Merge branch 'mesa_7_5_branch'
authorBrian Paul <brianp@vmware.com>
Wed, 17 Jun 2009 00:25:52 +0000 (18:25 -0600)
committerBrian Paul <brianp@vmware.com>
Wed, 17 Jun 2009 00:25:52 +0000 (18:25 -0600)
Conflicts:

src/mesa/main/api_validate.c

501 files changed:
Makefile
configs/autoconf.in
configs/default
configs/linux-x86-64-debug
configure.ac
docs/envvars.html
docs/relnotes-7.6.html [new file with mode: 0644]
docs/relnotes.html
include/GL/gl.h
include/GL/gl_mangle.h
include/GL/glext.h
include/GL/wglext.h
progs/demos/vao_demo.c
progs/glsl/multitex.c
progs/rbug/.gitignore [new file with mode: 0644]
progs/rbug/Makefile [new file with mode: 0644]
progs/rbug/README [new file with mode: 0644]
progs/rbug/bin_to_bmp.c [new file with mode: 0644]
progs/rbug/ctx_info.c [new file with mode: 0644]
progs/rbug/shdr_disable.c [new file with mode: 0644]
progs/rbug/shdr_dump.c [new file with mode: 0644]
progs/rbug/shdr_info.c [new file with mode: 0644]
progs/rbug/simple_client.c [new file with mode: 0644]
progs/rbug/simple_server.c [new file with mode: 0644]
progs/rbug/tex_dump.c [new file with mode: 0644]
progs/rbug/tex_info.c [new file with mode: 0644]
progs/samples/prim.c
progs/tests/Makefile
progs/tests/SConscript
progs/tests/arbgpuprog.c [new file with mode: 0644]
progs/tests/getteximage.c [new file with mode: 0644]
progs/tests/persp_hint.c [new file with mode: 0644]
progs/trivial/.gitignore
progs/util/extfuncs.h
scons/gallium.py
src/egl/drivers/dri/Makefile
src/egl/drivers/glx/Makefile
src/egl/drivers/xdri/Makefile
src/egl/main/Makefile
src/gallium/SConscript
src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
src/gallium/auxiliary/draw/draw_vs_exec.c
src/gallium/auxiliary/gallivm/instructionssoa.cpp
src/gallium/auxiliary/rbug/Makefile [new file with mode: 0644]
src/gallium/auxiliary/rbug/README [new file with mode: 0644]
src/gallium/auxiliary/rbug/SConscript [new file with mode: 0644]
src/gallium/auxiliary/rbug/rbug.h [new file with mode: 0644]
src/gallium/auxiliary/rbug/rbug_connection.c [new file with mode: 0644]
src/gallium/auxiliary/rbug/rbug_connection.h [new file with mode: 0644]
src/gallium/auxiliary/rbug/rbug_context.c [new file with mode: 0644]
src/gallium/auxiliary/rbug/rbug_context.h [new file with mode: 0644]
src/gallium/auxiliary/rbug/rbug_core.c [new file with mode: 0644]
src/gallium/auxiliary/rbug/rbug_core.h [new file with mode: 0644]
src/gallium/auxiliary/rbug/rbug_demarshal.c [new file with mode: 0644]
src/gallium/auxiliary/rbug/rbug_internal.h [new file with mode: 0644]
src/gallium/auxiliary/rbug/rbug_proto.h [new file with mode: 0644]
src/gallium/auxiliary/rbug/rbug_shader.c [new file with mode: 0644]
src/gallium/auxiliary/rbug/rbug_shader.h [new file with mode: 0644]
src/gallium/auxiliary/rbug/rbug_texture.c [new file with mode: 0644]
src/gallium/auxiliary/rbug/rbug_texture.h [new file with mode: 0644]
src/gallium/auxiliary/trace/trace_drm.h [new file with mode: 0644]
src/gallium/auxiliary/util/Makefile
src/gallium/auxiliary/util/SConscript
src/gallium/auxiliary/util/u_network.c [new file with mode: 0644]
src/gallium/auxiliary/util/u_network.h [new file with mode: 0644]
src/gallium/drivers/cell/spu/spu_render.c
src/gallium/drivers/cell/spu/spu_tri.c
src/gallium/drivers/cell/spu/spu_tri.h
src/gallium/drivers/nouveau/Makefile [new file with mode: 0644]
src/gallium/drivers/nouveau/nouveau_push.h
src/gallium/drivers/nouveau/nouveau_screen.c [new file with mode: 0644]
src/gallium/drivers/nouveau/nouveau_screen.h [new file with mode: 0644]
src/gallium/drivers/nouveau/nouveau_stateobj.h
src/gallium/drivers/nouveau/nouveau_winsys.h
src/gallium/drivers/nv04/nv04_miptree.c
src/gallium/drivers/nv04/nv04_screen.c
src/gallium/drivers/nv04/nv04_screen.h
src/gallium/drivers/nv04/nv04_state.c
src/gallium/drivers/nv04/nv04_state.h
src/gallium/drivers/nv04/nv04_surface_2d.c
src/gallium/drivers/nv04/nv04_surface_2d.h
src/gallium/drivers/nv04/nv04_vbo.c
src/gallium/drivers/nv10/nv10_context.c
src/gallium/drivers/nv10/nv10_prim_vbuf.c
src/gallium/drivers/nv10/nv10_screen.c
src/gallium/drivers/nv10/nv10_screen.h
src/gallium/drivers/nv10/nv10_state.c
src/gallium/drivers/nv10/nv10_vbo.c
src/gallium/drivers/nv20/nv20_context.c
src/gallium/drivers/nv20/nv20_prim_vbuf.c
src/gallium/drivers/nv20/nv20_screen.c
src/gallium/drivers/nv20/nv20_screen.h
src/gallium/drivers/nv20/nv20_state.c
src/gallium/drivers/nv20/nv20_vbo.c
src/gallium/drivers/nv20/nv20_vertprog.c
src/gallium/drivers/nv30/nv30_fragprog.c
src/gallium/drivers/nv30/nv30_fragtex.c
src/gallium/drivers/nv30/nv30_query.c
src/gallium/drivers/nv30/nv30_screen.c
src/gallium/drivers/nv30/nv30_screen.h
src/gallium/drivers/nv30/nv30_state_emit.c
src/gallium/drivers/nv30/nv30_state_fb.c
src/gallium/drivers/nv30/nv30_vbo.c
src/gallium/drivers/nv30/nv30_vertprog.c
src/gallium/drivers/nv40/nv40_draw.c
src/gallium/drivers/nv40/nv40_fragprog.c
src/gallium/drivers/nv40/nv40_fragtex.c
src/gallium/drivers/nv40/nv40_query.c
src/gallium/drivers/nv40/nv40_screen.c
src/gallium/drivers/nv40/nv40_screen.h
src/gallium/drivers/nv40/nv40_state_emit.c
src/gallium/drivers/nv40/nv40_state_fb.c
src/gallium/drivers/nv40/nv40_surface.c
src/gallium/drivers/nv40/nv40_vbo.c
src/gallium/drivers/nv40/nv40_vertprog.c
src/gallium/drivers/nv50/nv50_clear.c
src/gallium/drivers/nv50/nv50_context.c
src/gallium/drivers/nv50/nv50_context.h
src/gallium/drivers/nv50/nv50_miptree.c
src/gallium/drivers/nv50/nv50_program.c
src/gallium/drivers/nv50/nv50_program.h
src/gallium/drivers/nv50/nv50_query.c
src/gallium/drivers/nv50/nv50_screen.c
src/gallium/drivers/nv50/nv50_screen.h
src/gallium/drivers/nv50/nv50_state.c
src/gallium/drivers/nv50/nv50_state_validate.c
src/gallium/drivers/nv50/nv50_surface.c
src/gallium/drivers/nv50/nv50_tex.c
src/gallium/drivers/nv50/nv50_transfer.c
src/gallium/drivers/nv50/nv50_vbo.c
src/gallium/drivers/r300/r300_chipset.c
src/gallium/drivers/r300/r300_chipset.h
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_cs.h
src/gallium/drivers/r300/r300_debug.c
src/gallium/drivers/r300/r300_debug.h
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_emit.h
src/gallium/drivers/r300/r300_reg.h
src/gallium/drivers/r300/r300_render.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r300/r300_state_derived.c
src/gallium/drivers/r300/r300_state_inlines.h
src/gallium/drivers/r300/r300_state_invariant.c
src/gallium/drivers/r300/r300_state_shader.c
src/gallium/drivers/r300/r300_state_shader.h
src/gallium/drivers/r300/r300_state_tcl.c
src/gallium/drivers/r300/r300_state_tcl.h
src/gallium/drivers/r300/r300_surface.c
src/gallium/drivers/r300/r300_surface.h
src/gallium/drivers/r300/r300_texture.c
src/gallium/drivers/r300/r300_winsys.h
src/gallium/drivers/softpipe/sp_context.h
src/gallium/drivers/softpipe/sp_quad_pipe.c
src/gallium/drivers/softpipe/sp_query.c
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/drivers/softpipe/sp_setup.c
src/gallium/drivers/softpipe/sp_texture.c
src/gallium/drivers/trace/Makefile
src/gallium/drivers/trace/README
src/gallium/drivers/trace/SConscript
src/gallium/drivers/trace/tr_context.c
src/gallium/drivers/trace/tr_context.h
src/gallium/drivers/trace/tr_dump_state.c [new file with mode: 0644]
src/gallium/drivers/trace/tr_dump_state.h [new file with mode: 0644]
src/gallium/drivers/trace/tr_rbug.c [new file with mode: 0644]
src/gallium/drivers/trace/tr_screen.c
src/gallium/drivers/trace/tr_screen.h
src/gallium/drivers/trace/tr_state.c
src/gallium/drivers/trace/tr_state.h
src/gallium/include/pipe/p_defines.h
src/gallium/include/pipe/p_thread.h
src/gallium/state_trackers/dri/dri_drawable.c
src/gallium/state_trackers/dri/dri_drawable.h
src/gallium/state_trackers/dri/dri_extensions.c
src/gallium/state_trackers/egl/Makefile
src/gallium/state_trackers/glx/xlib/fakeglx.c
src/gallium/state_trackers/glx/xlib/xm_api.c
src/gallium/winsys/drm/Makefile.template
src/gallium/winsys/drm/intel/SConscript [new file with mode: 0644]
src/gallium/winsys/drm/intel/dri/Makefile
src/gallium/winsys/drm/intel/dri/SConscript [new file with mode: 0644]
src/gallium/winsys/drm/intel/gem/SConscript [new file with mode: 0644]
src/gallium/winsys/drm/intel/gem/intel_be_api.c
src/gallium/winsys/drm/intel/xorg/Makefile
src/gallium/winsys/drm/nouveau/Makefile
src/gallium/winsys/drm/nouveau/dri/Makefile
src/gallium/winsys/drm/nouveau/dri/nouveau_context.c [deleted file]
src/gallium/winsys/drm/nouveau/dri/nouveau_context.h [deleted file]
src/gallium/winsys/drm/nouveau/dri/nouveau_dri.h [deleted file]
src/gallium/winsys/drm/nouveau/dri/nouveau_lock.c [deleted file]
src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c [deleted file]
src/gallium/winsys/drm/nouveau/dri/nouveau_screen.h [deleted file]
src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.c [deleted file]
src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.h [deleted file]
src/gallium/winsys/drm/nouveau/dri2/Makefile [deleted file]
src/gallium/winsys/drm/nouveau/drm/Makefile
src/gallium/winsys/drm/nouveau/drm/nouveau_dri.h [new file with mode: 0644]
src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h
src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c [deleted file]
src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c [deleted file]
src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h [deleted file]
src/gallium/winsys/drm/radeon/core/radeon_buffer.c
src/gallium/winsys/drm/radeon/core/radeon_drm.c
src/gallium/winsys/drm/radeon/core/radeon_r300.c
src/gallium/winsys/drm/radeon/core/radeon_r300.h
src/gallium/winsys/drm/radeon/dri/Makefile
src/gallium/winsys/drm/radeon/egl/Makefile
src/gallium/winsys/drm/radeon/xorg/Makefile
src/gallium/winsys/egl_xlib/Makefile
src/gallium/winsys/egl_xlib/egl_xlib.c
src/gallium/winsys/gdi/SConscript
src/gallium/winsys/xlib/Makefile
src/glu/Makefile
src/glut/fbdev/Makefile
src/glut/glx/Makefile
src/glut/mini/Makefile
src/glw/Makefile
src/glx/x11/dri_common.c
src/glx/x11/indirect.c
src/mesa/Makefile
src/mesa/drivers/common/driverfuncs.c
src/mesa/drivers/dri/Makefile.template
src/mesa/drivers/dri/common/dri_util.c
src/mesa/drivers/dri/common/extension_helper.h
src/mesa/drivers/dri/i915/Makefile
src/mesa/drivers/dri/i915/i830_reg.h
src/mesa/drivers/dri/i915/i830_state.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_reg.h
src/mesa/drivers/dri/i915/i915_tex_layout.c
src/mesa/drivers/dri/i915/i915_texstate.c
src/mesa/drivers/dri/i915/i915_vtbl.c
src/mesa/drivers/dri/i915/intel_generatemipmap.c [new symlink]
src/mesa/drivers/dri/i965/Makefile
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_curbe.c
src/mesa/drivers/dri/i965/brw_draw_upload.c
src/mesa/drivers/dri/i965/brw_eu.h
src/mesa/drivers/dri/i965/brw_misc_state.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_cache.c
src/mesa/drivers/dri/i965/brw_state_upload.c
src/mesa/drivers/dri/i965/brw_tex_layout.c
src/mesa/drivers/dri/i965/brw_vs_emit.c
src/mesa/drivers/dri/i965/brw_vs_surface_state.c [new file with mode: 0644]
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
src/mesa/drivers/dri/i965/brw_wm_iz.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_surface_state.c
src/mesa/drivers/dri/i965/intel_generatemipmap.c [new symlink]
src/mesa/drivers/dri/intel/intel_buffer_objects.c
src/mesa/drivers/dri/intel/intel_buffer_objects.h
src/mesa/drivers/dri/intel/intel_buffers.c
src/mesa/drivers/dri/intel/intel_clear.c
src/mesa/drivers/dri/intel/intel_context.c
src/mesa/drivers/dri/intel/intel_context.h
src/mesa/drivers/dri/intel/intel_extensions.c
src/mesa/drivers/dri/intel/intel_fbo.c
src/mesa/drivers/dri/intel/intel_generatemipmap.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_mipmap_tree.c
src/mesa/drivers/dri/intel/intel_mipmap_tree.h
src/mesa/drivers/dri/intel/intel_pixel.c
src/mesa/drivers/dri/intel/intel_pixel.h
src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
src/mesa/drivers/dri/intel/intel_pixel_draw.c
src/mesa/drivers/dri/intel/intel_reg.h
src/mesa/drivers/dri/intel/intel_regions.c
src/mesa/drivers/dri/intel/intel_regions.h
src/mesa/drivers/dri/intel/intel_screen.c
src/mesa/drivers/dri/intel/intel_tex.c
src/mesa/drivers/dri/intel/intel_tex.h
src/mesa/drivers/dri/intel/intel_tex_copy.c
src/mesa/drivers/dri/intel/intel_tex_image.c
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_subimage.c
src/mesa/drivers/dri/intel/intel_tex_validate.c
src/mesa/drivers/dri/r200/Makefile
src/mesa/drivers/dri/r200/r200_cmdbuf.c
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_lock.c [deleted file]
src/mesa/drivers/dri/r200/r200_lock.h [deleted file]
src/mesa/drivers/dri/r200/r200_maos.h
src/mesa/drivers/dri/r200/r200_maos_arrays.c
src/mesa/drivers/dri/r200/r200_pixel.c
src/mesa/drivers/dri/r200/r200_reg.h
src/mesa/drivers/dri/r200/r200_span.c [deleted file]
src/mesa/drivers/dri/r200/r200_span.h [deleted file]
src/mesa/drivers/dri/r200/r200_state.c
src/mesa/drivers/dri/r200/r200_state.h
src/mesa/drivers/dri/r200/r200_state_init.c
src/mesa/drivers/dri/r200/r200_swtcl.c
src/mesa/drivers/dri/r200/r200_swtcl.h
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 [deleted file]
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_draw.c [new file with mode: 0644]
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_common.c [new file with mode: 0644]
src/mesa/drivers/dri/r300/r300_fragprog_common.h [new file with mode: 0644]
src/mesa/drivers/dri/r300/r300_fragprog_emit.c
src/mesa/drivers/dri/r300/r300_ioctl.c
src/mesa/drivers/dri/r300/r300_ioctl.h
src/mesa/drivers/dri/r300/r300_mem.c [deleted file]
src/mesa/drivers/dri/r300/r300_mem.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_render.h [new file with mode: 0644]
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_swtcl.h
src/mesa/drivers/dri/r300/r300_tex.c
src/mesa/drivers/dri/r300/r300_tex.h
src/mesa/drivers/dri/r300/r300_texmem.c [deleted file]
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
src/mesa/drivers/dri/r300/r500_fragprog.h
src/mesa/drivers/dri/r300/r500_fragprog_emit.c
src/mesa/drivers/dri/r300/radeon_context.c [deleted file]
src/mesa/drivers/dri/r300/radeon_context.h
src/mesa/drivers/dri/r300/radeon_ioctl.c [deleted file]
src/mesa/drivers/dri/r300/radeon_ioctl.h [deleted file]
src/mesa/drivers/dri/r300/radeon_lock.c [deleted file]
src/mesa/drivers/dri/r300/radeon_lock.h [deleted file]
src/mesa/drivers/dri/r300/radeon_program_pair.c
src/mesa/drivers/dri/r300/radeon_span.c [deleted file]
src/mesa/drivers/dri/r300/radeon_state.c [deleted file]
src/mesa/drivers/dri/r300/radeon_state.h [deleted file]
src/mesa/drivers/dri/radeon/Makefile
src/mesa/drivers/dri/radeon/radeon_bo_drm.h [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_bo_legacy.c [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_bo_legacy.h [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_bocs_wrapper.h [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_cmdbuf.h [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_common.c [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_common.h [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_common_context.c [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_common_context.h [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_compat.c [deleted file]
src/mesa/drivers/dri/radeon/radeon_context.c
src/mesa/drivers/dri/radeon/radeon_context.h
src/mesa/drivers/dri/radeon/radeon_cs_drm.h [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_cs_legacy.c [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_cs_legacy.h [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_dma.c [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_dma.h [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_fbo.c [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_ioctl.c
src/mesa/drivers/dri/radeon/radeon_ioctl.h
src/mesa/drivers/dri/radeon/radeon_lock.c
src/mesa/drivers/dri/radeon/radeon_lock.h
src/mesa/drivers/dri/radeon/radeon_maos.h
src/mesa/drivers/dri/radeon/radeon_maos_arrays.c
src/mesa/drivers/dri/radeon/radeon_maos_verts.c
src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_sanity.c
src/mesa/drivers/dri/radeon/radeon_sanity.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_span.h
src/mesa/drivers/dri/radeon/radeon_state.c
src/mesa/drivers/dri/radeon/radeon_state.h
src/mesa/drivers/dri/radeon/radeon_state_init.c
src/mesa/drivers/dri/radeon/radeon_swtcl.c
src/mesa/drivers/dri/radeon/radeon_swtcl.h
src/mesa/drivers/dri/radeon/radeon_tcl.c
src/mesa/drivers/dri/radeon/radeon_tex.c
src/mesa/drivers/dri/radeon/radeon_tex.h
src/mesa/drivers/dri/radeon/radeon_texmem.c [deleted file]
src/mesa/drivers/dri/radeon/radeon_texstate.c
src/mesa/drivers/dri/radeon/radeon_texture.c [new file with mode: 0644]
src/mesa/drivers/dri/radeon/radeon_texture.h [new file with mode: 0644]
src/mesa/drivers/dri/radeon/server/radeon_reg.h
src/mesa/drivers/x11/xm_dd.c
src/mesa/glapi/ARB_copy_buffer.xml [new file with mode: 0644]
src/mesa/glapi/ARB_map_buffer_range.xml [new file with mode: 0644]
src/mesa/glapi/Makefile
src/mesa/glapi/dispatch.h
src/mesa/glapi/glX_proto_send.py
src/mesa/glapi/gl_API.xml
src/mesa/glapi/glapioffsets.h
src/mesa/glapi/glapitable.h
src/mesa/glapi/glapitemp.h
src/mesa/glapi/glprocs.h
src/mesa/main/api_arrayelt.c
src/mesa/main/api_exec.c
src/mesa/main/api_noop.c
src/mesa/main/api_validate.c
src/mesa/main/arrayobj.c
src/mesa/main/arrayobj.h
src/mesa/main/attrib.c
src/mesa/main/bufferobj.c
src/mesa/main/bufferobj.h
src/mesa/main/buffers.c
src/mesa/main/config.h
src/mesa/main/context.c
src/mesa/main/dd.h
src/mesa/main/debug.c
src/mesa/main/debug.h
src/mesa/main/dlist.c
src/mesa/main/enable.c
src/mesa/main/enums.c
src/mesa/main/extensions.c
src/mesa/main/fbobject.c
src/mesa/main/image.c
src/mesa/main/mfeatures.h
src/mesa/main/mipmap.c
src/mesa/main/mtypes.h
src/mesa/main/pixel.c
src/mesa/main/pixelstore.c
src/mesa/main/shared.c
src/mesa/main/state.c
src/mesa/main/texobj.c
src/mesa/main/texobj.h
src/mesa/main/texparam.c
src/mesa/main/texstate.c
src/mesa/main/varray.c
src/mesa/main/varray.h
src/mesa/main/version.h
src/mesa/math/m_vector.c
src/mesa/math/m_vector.h
src/mesa/shader/arbprogparse.c
src/mesa/shader/arbprogram.c
src/mesa/shader/nvprogram.c
src/mesa/shader/prog_execute.c
src/mesa/shader/prog_instruction.c
src/mesa/shader/prog_optimize.c
src/mesa/shader/prog_optimize.h
src/mesa/shader/prog_print.c
src/mesa/shader/shader_api.c
src/mesa/shader/slang/slang_link.c
src/mesa/sparc/glapi_sparc.S
src/mesa/state_tracker/st_atom_constbuf.c
src/mesa/state_tracker/st_atom_framebuffer.c
src/mesa/state_tracker/st_cb_bufferobjects.c
src/mesa/state_tracker/st_cb_fbo.c
src/mesa/state_tracker/st_cb_fbo.h
src/mesa/state_tracker/st_cb_flush.c
src/mesa/state_tracker/st_cb_rasterpos.c
src/mesa/state_tracker/st_context.h
src/mesa/state_tracker/st_draw.c
src/mesa/state_tracker/st_draw.h
src/mesa/state_tracker/st_draw_feedback.c
src/mesa/state_tracker/st_extensions.c
src/mesa/state_tracker/st_framebuffer.c
src/mesa/state_tracker/st_program.c
src/mesa/state_tracker/st_public.h
src/mesa/swrast/s_imaging.c
src/mesa/swrast/s_span.c
src/mesa/swrast/s_texfilter.c
src/mesa/tnl/t_vb_cliptmp.h
src/mesa/tnl/t_vb_program.c
src/mesa/vbo/vbo_attrib_tmp.h
src/mesa/vbo/vbo_context.c
src/mesa/vbo/vbo_context.h
src/mesa/vbo/vbo_exec.h
src/mesa/vbo/vbo_exec_api.c
src/mesa/vbo/vbo_exec_array.c
src/mesa/vbo/vbo_exec_draw.c
src/mesa/vbo/vbo_rebase.c
src/mesa/vbo/vbo_split_copy.c
src/mesa/vbo/vbo_split_inplace.c
src/mesa/x86-64/glapi_x86-64.S
src/mesa/x86/glapi_x86.S

index 22334d6ee48966f845fa6c36a92d81750a6e885a..146c52093b299346cc643439b5e8cb9406c54827 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -182,7 +182,7 @@ ultrix-gcc:
 
 # Rules for making release tarballs
 
-VERSION=7.5-rc3
+VERSION=7.6-devel
 DIRECTORY = Mesa-$(VERSION)
 LIB_NAME = MesaLib-$(VERSION)
 DEMO_NAME = MesaDemos-$(VERSION)
index b61d7f33f009eb97bb101c52ac15074923d29716..83737e3a7df8e8e4fb334ea504b8daf79f305538 100644 (file)
@@ -20,6 +20,8 @@ CXXFLAGS = @CPPFLAGS@ @CXXFLAGS@ \
        $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
 LDFLAGS = @LDFLAGS@
 EXTRA_LIB_PATH = @EXTRA_LIB_PATH@
+RADEON_CFLAGS = @RADEON_CFLAGS@
+RADEON_LDFLAGS = @RADEON_LDFLAGS@
 
 # Assembler
 MESA_ASM_SOURCES = @MESA_ASM_SOURCES@
@@ -31,6 +33,7 @@ SHELL = @SHELL@
 MKLIB_OPTIONS = @MKLIB_OPTIONS@
 MKDEP = @MKDEP@
 MKDEP_OPTIONS = @MKDEP_OPTIONS@
+INSTALL = @INSTALL@
 
 # Python and flags (generally only needed by the developers)
 PYTHON2 = python
index b5ef80afb36a03f6db3b0e0461c2508aafaa375e..dc28be37ddf33477164f47615f2739711147efba 100644 (file)
@@ -9,7 +9,7 @@ CONFIG_NAME = default
 
 # Version info
 MESA_MAJOR=7
-MESA_MINOR=5
+MESA_MINOR=6
 MESA_TINY=0
 MESA_VERSION = $(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY)
 
@@ -36,7 +36,10 @@ MKLIB_OPTIONS =
 MKDEP = makedepend
 MKDEP_OPTIONS = -fdepend
 MAKE = make
-INSTALL = $(SHELL) $(TOP)/bin/minstall
+
+# Use MINSTALL for installing libraries, INSTALL for everything else
+MINSTALL = $(SHELL) $(TOP)/bin/minstall
+INSTALL = $(MINSTALL)
 
 # Tools for regenerating glapi (generally only needed by the developers)
 PYTHON2 = python
@@ -90,7 +93,7 @@ EGL_DRIVERS_DIRS = demo
 
 # Gallium directories and 
 GALLIUM_DIRS = auxiliary drivers state_trackers
-GALLIUM_AUXILIARY_DIRS = draw translate cso_cache pipebuffer tgsi sct rtasm util indices
+GALLIUM_AUXILIARY_DIRS = rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices
 GALLIUM_AUXILIARIES = $(foreach DIR,$(GALLIUM_AUXILIARY_DIRS),$(TOP)/src/gallium/auxiliary/$(DIR)/lib$(DIR).a)
 GALLIUM_DRIVERS_DIRS = softpipe i915simple failover trace
 GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
index 46e72c990af91d88f592df1b04070bcf21666685..6f631c0e8799982b6ddba90483f3f035f657bdfb 100644 (file)
@@ -4,4 +4,5 @@ include $(TOP)/configs/linux-x86-64
 
 CONFIG_NAME = linux-x86-64-debug
 
+OPT_FLAGS = -g
 DEFINES += -DDEBUG -DDEBUG_MATH
index 2a9ac1ed9cd245930672c67d165ac645b7d2187b..f34a4740b31b5288393079ceb67ad94282e1b864 100644 (file)
@@ -29,6 +29,11 @@ AC_CHECK_PROGS([MAKE], [gmake make])
 AC_PATH_PROG([MKDEP], [makedepend])
 AC_PATH_PROG([SED], [sed])
 
+dnl Our fallback install-sh is a symlink to minstall. Use the existing
+dnl configuration in that case.
+AC_PROG_INSTALL
+test "x$INSTALL" = "x$ac_install_sh" && INSTALL='$(MINSTALL)'
+
 dnl We need a POSIX shell for parts of the build. Assume we have one
 dnl in most cases.
 case "$host_os" in
@@ -411,7 +416,7 @@ WINDOW_SYSTEM=""
 GALLIUM_DIRS="auxiliary drivers state_trackers"
 GALLIUM_WINSYS_DIRS=""
 GALLIUM_WINSYS_DRM_DIRS=""
-GALLIUM_AUXILIARY_DIRS="draw translate cso_cache pipebuffer tgsi sct rtasm util indices"
+GALLIUM_AUXILIARY_DIRS="rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices"
 GALLIUM_DRIVERS_DIRS="softpipe failover trace"
 GALLIUM_STATE_TRACKERS_DIRS=""
 
@@ -440,6 +445,8 @@ AC_SUBST([GALLIUM_WINSYS_DRM_DIRS])
 AC_SUBST([GALLIUM_DRIVERS_DIRS])
 AC_SUBST([GALLIUM_AUXILIARY_DIRS])
 AC_SUBST([GALLIUM_STATE_TRACKERS_DIRS])
+AC_SUBST([RADEON_CFLAGS])
+AC_SUBST([RADEON_LDFLAGS])
 
 dnl
 dnl User supplied program configuration
@@ -567,6 +574,13 @@ dri)
     GL_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED dri2proto >= $DRI2PROTO_REQUIRED"
     DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED"
 
+    PKG_CHECK_MODULES([LIBDRM_RADEON], [libdrm_radeon], HAVE_LIBDRM_RADEON=yes, HAVE_LIBDRM_RADEON=no)
+
+    if test "$HAVE_LIBDRM_RADEON" = yes; then
+       RADEON_CFLAGS="-DHAVE_LIBDRM_RADEON=1 $LIBDRM_RADEON_CFLAGS"
+       RADEON_LDFLAGS=$LIBDRM_RADEON_LIBS
+    fi
+
     # find the DRI deps for libGL
     if test "$x11_pkgconfig" = yes; then
         # add xcb modules if necessary
@@ -1181,7 +1195,7 @@ AC_ARG_ENABLE([gallium-nouveau],
     [enable_gallium_nouveau=no])
 if test "x$enable_gallium_nouveau" = xyes; then
     GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS nouveau"
-    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nv04 nv10 nv20 nv30 nv40 nv50"
+    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nv04 nv10 nv20 nv30 nv40 nv50"
 fi
 
 
index 7fd9fe7c0a83f48d8fe98405ace0a88f51fff79f..6d7a321da9fb577c39e87adaea57a314ec2c402b 100644 (file)
@@ -25,6 +25,9 @@ fragment programs (intended for developers only)
 <li>MESA_TNL_PROG - if set, implement conventional vertex transformation
 operations with vertex programs (intended for developers only).
 Setting this variable automatically sets the MESA_TEX_PROG variable as well.
+<li>MESA_EXTENSION_OVERRIDE - can be used to enable/disable extensions.
+A value such as "GL_EXT_foo -GL_EXT_bar" will enable the GL_EXT_foo extension
+and disable the GL_EXT_bar extension.
 </ul>
 
 <p>
diff --git a/docs/relnotes-7.6.html b/docs/relnotes-7.6.html
new file mode 100644 (file)
index 0000000..82a924c
--- /dev/null
@@ -0,0 +1,61 @@
+<HTML>
+
+<TITLE>Mesa Release Notes</TITLE>
+
+<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<body bgcolor="#eeeeee">
+
+<H1>Mesa 7.6 Release Notes / date TBD</H1>
+
+<p>
+Mesa 7.6 is a new development release.
+People who are concerned with stability and reliability should stick
+with a previous release or wait for Mesa 7.6.1.
+</p>
+<p>
+Mesa 7.6 implements the OpenGL 2.1 API, but the version reported by
+glGetString(GL_VERSION) depends on the particular driver being used.
+Some drivers don't support all the features required in OpenGL 2.1.
+</p>
+<p>
+See the <a href="install.html">Compiling/Installing page</a> for prerequisites
+for DRI hardware acceleration.
+</p>
+
+
+<h2>MD5 checksums</h2>
+<pre>
+tbd
+</pre>
+
+
+<h2>New features</h2>
+<ul>
+<li><a href="openvg.html">OpenVG</a> front-end (state tracker for Gallium).
+This was written by Zack Rusin at Tungsten Graphics.
+<li>GL_APPLE_vertex_array_object for Gallium drivers and Intel DRI drivers.
+<li>GL_ARB_copy_buffer extension (supported in Gallium and swrast drivers)
+<li>Rewritten radeon/r200/r300 driver using a buffer manager
+<li>radeon/r200/r300 GL_EXT_framebuffer_object support when used with
+    kernel memory manager
+<li>r300 driver support for GL_EXT_vertex_array_bgra, GL_EXT_texture_sRGB
+<LI>GL_ARB_map_buffer_range extension (supported in Gallium and software drivers)
+</ul>
+
+
+<h2>Bug fixes</h2>
+<ul>
+<li>i965 DRI driver fixes, including support for "unlimited" size constant
+    buffers (GLSL uniforms)
+</ul>
+
+
+<h2>Changes</h2>
+<ul>
+</ul>
+
+</body>
+</html>
index 45746268af9451aeecf228f8162f6e13c123986f..ad5b74bad3c43c4a5e01175453e44c082882950b 100644 (file)
@@ -20,6 +20,7 @@ The release notes summarize what's new or changed in each Mesa release.
 </p>
 
 <UL>
+<LI><A HREF="relnotes-7.6.html">7.6 release notes</A>
 <LI><A HREF="relnotes-7.5.html">7.5 release notes</A>
 <LI><A HREF="relnotes-7.4.2.html">7.4.2 release notes</A>
 <LI><A HREF="relnotes-7.4.1.html">7.4.1 release notes</A>
index aad51214fbeae31ea795adc75c2746d8c2c7c416..05362b9776244564b9e34cae3559694c30649ff4 100644 (file)
@@ -1,8 +1,9 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.5
+ * Version:  7.6
  *
  * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ * Copyright (C) 2009  VMware, 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"),
@@ -1739,41 +1740,6 @@ GLAPI void GLAPIENTRY glSeparableFilter2D( GLenum target,
 GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format,
        GLenum type, GLvoid *row, GLvoid *column, GLvoid *span );
 
-typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
-typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode);
-typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
-typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
-typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table);
-typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
-typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
-typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
-typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params);
-typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params);
-typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
-typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image);
-typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
-typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
-typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
-typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
-typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
-typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink);
-typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target);
-typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target);
-
 
 
 /*
@@ -1978,53 +1944,6 @@ GLAPI void GLAPIENTRY glMultTransposeMatrixf( const GLfloat m[16] );
 
 GLAPI void GLAPIENTRY glSampleCoverage( GLclampf value, GLboolean invert );
 
-typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
-typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m);
-typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m);
-typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m);
-typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m);
-typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img);
-
 
 /*
  * GL_ARB_multitexture (ARB extension 1 and OpenGL 1.2.1)
index 639d7bb7a40f50c508b55f38e42fa3736bad5d18..54147f73382a0aab694b48eaddbac9146bfce344 100644 (file)
@@ -53,6 +53,7 @@
 #define glBeginFragmentShaderATI               MANGLE(BeginFragmentShaderATI)
 #define glBegin                MANGLE(Begin)
 #define glBeginOcclusionQueryNV                MANGLE(BeginOcclusionQueryNV)
+#define glBeginPerfMonitorAMD          MANGLE(BeginPerfMonitorAMD)
 #define glBeginQueryARB                MANGLE(BeginQueryARB)
 #define glBeginQuery           MANGLE(BeginQuery)
 #define glBeginTransformFeedbackEXT            MANGLE(BeginTransformFeedbackEXT)
 #define glConvolutionParameteri                MANGLE(ConvolutionParameteri)
 #define glConvolutionParameterivEXT            MANGLE(ConvolutionParameterivEXT)
 #define glConvolutionParameteriv               MANGLE(ConvolutionParameteriv)
+#define glCopyBufferSubData            MANGLE(CopyBufferSubData)
 #define glCopyColorSubTableEXT         MANGLE(CopyColorSubTableEXT)
 #define glCopyColorSubTable            MANGLE(CopyColorSubTable)
 #define glCopyColorTable               MANGLE(CopyColorTable)
 #define glDeleteLists          MANGLE(DeleteLists)
 #define glDeleteObjectARB              MANGLE(DeleteObjectARB)
 #define glDeleteOcclusionQueriesNV             MANGLE(DeleteOcclusionQueriesNV)
+#define glDeletePerfMonitorsAMD                MANGLE(DeletePerfMonitorsAMD)
 #define glDeleteProgram                MANGLE(DeleteProgram)
 #define glDeleteProgramsARB            MANGLE(DeleteProgramsARB)
 #define glDeleteProgramsNV             MANGLE(DeleteProgramsNV)
 #define glDrawArraysEXT                MANGLE(DrawArraysEXT)
 #define glDrawArraysInstancedARB               MANGLE(DrawArraysInstancedARB)
 #define glDrawArraysInstancedEXT               MANGLE(DrawArraysInstancedEXT)
+#define glDrawArraysInstanced          MANGLE(DrawArraysInstanced)
 #define glDrawArrays           MANGLE(DrawArrays)
 #define glDrawBuffer           MANGLE(DrawBuffer)
 #define glDrawBuffersARB               MANGLE(DrawBuffersARB)
 #define glDrawElementArrayATI          MANGLE(DrawElementArrayATI)
 #define glDrawElementsInstancedARB             MANGLE(DrawElementsInstancedARB)
 #define glDrawElementsInstancedEXT             MANGLE(DrawElementsInstancedEXT)
+#define glDrawElementsInstanced                MANGLE(DrawElementsInstanced)
 #define glDrawElements         MANGLE(DrawElements)
 #define glDrawMeshArraysSUN            MANGLE(DrawMeshArraysSUN)
 #define glDrawPixels           MANGLE(DrawPixels)
 #define glEndList              MANGLE(EndList)
 #define glEnd          MANGLE(End)
 #define glEndOcclusionQueryNV          MANGLE(EndOcclusionQueryNV)
+#define glEndPerfMonitorAMD            MANGLE(EndPerfMonitorAMD)
 #define glEndQueryARB          MANGLE(EndQueryARB)
 #define glEndQuery             MANGLE(EndQuery)
 #define glEndTransformFeedbackEXT              MANGLE(EndTransformFeedbackEXT)
 #define glGenFramebuffers              MANGLE(GenFramebuffers)
 #define glGenLists             MANGLE(GenLists)
 #define glGenOcclusionQueriesNV                MANGLE(GenOcclusionQueriesNV)
+#define glGenPerfMonitorsAMD           MANGLE(GenPerfMonitorsAMD)
 #define glGenProgramsARB               MANGLE(GenProgramsARB)
 #define glGenProgramsNV                MANGLE(GenProgramsNV)
 #define glGenQueriesARB                MANGLE(GenQueriesARB)
 #define glGetActiveAttribARB           MANGLE(GetActiveAttribARB)
 #define glGetActiveAttrib              MANGLE(GetActiveAttrib)
 #define glGetActiveUniformARB          MANGLE(GetActiveUniformARB)
+#define glGetActiveUniformBlockiv              MANGLE(GetActiveUniformBlockiv)
+#define glGetActiveUniformBlockName            MANGLE(GetActiveUniformBlockName)
 #define glGetActiveUniform             MANGLE(GetActiveUniform)
+#define glGetActiveUniformName         MANGLE(GetActiveUniformName)
+#define glGetActiveUniformsiv          MANGLE(GetActiveUniformsiv)
 #define glGetActiveVaryingNV           MANGLE(GetActiveVaryingNV)
 #define glGetArrayObjectfvATI          MANGLE(GetArrayObjectfvATI)
 #define glGetArrayObjectivATI          MANGLE(GetArrayObjectivATI)
 #define glGetObjectParameterivARB              MANGLE(GetObjectParameterivARB)
 #define glGetOcclusionQueryivNV                MANGLE(GetOcclusionQueryivNV)
 #define glGetOcclusionQueryuivNV               MANGLE(GetOcclusionQueryuivNV)
+#define glGetPerfMonitorCounterDataAMD         MANGLE(GetPerfMonitorCounterDataAMD)
+#define glGetPerfMonitorCounterInfoAMD         MANGLE(GetPerfMonitorCounterInfoAMD)
+#define glGetPerfMonitorCountersAMD            MANGLE(GetPerfMonitorCountersAMD)
+#define glGetPerfMonitorCounterStringAMD               MANGLE(GetPerfMonitorCounterStringAMD)
+#define glGetPerfMonitorGroupsAMD              MANGLE(GetPerfMonitorGroupsAMD)
+#define glGetPerfMonitorGroupStringAMD         MANGLE(GetPerfMonitorGroupStringAMD)
 #define glGetPixelMapfv                MANGLE(GetPixelMapfv)
 #define glGetPixelMapuiv               MANGLE(GetPixelMapuiv)
 #define glGetPixelMapusv               MANGLE(GetPixelMapusv)
 #define glGetTransformFeedbackVaryingEXT               MANGLE(GetTransformFeedbackVaryingEXT)
 #define glGetTransformFeedbackVarying          MANGLE(GetTransformFeedbackVarying)
 #define glGetTransformFeedbackVaryingNV                MANGLE(GetTransformFeedbackVaryingNV)
+#define glGetUniformBlockIndex         MANGLE(GetUniformBlockIndex)
 #define glGetUniformBufferSizeEXT              MANGLE(GetUniformBufferSizeEXT)
 #define glGetUniformfvARB              MANGLE(GetUniformfvARB)
 #define glGetUniformfv         MANGLE(GetUniformfv)
+#define glGetUniformIndices            MANGLE(GetUniformIndices)
 #define glGetUniformivARB              MANGLE(GetUniformivARB)
 #define glGetUniformiv         MANGLE(GetUniformiv)
 #define glGetUniformLocationARB                MANGLE(GetUniformLocationARB)
 #define glGetVertexAttribPointervARB           MANGLE(GetVertexAttribPointervARB)
 #define glGetVertexAttribPointerv              MANGLE(GetVertexAttribPointerv)
 #define glGetVertexAttribPointervNV            MANGLE(GetVertexAttribPointervNV)
+#define glGetVideoi64vNV               MANGLE(GetVideoi64vNV)
+#define glGetVideoivNV         MANGLE(GetVideoivNV)
+#define glGetVideoui64vNV              MANGLE(GetVideoui64vNV)
+#define glGetVideouivNV                MANGLE(GetVideouivNV)
 #define glGlobalAlphaFactorbSUN                MANGLE(GlobalAlphaFactorbSUN)
 #define glGlobalAlphaFactordSUN                MANGLE(GlobalAlphaFactordSUN)
 #define glGlobalAlphaFactorfSUN                MANGLE(GlobalAlphaFactorfSUN)
 #define glPopClientAttrib              MANGLE(PopClientAttrib)
 #define glPopMatrix            MANGLE(PopMatrix)
 #define glPopName              MANGLE(PopName)
+#define glPresentFrameDualFillNV               MANGLE(PresentFrameDualFillNV)
+#define glPresentFrameKeyedNV          MANGLE(PresentFrameKeyedNV)
+#define glPrimitiveRestartIndex                MANGLE(PrimitiveRestartIndex)
 #define glPrimitiveRestartIndexNV              MANGLE(PrimitiveRestartIndexNV)
 #define glPrimitiveRestartNV           MANGLE(PrimitiveRestartNV)
 #define glPrioritizeTexturesEXT                MANGLE(PrioritizeTexturesEXT)
 #define glProgramUniformMatrix4x2fvEXT         MANGLE(ProgramUniformMatrix4x2fvEXT)
 #define glProgramUniformMatrix4x3fvEXT         MANGLE(ProgramUniformMatrix4x3fvEXT)
 #define glProgramVertexLimitNV         MANGLE(ProgramVertexLimitNV)
+#define glProvokingVertexEXT           MANGLE(ProvokingVertexEXT)
 #define glPushAttrib           MANGLE(PushAttrib)
 #define glPushClientAttribDefaultEXT           MANGLE(PushClientAttribDefaultEXT)
 #define glPushClientAttrib             MANGLE(PushClientAttrib)
 #define glSecondaryColorPointerListIBM         MANGLE(SecondaryColorPointerListIBM)
 #define glSecondaryColorPointer                MANGLE(SecondaryColorPointer)
 #define glSelectBuffer         MANGLE(SelectBuffer)
+#define glSelectPerfMonitorCountersAMD         MANGLE(SelectPerfMonitorCountersAMD)
 #define glSeparableFilter2DEXT         MANGLE(SeparableFilter2DEXT)
 #define glSeparableFilter2D            MANGLE(SeparableFilter2D)
 #define glSetFenceAPPLE                MANGLE(SetFenceAPPLE)
 #define glTangent3svEXT                MANGLE(Tangent3svEXT)
 #define glTangentPointerEXT            MANGLE(TangentPointerEXT)
 #define glTbufferMask3DFX              MANGLE(TbufferMask3DFX)
+#define glTessellationFactorAMD                MANGLE(TessellationFactorAMD)
+#define glTessellationModeAMD          MANGLE(TessellationModeAMD)
 #define glTestFenceAPPLE               MANGLE(TestFenceAPPLE)
 #define glTestFenceNV          MANGLE(TestFenceNV)
 #define glTestObjectAPPLE              MANGLE(TestObjectAPPLE)
 #define glTexBufferARB         MANGLE(TexBufferARB)
 #define glTexBufferEXT         MANGLE(TexBufferEXT)
+#define glTexBuffer            MANGLE(TexBuffer)
 #define glTexBumpParameterfvATI                MANGLE(TexBumpParameterfvATI)
 #define glTexBumpParameterivATI                MANGLE(TexBumpParameterivATI)
 #define glTexCoord1d           MANGLE(TexCoord1d)
 #define glUniform4ui           MANGLE(Uniform4ui)
 #define glUniform4uivEXT               MANGLE(Uniform4uivEXT)
 #define glUniform4uiv          MANGLE(Uniform4uiv)
+#define glUniformBlockBinding          MANGLE(UniformBlockBinding)
 #define glUniformBufferEXT             MANGLE(UniformBufferEXT)
 #define glUniformMatrix2fvARB          MANGLE(UniformMatrix2fvARB)
 #define glUniformMatrix2fv             MANGLE(UniformMatrix2fv)
 #define glVertexAttrib4usvARB          MANGLE(VertexAttrib4usvARB)
 #define glVertexAttrib4usv             MANGLE(VertexAttrib4usv)
 #define glVertexAttribArrayObjectATI           MANGLE(VertexAttribArrayObjectATI)
-#define glVertexAttribDivisor          MANGLE(VertexAttribDivisor)
+#define glVertexAttribDivisorARB               MANGLE(VertexAttribDivisorARB)
 #define glVertexAttribI1iEXT           MANGLE(VertexAttribI1iEXT)
 #define glVertexAttribI1i              MANGLE(VertexAttribI1i)
 #define glVertexAttribI1ivEXT          MANGLE(VertexAttribI1ivEXT)
index 41149c935a97f87ac5233c09399e6c53cd4e547c..5429287d3fb49e8190bf7b84527764918744fd0f 100644 (file)
@@ -6,7 +6,7 @@ extern "C" {
 #endif
 
 /*
-** Copyright (c) 2007 The Khronos Group Inc.
+** Copyright (c) 2007-2009 The Khronos Group Inc.
 ** 
 ** Permission is hereby granted, free of charge, to any person obtaining a
 ** copy of this software and/or associated documentation files (the
@@ -28,6 +28,13 @@ extern "C" {
 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
 */
 
+/* Header file version number, required by OpenGL ABI for Linux */
+/* glext.h last updated $Date: 2009-05-05 15:27:42 -0700 (Tue, 05 May 2009) $ */
+/* Current version at http://www.opengl.org/registry/ */
+#define GL_GLEXT_VERSION 52
+
+/* Function declaration macros - to move into glplatform.h */
+
 #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
 #define WIN32_LEAN_AND_MEAN 1
 #include <windows.h>
@@ -45,18 +52,12 @@ extern "C" {
 
 /*************************************************************/
 
-/* Header file version number, required by OpenGL ABI for Linux */
-/* glext.h last updated 2009/03/19 */
-/* Current version at http://www.opengl.org/registry/ */
-#define GL_GLEXT_VERSION 48
-
 #ifndef GL_VERSION_1_2
 #define GL_UNSIGNED_BYTE_3_3_2            0x8032
 #define GL_UNSIGNED_SHORT_4_4_4_4         0x8033
 #define GL_UNSIGNED_SHORT_5_5_5_1         0x8034
 #define GL_UNSIGNED_INT_8_8_8_8           0x8035
 #define GL_UNSIGNED_INT_10_10_10_2        0x8036
-#define GL_RESCALE_NORMAL                 0x803A
 #define GL_TEXTURE_BINDING_3D             0x806A
 #define GL_PACK_SKIP_IMAGES               0x806B
 #define GL_PACK_IMAGE_HEIGHT              0x806C
@@ -83,17 +84,21 @@ extern "C" {
 #define GL_TEXTURE_MAX_LOD                0x813B
 #define GL_TEXTURE_BASE_LEVEL             0x813C
 #define GL_TEXTURE_MAX_LEVEL              0x813D
-#define GL_LIGHT_MODEL_COLOR_CONTROL      0x81F8
-#define GL_SINGLE_COLOR                   0x81F9
-#define GL_SEPARATE_SPECULAR_COLOR        0x81FA
 #define GL_SMOOTH_POINT_SIZE_RANGE        0x0B12
 #define GL_SMOOTH_POINT_SIZE_GRANULARITY  0x0B13
 #define GL_SMOOTH_LINE_WIDTH_RANGE        0x0B22
 #define GL_SMOOTH_LINE_WIDTH_GRANULARITY  0x0B23
-#define GL_ALIASED_POINT_SIZE_RANGE       0x846D
 #define GL_ALIASED_LINE_WIDTH_RANGE       0x846E
 #endif
 
+#ifndef GL_VERSION_1_2_DEPRECATED
+#define GL_RESCALE_NORMAL                 0x803A
+#define GL_LIGHT_MODEL_COLOR_CONTROL      0x81F8
+#define GL_SINGLE_COLOR                   0x81F9
+#define GL_SEPARATE_SPECULAR_COLOR        0x81FA
+#define GL_ALIASED_POINT_SIZE_RANGE       0x846D
+#endif
+
 #ifndef GL_ARB_imaging
 #define GL_CONSTANT_COLOR                 0x8001
 #define GL_ONE_MINUS_CONSTANT_COLOR       0x8002
@@ -106,6 +111,9 @@ extern "C" {
 #define GL_BLEND_EQUATION                 0x8009
 #define GL_FUNC_SUBTRACT                  0x800A
 #define GL_FUNC_REVERSE_SUBTRACT          0x800B
+#endif
+
+#ifndef GL_ARB_imaging_DEPRECATED
 #define GL_CONVOLUTION_1D                 0x8010
 #define GL_CONVOLUTION_2D                 0x8011
 #define GL_SEPARABLE_2D                   0x8012
@@ -206,12 +214,6 @@ extern "C" {
 #define GL_TEXTURE30                      0x84DE
 #define GL_TEXTURE31                      0x84DF
 #define GL_ACTIVE_TEXTURE                 0x84E0
-#define GL_CLIENT_ACTIVE_TEXTURE          0x84E1
-#define GL_MAX_TEXTURE_UNITS              0x84E2
-#define GL_TRANSPOSE_MODELVIEW_MATRIX     0x84E3
-#define GL_TRANSPOSE_PROJECTION_MATRIX    0x84E4
-#define GL_TRANSPOSE_TEXTURE_MATRIX       0x84E5
-#define GL_TRANSPOSE_COLOR_MATRIX         0x84E6
 #define GL_MULTISAMPLE                    0x809D
 #define GL_SAMPLE_ALPHA_TO_COVERAGE       0x809E
 #define GL_SAMPLE_ALPHA_TO_ONE            0x809F
@@ -220,9 +222,6 @@ extern "C" {
 #define GL_SAMPLES                        0x80A9
 #define GL_SAMPLE_COVERAGE_VALUE          0x80AA
 #define GL_SAMPLE_COVERAGE_INVERT         0x80AB
-#define GL_MULTISAMPLE_BIT                0x20000000
-#define GL_NORMAL_MAP                     0x8511
-#define GL_REFLECTION_MAP                 0x8512
 #define GL_TEXTURE_CUBE_MAP               0x8513
 #define GL_TEXTURE_BINDING_CUBE_MAP       0x8514
 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X    0x8515
@@ -233,10 +232,6 @@ extern "C" {
 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z    0x851A
 #define GL_PROXY_TEXTURE_CUBE_MAP         0x851B
 #define GL_MAX_CUBE_MAP_TEXTURE_SIZE      0x851C
-#define GL_COMPRESSED_ALPHA               0x84E9
-#define GL_COMPRESSED_LUMINANCE           0x84EA
-#define GL_COMPRESSED_LUMINANCE_ALPHA     0x84EB
-#define GL_COMPRESSED_INTENSITY           0x84EC
 #define GL_COMPRESSED_RGB                 0x84ED
 #define GL_COMPRESSED_RGBA                0x84EE
 #define GL_TEXTURE_COMPRESSION_HINT       0x84EF
@@ -245,6 +240,22 @@ extern "C" {
 #define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
 #define GL_COMPRESSED_TEXTURE_FORMATS     0x86A3
 #define GL_CLAMP_TO_BORDER                0x812D
+#endif
+
+#ifndef GL_VERSION_1_3_DEPRECATED
+#define GL_CLIENT_ACTIVE_TEXTURE          0x84E1
+#define GL_MAX_TEXTURE_UNITS              0x84E2
+#define GL_TRANSPOSE_MODELVIEW_MATRIX     0x84E3
+#define GL_TRANSPOSE_PROJECTION_MATRIX    0x84E4
+#define GL_TRANSPOSE_TEXTURE_MATRIX       0x84E5
+#define GL_TRANSPOSE_COLOR_MATRIX         0x84E6
+#define GL_MULTISAMPLE_BIT                0x20000000
+#define GL_NORMAL_MAP                     0x8511
+#define GL_REFLECTION_MAP                 0x8512
+#define GL_COMPRESSED_ALPHA               0x84E9
+#define GL_COMPRESSED_LUMINANCE           0x84EA
+#define GL_COMPRESSED_LUMINANCE_ALPHA     0x84EB
+#define GL_COMPRESSED_INTENSITY           0x84EC
 #define GL_COMBINE                        0x8570
 #define GL_COMBINE_RGB                    0x8571
 #define GL_COMBINE_ALPHA                  0x8572
@@ -276,16 +287,26 @@ extern "C" {
 #define GL_BLEND_SRC_RGB                  0x80C9
 #define GL_BLEND_DST_ALPHA                0x80CA
 #define GL_BLEND_SRC_ALPHA                0x80CB
-#define GL_POINT_SIZE_MIN                 0x8126
-#define GL_POINT_SIZE_MAX                 0x8127
 #define GL_POINT_FADE_THRESHOLD_SIZE      0x8128
-#define GL_POINT_DISTANCE_ATTENUATION     0x8129
-#define GL_GENERATE_MIPMAP                0x8191
-#define GL_GENERATE_MIPMAP_HINT           0x8192
 #define GL_DEPTH_COMPONENT16              0x81A5
 #define GL_DEPTH_COMPONENT24              0x81A6
 #define GL_DEPTH_COMPONENT32              0x81A7
 #define GL_MIRRORED_REPEAT                0x8370
+#define GL_MAX_TEXTURE_LOD_BIAS           0x84FD
+#define GL_TEXTURE_LOD_BIAS               0x8501
+#define GL_INCR_WRAP                      0x8507
+#define GL_DECR_WRAP                      0x8508
+#define GL_TEXTURE_DEPTH_SIZE             0x884A
+#define GL_TEXTURE_COMPARE_MODE           0x884C
+#define GL_TEXTURE_COMPARE_FUNC           0x884D
+#endif
+
+#ifndef GL_VERSION_1_4_DEPRECATED
+#define GL_POINT_SIZE_MIN                 0x8126
+#define GL_POINT_SIZE_MAX                 0x8127
+#define GL_POINT_DISTANCE_ATTENUATION     0x8129
+#define GL_GENERATE_MIPMAP                0x8191
+#define GL_GENERATE_MIPMAP_HINT           0x8192
 #define GL_FOG_COORDINATE_SOURCE          0x8450
 #define GL_FOG_COORDINATE                 0x8451
 #define GL_FRAGMENT_DEPTH                 0x8452
@@ -301,15 +322,8 @@ extern "C" {
 #define GL_SECONDARY_COLOR_ARRAY_STRIDE   0x845C
 #define GL_SECONDARY_COLOR_ARRAY_POINTER  0x845D
 #define GL_SECONDARY_COLOR_ARRAY          0x845E
-#define GL_MAX_TEXTURE_LOD_BIAS           0x84FD
 #define GL_TEXTURE_FILTER_CONTROL         0x8500
-#define GL_TEXTURE_LOD_BIAS               0x8501
-#define GL_INCR_WRAP                      0x8507
-#define GL_DECR_WRAP                      0x8508
-#define GL_TEXTURE_DEPTH_SIZE             0x884A
 #define GL_DEPTH_TEXTURE_MODE             0x884B
-#define GL_TEXTURE_COMPARE_MODE           0x884C
-#define GL_TEXTURE_COMPARE_FUNC           0x884D
 #define GL_COMPARE_R_TO_TEXTURE           0x884E
 #endif
 
@@ -324,15 +338,6 @@ extern "C" {
 #define GL_ELEMENT_ARRAY_BUFFER           0x8893
 #define GL_ARRAY_BUFFER_BINDING           0x8894
 #define GL_ELEMENT_ARRAY_BUFFER_BINDING   0x8895
-#define GL_VERTEX_ARRAY_BUFFER_BINDING    0x8896
-#define GL_NORMAL_ARRAY_BUFFER_BINDING    0x8897
-#define GL_COLOR_ARRAY_BUFFER_BINDING     0x8898
-#define GL_INDEX_ARRAY_BUFFER_BINDING     0x8899
-#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A
-#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B
-#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C
-#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D
-#define GL_WEIGHT_ARRAY_BUFFER_BINDING    0x889E
 #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
 #define GL_READ_ONLY                      0x88B8
 #define GL_WRITE_ONLY                     0x88B9
@@ -350,31 +355,42 @@ extern "C" {
 #define GL_DYNAMIC_READ                   0x88E9
 #define GL_DYNAMIC_COPY                   0x88EA
 #define GL_SAMPLES_PASSED                 0x8914
-#define GL_FOG_COORD_SRC                  GL_FOG_COORDINATE_SOURCE
-#define GL_FOG_COORD                      GL_FOG_COORDINATE
-#define GL_CURRENT_FOG_COORD              GL_CURRENT_FOG_COORDINATE
-#define GL_FOG_COORD_ARRAY_TYPE           GL_FOG_COORDINATE_ARRAY_TYPE
-#define GL_FOG_COORD_ARRAY_STRIDE         GL_FOG_COORDINATE_ARRAY_STRIDE
-#define GL_FOG_COORD_ARRAY_POINTER        GL_FOG_COORDINATE_ARRAY_POINTER
-#define GL_FOG_COORD_ARRAY                GL_FOG_COORDINATE_ARRAY
-#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING
-#define GL_SRC0_RGB                       GL_SOURCE0_RGB
-#define GL_SRC1_RGB                       GL_SOURCE1_RGB
-#define GL_SRC2_RGB                       GL_SOURCE2_RGB
-#define GL_SRC0_ALPHA                     GL_SOURCE0_ALPHA
-#define GL_SRC1_ALPHA                     GL_SOURCE1_ALPHA
-#define GL_SRC2_ALPHA                     GL_SOURCE2_ALPHA
+#endif
+
+#ifndef GL_VERSION_1_5_DEPRECATED
+#define GL_VERTEX_ARRAY_BUFFER_BINDING    0x8896
+#define GL_NORMAL_ARRAY_BUFFER_BINDING    0x8897
+#define GL_COLOR_ARRAY_BUFFER_BINDING     0x8898
+#define GL_INDEX_ARRAY_BUFFER_BINDING     0x8899
+#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A
+#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B
+#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C
+#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D
+#define GL_WEIGHT_ARRAY_BUFFER_BINDING    0x889E
+#define GL_FOG_COORD_SRC                  0x8450
+#define GL_FOG_COORD                      0x8451
+#define GL_CURRENT_FOG_COORD              0x8453
+#define GL_FOG_COORD_ARRAY_TYPE           0x8454
+#define GL_FOG_COORD_ARRAY_STRIDE         0x8455
+#define GL_FOG_COORD_ARRAY_POINTER        0x8456
+#define GL_FOG_COORD_ARRAY                0x8457
+#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D
+#define GL_SRC0_RGB                       0x8580
+#define GL_SRC1_RGB                       0x8581
+#define GL_SRC2_RGB                       0x8582
+#define GL_SRC0_ALPHA                     0x8588
+#define GL_SRC1_ALPHA                     0x8589
+#define GL_SRC2_ALPHA                     0x858A
 #endif
 
 #ifndef GL_VERSION_2_0
-#define GL_BLEND_EQUATION_RGB             GL_BLEND_EQUATION
+#define GL_BLEND_EQUATION_RGB             0x8009
 #define GL_VERTEX_ATTRIB_ARRAY_ENABLED    0x8622
 #define GL_VERTEX_ATTRIB_ARRAY_SIZE       0x8623
 #define GL_VERTEX_ATTRIB_ARRAY_STRIDE     0x8624
 #define GL_VERTEX_ATTRIB_ARRAY_TYPE       0x8625
 #define GL_CURRENT_VERTEX_ATTRIB          0x8626
 #define GL_VERTEX_PROGRAM_POINT_SIZE      0x8642
-#define GL_VERTEX_PROGRAM_TWO_SIDE        0x8643
 #define GL_VERTEX_ATTRIB_ARRAY_POINTER    0x8645
 #define GL_STENCIL_BACK_FUNC              0x8800
 #define GL_STENCIL_BACK_FAIL              0x8801
@@ -398,11 +414,8 @@ extern "C" {
 #define GL_DRAW_BUFFER14                  0x8833
 #define GL_DRAW_BUFFER15                  0x8834
 #define GL_BLEND_EQUATION_ALPHA           0x883D
-#define GL_POINT_SPRITE                   0x8861
-#define GL_COORD_REPLACE                  0x8862
 #define GL_MAX_VERTEX_ATTRIBS             0x8869
 #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
-#define GL_MAX_TEXTURE_COORDS             0x8871
 #define GL_MAX_TEXTURE_IMAGE_UNITS        0x8872
 #define GL_FRAGMENT_SHADER                0x8B30
 #define GL_VERTEX_SHADER                  0x8B31
@@ -453,8 +466,14 @@ extern "C" {
 #define GL_STENCIL_BACK_WRITEMASK         0x8CA5
 #endif
 
+#ifndef GL_VERSION_2_0_DEPRECATED
+#define GL_VERTEX_PROGRAM_TWO_SIDE        0x8643
+#define GL_POINT_SPRITE                   0x8861
+#define GL_COORD_REPLACE                  0x8862
+#define GL_MAX_TEXTURE_COORDS             0x8871
+#endif
+
 #ifndef GL_VERSION_2_1
-#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F
 #define GL_PIXEL_PACK_BUFFER              0x88EB
 #define GL_PIXEL_UNPACK_BUFFER            0x88EC
 #define GL_PIXEL_PACK_BUFFER_BINDING      0x88ED
@@ -469,25 +488,29 @@ extern "C" {
 #define GL_SRGB8                          0x8C41
 #define GL_SRGB_ALPHA                     0x8C42
 #define GL_SRGB8_ALPHA8                   0x8C43
+#define GL_COMPRESSED_SRGB                0x8C48
+#define GL_COMPRESSED_SRGB_ALPHA          0x8C49
+#endif
+
+#ifndef GL_VERSION_2_1_DEPRECATED
+#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F
 #define GL_SLUMINANCE_ALPHA               0x8C44
 #define GL_SLUMINANCE8_ALPHA8             0x8C45
 #define GL_SLUMINANCE                     0x8C46
 #define GL_SLUMINANCE8                    0x8C47
-#define GL_COMPRESSED_SRGB                0x8C48
-#define GL_COMPRESSED_SRGB_ALPHA          0x8C49
 #define GL_COMPRESSED_SLUMINANCE          0x8C4A
 #define GL_COMPRESSED_SLUMINANCE_ALPHA    0x8C4B
 #endif
 
 #ifndef GL_VERSION_3_0
-#define GL_COMPARE_REF_TO_TEXTURE         GL_COMPARE_R_TO_TEXTURE_ARB
-#define GL_CLIP_DISTANCE0                 GL_CLIP_PLANE0
-#define GL_CLIP_DISTANCE1                 GL_CLIP_PLANE1
-#define GL_CLIP_DISTANCE2                 GL_CLIP_PLANE2
-#define GL_CLIP_DISTANCE3                 GL_CLIP_PLANE3
-#define GL_CLIP_DISTANCE4                 GL_CLIP_PLANE4
-#define GL_CLIP_DISTANCE5                 GL_CLIP_PLANE5
-#define GL_MAX_CLIP_DISTANCES             GL_MAX_CLIP_PLANES
+#define GL_COMPARE_REF_TO_TEXTURE         0x884E
+#define GL_CLIP_DISTANCE0                 0x3000
+#define GL_CLIP_DISTANCE1                 0x3001
+#define GL_CLIP_DISTANCE2                 0x3002
+#define GL_CLIP_DISTANCE3                 0x3003
+#define GL_CLIP_DISTANCE4                 0x3004
+#define GL_CLIP_DISTANCE5                 0x3005
+#define GL_MAX_CLIP_DISTANCES             0x0D32
 #define GL_MAJOR_VERSION                  0x821B
 #define GL_MINOR_VERSION                  0x821C
 #define GL_NUM_EXTENSIONS                 0x821D
@@ -505,19 +528,9 @@ extern "C" {
 #define GL_MAX_ARRAY_TEXTURE_LAYERS       0x88FF
 #define GL_MIN_PROGRAM_TEXEL_OFFSET       0x8904
 #define GL_MAX_PROGRAM_TEXEL_OFFSET       0x8905
-#define GL_CLAMP_VERTEX_COLOR             0x891A
-#define GL_CLAMP_FRAGMENT_COLOR           0x891B
 #define GL_CLAMP_READ_COLOR               0x891C
 #define GL_FIXED_ONLY                     0x891D
-#define GL_MAX_VARYING_COMPONENTS         GL_MAX_VARYING_FLOATS
-#define GL_TEXTURE_RED_TYPE               0x8C10
-#define GL_TEXTURE_GREEN_TYPE             0x8C11
-#define GL_TEXTURE_BLUE_TYPE              0x8C12
-#define GL_TEXTURE_ALPHA_TYPE             0x8C13
-#define GL_TEXTURE_LUMINANCE_TYPE         0x8C14
-#define GL_TEXTURE_INTENSITY_TYPE         0x8C15
-#define GL_TEXTURE_DEPTH_TYPE             0x8C16
-#define GL_UNSIGNED_NORMALIZED            0x8C17
+#define GL_MAX_VARYING_COMPONENTS         0x8B4B
 #define GL_TEXTURE_1D_ARRAY               0x8C18
 #define GL_PROXY_TEXTURE_1D_ARRAY         0x8C19
 #define GL_TEXTURE_2D_ARRAY               0x8C1A
@@ -559,7 +572,6 @@ extern "C" {
 #define GL_RED_INTEGER                    0x8D94
 #define GL_GREEN_INTEGER                  0x8D95
 #define GL_BLUE_INTEGER                   0x8D96
-#define GL_ALPHA_INTEGER                  0x8D97
 #define GL_RGB_INTEGER                    0x8D98
 #define GL_RGBA_INTEGER                   0x8D99
 #define GL_BGR_INTEGER                    0x8D9A
@@ -615,8 +627,6 @@ extern "C" {
 /* reuse GL_TEXTURE_GREEN_TYPE */
 /* reuse GL_TEXTURE_BLUE_TYPE */
 /* reuse GL_TEXTURE_ALPHA_TYPE */
-/* reuse GL_TEXTURE_LUMINANCE_TYPE */
-/* reuse GL_TEXTURE_INTENSITY_TYPE */
 /* reuse GL_TEXTURE_DEPTH_TYPE */
 /* reuse GL_UNSIGNED_NORMALIZED */
 /* reuse GL_FRAMEBUFFER_BINDING */
@@ -716,7 +726,32 @@ extern "C" {
 /* reuse GL_VERTEX_ARRAY_BINDING */
 #endif
 
+#ifndef GL_VERSION_3_0_DEPRECATED
+#define GL_CLAMP_VERTEX_COLOR             0x891A
+#define GL_CLAMP_FRAGMENT_COLOR           0x891B
+#define GL_ALPHA_INTEGER                  0x8D97
+/* Reuse tokens from ARB_framebuffer_object */
+/* reuse GL_TEXTURE_LUMINANCE_TYPE */
+/* reuse GL_TEXTURE_INTENSITY_TYPE */
+#endif
+
 #ifndef GL_VERSION_3_1
+#define GL_SAMPLER_2D_RECT                0x8B63
+#define GL_SAMPLER_2D_RECT_SHADOW         0x8B64
+#define GL_SAMPLER_BUFFER                 0x8DC2
+#define GL_INT_SAMPLER_2D_RECT            0x8DCD
+#define GL_INT_SAMPLER_BUFFER             0x8DD0
+#define GL_UNSIGNED_INT_SAMPLER_2D_RECT   0x8DD5
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER    0x8DD8
+#define GL_TEXTURE_BUFFER                 0x8C2A
+#define GL_MAX_TEXTURE_BUFFER_SIZE        0x8C2B
+#define GL_TEXTURE_BINDING_BUFFER         0x8C2C
+#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D
+#define GL_TEXTURE_BUFFER_FORMAT          0x8C2E
+#define GL_TEXTURE_RECTANGLE              0x84F5
+#define GL_TEXTURE_BINDING_RECTANGLE      0x84F6
+#define GL_PROXY_TEXTURE_RECTANGLE        0x84F7
+#define GL_MAX_RECTANGLE_TEXTURE_SIZE     0x84F8
 #define GL_RED_SNORM                      0x8F90
 #define GL_RG_SNORM                       0x8F91
 #define GL_RGB_SNORM                      0x8F92
@@ -732,6 +767,41 @@ extern "C" {
 #define GL_SIGNED_NORMALIZED              0x8F9C
 #define GL_PRIMITIVE_RESTART              0x8F9D
 #define GL_PRIMITIVE_RESTART_INDEX        0x8F9E
+/* Reuse tokens from ARB_copy_buffer */
+/* reuse GL_COPY_READ_BUFFER */
+/* reuse GL_COPY_WRITE_BUFFER */
+/* Would reuse tokens from ARB_draw_instanced, but it has none */
+/* Reuse tokens from ARB_uniform_buffer_object */
+/* reuse GL_UNIFORM_BUFFER */
+/* reuse GL_UNIFORM_BUFFER_BINDING */
+/* reuse GL_UNIFORM_BUFFER_START */
+/* reuse GL_UNIFORM_BUFFER_SIZE */
+/* reuse GL_MAX_VERTEX_UNIFORM_BLOCKS */
+/* reuse GL_MAX_FRAGMENT_UNIFORM_BLOCKS */
+/* reuse GL_MAX_COMBINED_UNIFORM_BLOCKS */
+/* reuse GL_MAX_UNIFORM_BUFFER_BINDINGS */
+/* reuse GL_MAX_UNIFORM_BLOCK_SIZE */
+/* reuse GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS */
+/* reuse GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS */
+/* reuse GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT */
+/* reuse GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH */
+/* reuse GL_ACTIVE_UNIFORM_BLOCKS */
+/* reuse GL_UNIFORM_TYPE */
+/* reuse GL_UNIFORM_SIZE */
+/* reuse GL_UNIFORM_NAME_LENGTH */
+/* reuse GL_UNIFORM_BLOCK_INDEX */
+/* reuse GL_UNIFORM_OFFSET */
+/* reuse GL_UNIFORM_ARRAY_STRIDE */
+/* reuse GL_UNIFORM_MATRIX_STRIDE */
+/* reuse GL_UNIFORM_IS_ROW_MAJOR */
+/* reuse GL_UNIFORM_BLOCK_BINDING */
+/* reuse GL_UNIFORM_BLOCK_DATA_SIZE */
+/* reuse GL_UNIFORM_BLOCK_NAME_LENGTH */
+/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS */
+/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES */
+/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER */
+/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER */
+/* reuse GL_INVALID_INDEX */
 #endif
 
 #ifndef GL_ARB_multitexture
@@ -1251,12 +1321,17 @@ extern "C" {
 #define GL_FRAMEBUFFER_DEFAULT            0x8218
 #define GL_FRAMEBUFFER_UNDEFINED          0x8219
 #define GL_DEPTH_STENCIL_ATTACHMENT       0x821A
-#define GL_INDEX                          0x8222
 #define GL_MAX_RENDERBUFFER_SIZE          0x84E8
 #define GL_DEPTH_STENCIL                  0x84F9
 #define GL_UNSIGNED_INT_24_8              0x84FA
 #define GL_DEPTH24_STENCIL8               0x88F0
 #define GL_TEXTURE_STENCIL_SIZE           0x88F1
+#define GL_TEXTURE_RED_TYPE               0x8C10
+#define GL_TEXTURE_GREEN_TYPE             0x8C11
+#define GL_TEXTURE_BLUE_TYPE              0x8C12
+#define GL_TEXTURE_ALPHA_TYPE             0x8C13
+#define GL_TEXTURE_DEPTH_TYPE             0x8C16
+#define GL_UNSIGNED_NORMALIZED            0x8C17
 #define GL_FRAMEBUFFER_BINDING            0x8CA6
 #define GL_DRAW_FRAMEBUFFER_BINDING       GL_FRAMEBUFFER_BINDING
 #define GL_RENDERBUFFER_BINDING           0x8CA7
@@ -1313,6 +1388,12 @@ extern "C" {
 #define GL_MAX_SAMPLES                    0x8D57
 #endif
 
+#ifndef GL_ARB_framebuffer_object_DEPRECATED
+#define GL_INDEX                          0x8222
+#define GL_TEXTURE_LUMINANCE_TYPE         0x8C14
+#define GL_TEXTURE_INTENSITY_TYPE         0x8C15
+#endif
+
 #ifndef GL_ARB_framebuffer_sRGB
 #define GL_FRAMEBUFFER_SRGB               0x8DB9
 #endif
@@ -1434,7 +1515,7 @@ extern "C" {
 #define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44
 #define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45
 #define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46
-#define GL_INVALID_INDEX_ARB              0xFFFFFFFFu
+#define GL_INVALID_INDEX                  0xFFFFFFFFu
 #endif
 
 #ifndef GL_ARB_compatibility
@@ -1446,6 +1527,9 @@ extern "C" {
 #define GL_COPY_WRITE_BUFFER              0x8F37
 #endif
 
+#ifndef GL_ARB_shader_texture_lod
+#endif
+
 #ifndef GL_EXT_abgr
 #define GL_ABGR_EXT                       0x8000
 #endif
@@ -3431,7 +3515,7 @@ extern "C" {
 #endif
 
 #ifndef GL_EXT_blend_equation_separate
-#define GL_BLEND_EQUATION_RGB_EXT         GL_BLEND_EQUATION
+#define GL_BLEND_EQUATION_RGB_EXT         0x8009
 #define GL_BLEND_EQUATION_ALPHA_EXT       0x883D
 #endif
 
@@ -3968,7 +4052,7 @@ extern "C" {
 #include <stddef.h>
 #ifndef GL_VERSION_2_0
 /* GL type for program/shader text */
-typedef char GLchar;                   /* native character */
+typedef char GLchar;
 #endif
 
 #ifndef GL_VERSION_1_5
@@ -3984,12 +4068,12 @@ typedef ptrdiff_t GLsizeiptrARB;
 #endif
 
 #ifndef GL_ARB_shader_objects
-/* GL types for handling shader object handles and program/shader text */
-typedef char GLcharARB;                /* native character */
-typedef unsigned int GLhandleARB;      /* shader object handle */
+/* GL types for program/shader text and shader object handles */
+typedef char GLcharARB;
+typedef unsigned int GLhandleARB;
 #endif
 
-/* GL types for "half" precision (s10e5) float data in host memory */
+/* GL type for "half" precision (s10e5) float data in host memory */
 #ifndef GL_ARB_half_float_pixel
 typedef unsigned short GLhalfARB;
 #endif
@@ -4031,7 +4115,8 @@ typedef __int32 int32_t;
 typedef __int64 int64_t;
 typedef unsigned __int64 uint64_t;
 #else
-#include <inttypes.h>     /* Fallback option */
+/* Fallback if nothing above works */
+#include <inttypes.h>
 #endif
 #endif
 
@@ -4046,6 +4131,21 @@ typedef uint64_t GLuint64EXT;
 GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf);
 GLAPI void APIENTRY glBlendEquation (GLenum);
 GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *);
+GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode);
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+#endif
+
+#ifndef GL_VERSION_1_2_DEPRECATED
+#define GL_VERSION_1_2_DEPRECATED 1
+#ifdef GL_GLEXT_PROTOTYPES
 GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
 GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *);
 GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *);
@@ -4078,13 +4178,7 @@ GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean);
 GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean);
 GLAPI void APIENTRY glResetHistogram (GLenum);
 GLAPI void APIENTRY glResetMinmax (GLenum);
-GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
-GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
-GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
 #endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
-typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode);
-typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
 typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
 typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
 typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
@@ -4117,15 +4211,35 @@ typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenu
 typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink);
 typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target);
 typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target);
-typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
 #endif
 
 #ifndef GL_VERSION_1_3
 #define GL_VERSION_1_3 1
 #ifdef GL_GLEXT_PROTOTYPES
 GLAPI void APIENTRY glActiveTexture (GLenum);
+GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean);
+GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img);
+#endif
+
+#ifndef GL_VERSION_1_3_DEPRECATED
+#define GL_VERSION_1_3_DEPRECATED 1
+#ifdef GL_GLEXT_PROTOTYPES
 GLAPI void APIENTRY glClientActiveTexture (GLenum);
 GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble);
 GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *);
@@ -4163,16 +4277,7 @@ GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *);
 GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *);
 GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *);
 GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *);
-GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean);
-GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *);
 #endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
 typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture);
 typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s);
 typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v);
@@ -4210,31 +4315,36 @@ typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m);
 typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m);
 typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m);
 typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m);
-typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img);
 #endif
 
 #ifndef GL_VERSION_1_4
 #define GL_VERSION_1_4 1
 #ifdef GL_GLEXT_PROTOTYPES
 GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum);
-GLAPI void APIENTRY glFogCoordf (GLfloat);
-GLAPI void APIENTRY glFogCoordfv (const GLfloat *);
-GLAPI void APIENTRY glFogCoordd (GLdouble);
-GLAPI void APIENTRY glFogCoorddv (const GLdouble *);
-GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *);
 GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei);
 GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);
 GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat);
 GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *);
 GLAPI void APIENTRY glPointParameteri (GLenum, GLint);
 GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params);
+#endif
+
+#ifndef GL_VERSION_1_4_DEPRECATED
+#define GL_VERSION_1_4_DEPRECATED 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFogCoordf (GLfloat);
+GLAPI void APIENTRY glFogCoordfv (const GLfloat *);
+GLAPI void APIENTRY glFogCoordd (GLdouble);
+GLAPI void APIENTRY glFogCoorddv (const GLdouble *);
+GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *);
 GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte);
 GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *);
 GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble);
@@ -4269,18 +4379,11 @@ GLAPI void APIENTRY glWindowPos3iv (const GLint *);
 GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort);
 GLAPI void APIENTRY glWindowPos3sv (const GLshort *);
 #endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
 typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord);
 typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord);
 typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord);
 typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord);
 typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
-typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params);
 typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue);
 typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v);
 typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue);
@@ -4592,26 +4695,6 @@ GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint, GLuint, GLsizei, GLsi
 GLAPI void APIENTRY glClampColor (GLenum, GLenum);
 GLAPI void APIENTRY glBeginConditionalRender (GLuint, GLenum);
 GLAPI void APIENTRY glEndConditionalRender (void);
-GLAPI void APIENTRY glVertexAttribI1i (GLuint, GLint);
-GLAPI void APIENTRY glVertexAttribI2i (GLuint, GLint, GLint);
-GLAPI void APIENTRY glVertexAttribI3i (GLuint, GLint, GLint, GLint);
-GLAPI void APIENTRY glVertexAttribI4i (GLuint, GLint, GLint, GLint, GLint);
-GLAPI void APIENTRY glVertexAttribI1ui (GLuint, GLuint);
-GLAPI void APIENTRY glVertexAttribI2ui (GLuint, GLuint, GLuint);
-GLAPI void APIENTRY glVertexAttribI3ui (GLuint, GLuint, GLuint, GLuint);
-GLAPI void APIENTRY glVertexAttribI4ui (GLuint, GLuint, GLuint, GLuint, GLuint);
-GLAPI void APIENTRY glVertexAttribI1iv (GLuint, const GLint *);
-GLAPI void APIENTRY glVertexAttribI2iv (GLuint, const GLint *);
-GLAPI void APIENTRY glVertexAttribI3iv (GLuint, const GLint *);
-GLAPI void APIENTRY glVertexAttribI4iv (GLuint, const GLint *);
-GLAPI void APIENTRY glVertexAttribI1uiv (GLuint, const GLuint *);
-GLAPI void APIENTRY glVertexAttribI2uiv (GLuint, const GLuint *);
-GLAPI void APIENTRY glVertexAttribI3uiv (GLuint, const GLuint *);
-GLAPI void APIENTRY glVertexAttribI4uiv (GLuint, const GLuint *);
-GLAPI void APIENTRY glVertexAttribI4bv (GLuint, const GLbyte *);
-GLAPI void APIENTRY glVertexAttribI4sv (GLuint, const GLshort *);
-GLAPI void APIENTRY glVertexAttribI4ubv (GLuint, const GLubyte *);
-GLAPI void APIENTRY glVertexAttribI4usv (GLuint, const GLushort *);
 GLAPI void APIENTRY glVertexAttribIPointer (GLuint, GLint, GLenum, GLsizei, const GLvoid *);
 GLAPI void APIENTRY glGetVertexAttribIiv (GLuint, GLenum, GLint *);
 GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint, GLenum, GLuint *);
@@ -4651,26 +4734,6 @@ typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, G
 typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp);
 typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode);
 typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v);
 typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
 typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params);
 typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params);
@@ -4696,6 +4759,69 @@ typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer
 typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index);
 #endif
 
+#ifndef GL_VERSION_3_0_DEPRECATED
+#define GL_VERSION_3_0_DEPRECATED 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttribI1i (GLuint, GLint);
+GLAPI void APIENTRY glVertexAttribI2i (GLuint, GLint, GLint);
+GLAPI void APIENTRY glVertexAttribI3i (GLuint, GLint, GLint, GLint);
+GLAPI void APIENTRY glVertexAttribI4i (GLuint, GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glVertexAttribI1ui (GLuint, GLuint);
+GLAPI void APIENTRY glVertexAttribI2ui (GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glVertexAttribI3ui (GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glVertexAttribI4ui (GLuint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glVertexAttribI1iv (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttribI2iv (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttribI3iv (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttribI4iv (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttribI1uiv (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttribI2uiv (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttribI3uiv (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttribI4uiv (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttribI4bv (GLuint, const GLbyte *);
+GLAPI void APIENTRY glVertexAttribI4sv (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttribI4ubv (GLuint, const GLubyte *);
+GLAPI void APIENTRY glVertexAttribI4usv (GLuint, const GLushort *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v);
+#endif
+
+#ifndef GL_VERSION_3_1
+#define GL_VERSION_3_1 1
+/* OpenGL 3.1 also reuses entry points from these extensions: */
+/* ARB_copy_buffer */
+/* ARB_uniform_buffer_object */
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawArraysInstanced (GLenum, GLint, GLsizei, GLsizei);
+GLAPI void APIENTRY glDrawElementsInstanced (GLenum, GLsizei, GLenum, const GLvoid *, GLsizei);
+GLAPI void APIENTRY glTexBuffer (GLenum, GLenum, GLuint);
+GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
+typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer);
+typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index);
+#endif
+
 #ifndef GL_ARB_multitexture
 #define GL_ARB_multitexture 1
 #ifdef GL_GLEXT_PROTOTYPES
@@ -5360,9 +5486,9 @@ typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLen
 #ifndef GL_ARB_instanced_arrays
 #define GL_ARB_instanced_arrays 1
 #ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertexAttribDivisor (GLuint, GLuint);
+GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint, GLuint);
 #endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor);
 #endif
 
 #ifndef GL_ARB_map_buffer_range
@@ -5437,6 +5563,10 @@ GLAPI void APIENTRY glCopyBufferSubData (GLenum, GLenum, GLintptr, GLintptr, GLs
 typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
 #endif
 
+#ifndef GL_ARB_shader_texture_lod
+#define GL_ARB_shader_texture_lod 1
+#endif
+
 #ifndef GL_EXT_abgr
 #define GL_EXT_abgr 1
 #endif
@@ -8150,7 +8280,6 @@ GLAPI void APIENTRY glGetVideoivNV (GLuint, GLenum, GLint *);
 GLAPI void APIENTRY glGetVideouivNV (GLuint, GLenum, GLuint *);
 GLAPI void APIENTRY glGetVideoi64vNV (GLuint, GLenum, GLint64EXT *);
 GLAPI void APIENTRY glGetVideoui64vNV (GLuint, GLenum, GLuint64EXT *);
-GLAPI void APIENTRY glVideoParameterivNV (GLuint, GLenum, const GLint *);
 #endif /* GL_GLEXT_PROTOTYPES */
 typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1);
 typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3);
@@ -8158,7 +8287,6 @@ typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname,
 typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params);
 typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params);
 typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params);
-typedef void (APIENTRYP PFNGLVIDEOPARAMETERIVNVPROC) (GLuint video_slot, GLenum pname, const GLint *params);
 #endif
 
 #ifndef GL_EXT_transform_feedback
index d54e0a4d509c6f4a63069c28f8904a7306a672b8..3c492dd6348c1c1301f00acb30513629cda4b5b9 100644 (file)
@@ -6,7 +6,7 @@ extern "C" {
 #endif
 
 /*
-** Copyright (c) 2007 The Khronos Group Inc.
+** Copyright (c) 2007-2009 The Khronos Group Inc.
 ** 
 ** Permission is hereby granted, free of charge, to any person obtaining a
 ** copy of this software and/or associated documentation files (the
@@ -28,6 +28,8 @@ extern "C" {
 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
 */
 
+/* Function declaration macros - to move into glplatform.h */
+
 #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
 #define WIN32_LEAN_AND_MEAN 1
 #include <windows.h>
@@ -709,6 +711,14 @@ typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWO
 #define WGL_NV_float_buffer 1
 #endif
 
+#ifndef WGL_3DL_stereo_control
+#define WGL_3DL_stereo_control 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglSetStereoEmitterState3DL (HDC, UINT);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState);
+#endif
+
 #ifndef WGL_EXT_pixel_format_packed_float
 #define WGL_EXT_pixel_format_packed_float 1
 #endif
index ce416712fe264e1274cdd755cdc4ef80a83de88b..206e06fc6c7141d255e3c06c07b7551985893e2c 100644 (file)
@@ -260,6 +260,8 @@ static void Key( unsigned char key, int x, int y )
    (void) y;
    switch (key) {
       case 27:
+         (*delete_vertex_arrays)( 1, & cube_array_obj );
+         (*delete_vertex_arrays)( 1, & oct_array_obj );
          glutDestroyWindow(Win);
          exit(0);
          break;
index bbf58af055d15061c22fc434eb381ecb514c35bf..1a1c63aaf48e3d134f8eb2222d1cf2638bdf648a 100644 (file)
@@ -51,6 +51,8 @@ static GLfloat Xrot = 0.0, Yrot = .0, Zrot = 0.0;
 static GLfloat EyeDist = 10;
 static GLboolean Anim = GL_TRUE;
 static GLboolean UseArrays = GL_TRUE;
+static GLboolean UseVBO = GL_TRUE;
+static GLuint VBO = 0;
 
 static GLint VertCoord_attr = -1, TexCoord0_attr = -1, TexCoord1_attr = -1;
 
@@ -76,28 +78,81 @@ static const GLfloat VertCoords[4][2] = {
 };
 
 
+
+static void
+SetupVertexBuffer(void)
+{
+   glGenBuffersARB_func(1, &VBO);
+   glBindBufferARB_func(GL_ARRAY_BUFFER_ARB, VBO);
+
+   glBufferDataARB_func(GL_ARRAY_BUFFER_ARB,
+                        sizeof(VertCoords) +
+                        sizeof(Tex0Coords) +
+                        sizeof(Tex1Coords),
+                        NULL,
+                        GL_STATIC_DRAW_ARB);
+
+   /* non-interleaved vertex arrays */
+
+   glBufferSubDataARB_func(GL_ARRAY_BUFFER_ARB,
+                           0,                   /* offset */
+                           sizeof(VertCoords),  /* size */
+                           VertCoords);         /* data */
+
+   glBufferSubDataARB_func(GL_ARRAY_BUFFER_ARB,
+                           sizeof(VertCoords),  /* offset */
+                           sizeof(Tex0Coords),  /* size */
+                           Tex0Coords);         /* data */
+
+   glBufferSubDataARB_func(GL_ARRAY_BUFFER_ARB,
+                           sizeof(VertCoords) +
+                           sizeof(Tex0Coords),  /* offset */
+                           sizeof(Tex1Coords),  /* size */
+                           Tex1Coords);         /* data */
+
+   glBindBufferARB_func(GL_ARRAY_BUFFER_ARB, 0);
+}
+
+
 static void
 DrawPolygonArray(void)
 {
+   void *vertPtr, *tex0Ptr, *tex1Ptr;
+
+   if (UseVBO) {
+      glBindBufferARB_func(GL_ARRAY_BUFFER_ARB, VBO);
+      vertPtr = (void *) 0;
+      tex0Ptr = (void *) sizeof(VertCoords);
+      tex1Ptr = (void *) (sizeof(VertCoords) + sizeof(Tex0Coords));
+   }
+   else {
+      glBindBufferARB_func(GL_ARRAY_BUFFER_ARB, 0);
+      vertPtr = VertCoords;
+      tex0Ptr = Tex0Coords;
+      tex1Ptr = Tex1Coords;
+   }
+
    if (VertCoord_attr >= 0) {
       glVertexAttribPointer_func(VertCoord_attr, 2, GL_FLOAT, GL_FALSE,
-                                 0, VertCoords);
+                                 0, vertPtr);
       glEnableVertexAttribArray_func(VertCoord_attr);
    }
    else {
-      glVertexPointer(2, GL_FLOAT, 0, VertCoords);
+      glVertexPointer(2, GL_FLOAT, 0, vertPtr);
       glEnable(GL_VERTEX_ARRAY);
    }
 
    glVertexAttribPointer_func(TexCoord0_attr, 2, GL_FLOAT, GL_FALSE,
-                              0, Tex0Coords);
+                              0, tex0Ptr);
    glEnableVertexAttribArray_func(TexCoord0_attr);
 
    glVertexAttribPointer_func(TexCoord1_attr, 2, GL_FLOAT, GL_FALSE,
-                              0, Tex1Coords);
+                              0, tex1Ptr);
    glEnableVertexAttribArray_func(TexCoord1_attr);
 
    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+
+      glBindBufferARB_func(GL_ARRAY_BUFFER_ARB, 0);
 }
 
 
@@ -163,6 +218,10 @@ key(unsigned char k, int x, int y)
       UseArrays = !UseArrays;
       printf("Arrays: %d\n", UseArrays);
       break;
+   case 'v':
+      UseVBO = !UseVBO;
+      printf("Use VBO: %d\n", UseVBO);
+      break;
    case ' ':
       Anim = !Anim;
       if (Anim)
@@ -314,12 +373,19 @@ InitGL(void)
       /*exit(1);*/
    }
    printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
-
+   printf("Usage:\n");
+   printf("  a     - toggle arrays vs. immediate mode rendering\n");
+   printf("  v     - toggle VBO usage for array rendering\n");
+   printf("  z/Z   - change viewing distance\n");
+   printf("  SPACE - toggle animation\n");
+   printf("  Esc   - exit\n");
    GetExtensionFuncs();
 
    InitTextures();
    InitPrograms();
 
+   SetupVertexBuffer();
+
    glEnable(GL_DEPTH_TEST);
 
    glClearColor(.6, .6, .9, 0);
diff --git a/progs/rbug/.gitignore b/progs/rbug/.gitignore
new file mode 100644 (file)
index 0000000..26a561c
--- /dev/null
@@ -0,0 +1,11 @@
+bin_to_bmp
+simple_client
+simple_server
+shdr_info
+shdr_dump
+shdr_disable
+ctx_info
+tex_dump
+tex_info
+*.bmp
+*.bin
diff --git a/progs/rbug/Makefile b/progs/rbug/Makefile
new file mode 100644 (file)
index 0000000..718f7a2
--- /dev/null
@@ -0,0 +1,47 @@
+# progs/rbug/Makefile
+
+TOP = ../..
+include $(TOP)/configs/current
+
+INCLUDES = \
+       -I. \
+       -I$(TOP)/src/gallium/include \
+       -I$(TOP)/src/gallium/auxiliary \
+       -I$(TOP)/src/gallium/drivers \
+       $(PROG_INCLUDES)
+
+LINKS = \
+       $(GALLIUM_AUXILIARIES) \
+       $(PROG_LINKS)
+
+SOURCES = \
+       bin_to_bmp.c \
+       simple_client.c \
+       simple_server.c \
+       shdr_info.c \
+       shdr_dump.c \
+       shdr_disable.c \
+       ctx_info.c \
+       tex_info.c \
+       tex_dump.c
+
+
+OBJECTS = $(SOURCES:.c=.o)
+
+PROGS = $(OBJECTS:.o=)
+
+##### TARGETS #####
+
+default: $(OBJECTS) $(PROGS)
+
+clean:
+       -rm -f $(PROGS)
+       -rm -f *.o
+
+##### RULES #####
+
+$(OBJECTS): %.o: %.c
+       $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $(PROG_DEFINES) $< -o $@
+
+$(PROGS): %: %.o
+       $(CC) $(LDFLAGS) $< $(LINKS) -o $@
diff --git a/progs/rbug/README b/progs/rbug/README
new file mode 100644 (file)
index 0000000..0eb0a5d
--- /dev/null
@@ -0,0 +1,39 @@
+                        REMOTE DEBUGGING CLI APPLICATIONS
+
+
+= About =
+
+This directory contains a Gallium3D remote debugging cli applications.
+
+
+= Build Instructions =
+
+To build, build a normal gallium build and from this directory do the following.
+
+ make
+
+= Usage =
+
+Make sure that you driver has trace integration, see
+src/gallium/driver/trace/README for more information about that. Then from on
+the computer that you want to debug do:
+
+ export GALLIUM_RBUG=true
+
+ <launch app>
+
+From the debugging computer launch apps form this directory. Currently ip
+addresses are hardcoded and you need to edit the application, but that will
+change in the future.
+
+= Testing =
+
+The two apps simple_client and simple_server. Are unit testing of the
+connection and (de)marsheler. Just run the server first and then the client:
+
+ ./simple_server &
+ ./simple_client
+
+
+--
+Jakob Bornecrantz <jakob@vmware.com>
diff --git a/progs/rbug/bin_to_bmp.c b/progs/rbug/bin_to_bmp.c
new file mode 100644 (file)
index 0000000..cdae348
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE 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 "pipe/p_compiler.h"
+#include "pipe/p_format.h"
+#include "pipe/p_state.h"
+#include "util/u_memory.h"
+#include "util/u_debug.h"
+#include "util/u_network.h"
+#include "util/u_tile.h"
+
+static uint8_t* read(const char *filename, unsigned size);
+static void dump(unsigned src_width, unsigned src_height,
+                 unsigned src_stride, enum pipe_format src_format,
+                 uint8_t *data, unsigned src_size);
+
+int main(int argc, char** argv)
+{
+   /* change these */
+   unsigned width = 64;
+   unsigned height = 64;
+   unsigned stride = width * 4;
+   unsigned size = stride * height;
+   const char *filename = "mybin.bin";
+   enum pipe_format format = PIPE_FORMAT_A8R8G8B8_UNORM;
+
+   dump(width, height, stride, format, read(filename, size), size);
+
+   return 0;
+}
+
+static void dump(unsigned width, unsigned height,
+                 unsigned src_stride, enum pipe_format src_format,
+                 uint8_t *data, unsigned src_size)
+{
+   struct pipe_format_block src_block;
+
+   enum pipe_format dst_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+   struct pipe_format_block dst_block;
+   unsigned dst_stride;
+   unsigned dst_size;
+   float *rgba;
+   int i;
+   char filename[512];
+
+   {
+      pf_get_block(src_format, &src_block);
+      assert(src_stride >= pf_get_stride(&src_block, width));
+      assert(src_size >= pf_get_2d_size(&src_block, src_stride, width));
+   }
+   {
+      pf_get_block(dst_format, &dst_block);
+      dst_stride = pf_get_stride(&dst_block, width);
+      dst_size = pf_get_2d_size(&dst_block, dst_stride, width);
+      rgba = MALLOC(dst_size);
+   }
+
+   util_snprintf(filename, 512, "%s.bmp", pf_name(src_format));
+
+   if (pf_is_compressed(src_format)) {
+      debug_printf("skipping: %s\n", filename);
+      return;
+   }
+
+   debug_printf("saving: %s\n", filename);
+
+   for (i = 0; i < height; i++) {
+      pipe_tile_raw_to_rgba(src_format, data + src_stride * i,
+                            width, 1,
+                            &rgba[width*4*i], dst_stride);
+   }
+
+   debug_dump_float_rgba_bmp(filename, width, height, rgba, width);
+
+   FREE(rgba);
+}
+
+static uint8_t* read(const char *filename, unsigned size)
+{
+   uint8_t *data;
+   FILE *file = fopen(filename, "rb");
+
+   data = MALLOC(size);
+
+   fread(data, 1, size, file);
+   fclose(file);
+
+   return data;
+}
diff --git a/progs/rbug/ctx_info.c b/progs/rbug/ctx_info.c
new file mode 100644 (file)
index 0000000..d72c326
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE 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 "pipe/p_compiler.h"
+#include "pipe/p_format.h"
+#include "util/u_memory.h"
+#include "util/u_debug.h"
+#include "util/u_network.h"
+
+#include "rbug/rbug.h"
+
+static void talk()
+{
+   int c = u_socket_connect("localhost", 13370);
+   struct rbug_connection *con = rbug_from_socket(c);
+   struct rbug_header *header;
+   struct rbug_proto_context_list_reply *list;
+   struct rbug_proto_context_info_reply *info;
+   int i;
+
+   assert(c >= 0);
+   assert(con);
+   debug_printf("Connection get!\n");
+
+   debug_printf("Sending get contexts\n");
+   rbug_send_context_list(con, NULL);
+
+   debug_printf("Waiting for contexts\n");
+   header = rbug_get_message(con, NULL);
+   assert(header->opcode == RBUG_OP_CONTEXT_LIST_REPLY);
+   list = (struct rbug_proto_context_list_reply *)header;
+
+   debug_printf("Got contexts:\n");
+   for (i = 0; i < list->contexts_len; i++) {
+#if 0
+      rbug_send_contexts_info(con, list->contexts[i], NULL);
+
+      header = rbug_get_message(con, NULL);
+      assert(header->opcode == RBUG_OP_CONTEXT_INFO_REPLY);
+      info = (struct rbug_proto_context_info_reply *)header;
+#else
+      (void)info;
+      header = NULL;
+#endif
+
+      debug_printf("%llu\n",
+                   (unsigned long long)list->contexts[i]);
+      rbug_free_header(header);
+   }
+
+   rbug_free_header(&list->header);
+   rbug_disconnect(con);
+}
+
+int main(int argc, char** argv)
+{
+   talk();
+   return 0;
+}
diff --git a/progs/rbug/shdr_disable.c b/progs/rbug/shdr_disable.c
new file mode 100644 (file)
index 0000000..e6b1207
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE 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 "pipe/p_compiler.h"
+#include "pipe/p_format.h"
+#include "util/u_memory.h"
+#include "util/u_debug.h"
+#include "util/u_network.h"
+
+#include "rbug/rbug.h"
+
+static void talk(rbug_context_t ctx, rbug_shader_t shdr)
+{
+   int c = u_socket_connect("localhost", 13370);
+   struct rbug_connection *con = rbug_from_socket(c);
+   struct rbug_header *header;
+
+   assert(c >= 0);
+   assert(con);
+   debug_printf("Connection get!\n");
+
+   rbug_send_shader_disable(con, ctx, shdr, true, NULL);
+
+   rbug_send_ping(con, NULL);
+
+   debug_printf("Sent waiting for reply\n");
+   header = rbug_get_message(con, NULL);
+
+   if (header->opcode != RBUG_OP_PING_REPLY)
+      debug_printf("Error\n");
+   else
+      debug_printf("Ok!\n");
+
+   rbug_free_header(header);
+   rbug_disconnect(con);
+}
+
+static void print_usage()
+{
+   printf("Usage shdr_disable <context> <shader>\n");
+   exit(-1);
+}
+
+int main(int argc, char** argv)
+{
+   long ctx;
+   long shdr;
+
+   if (argc < 3)
+      print_usage();
+
+   ctx = atol(argv[1]);
+   shdr = atol(argv[2]);
+
+   if (ctx <= 0 && ctx <= 0)
+      print_usage();
+
+   talk((uint64_t)ctx, (uint64_t)shdr);
+
+   return 0;
+}
diff --git a/progs/rbug/shdr_dump.c b/progs/rbug/shdr_dump.c
new file mode 100644 (file)
index 0000000..8f9d758
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE 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 "pipe/p_compiler.h"
+#include "pipe/p_format.h"
+#include "util/u_memory.h"
+#include "util/u_debug.h"
+#include "util/u_network.h"
+
+#include "rbug/rbug.h"
+
+#include "tgsi/tgsi_dump.h"
+
+static void shader_info(struct rbug_connection *con, rbug_context_t ctx)
+{
+   struct rbug_header *header;
+   struct rbug_proto_shader_list_reply *list;
+   struct rbug_proto_shader_info_reply *info;
+   int i;
+
+   debug_printf("Sending get shaders to %llu\n", (unsigned long long)ctx);
+   rbug_send_shader_list(con, ctx, NULL);
+
+   debug_printf("Waiting for shaders from %llu\n", (unsigned long long)ctx);
+   header = rbug_get_message(con, NULL);
+   assert(header->opcode == RBUG_OP_SHADER_LIST_REPLY);
+   list = (struct rbug_proto_shader_list_reply *)header;
+
+   debug_printf("Got shaders:\n");
+   for (i = 0; i < list->shaders_len; i++) {
+      rbug_send_shader_info(con, ctx, list->shaders[i], NULL);
+
+      header = rbug_get_message(con, NULL);
+      assert(header->opcode == RBUG_OP_SHADER_INFO_REPLY);
+      info = (struct rbug_proto_shader_info_reply *)header;
+
+      debug_printf("#####################################################\n");
+      debug_printf("ctx: %llu shdr: %llu disabled %u\n",
+                   (unsigned long long)ctx,
+                   (unsigned long long)list->shaders[i],
+                   info->disabled);
+
+      /* just to be sure */
+      assert(sizeof(struct tgsi_token) == 4);
+
+      debug_printf("-----------------------------------------------------\n");
+      tgsi_dump((struct tgsi_token *)info->original, 0);
+
+      if (info->replaced_len > 0) {
+         debug_printf("-----------------------------------------------------\n");
+         tgsi_dump((struct tgsi_token *)info->replaced, 0);
+      }
+
+      rbug_free_header(header);
+   }
+
+   debug_printf("#####################################################\n");
+   rbug_free_header(&list->header);
+}
+
+static void talk()
+{
+   int c = u_socket_connect("localhost", 13370);
+   struct rbug_connection *con = rbug_from_socket(c);
+   struct rbug_header *header;
+   struct rbug_proto_context_list_reply *list;
+   int i;
+
+   assert(c >= 0);
+   assert(con);
+   debug_printf("Connection get!\n");
+
+   debug_printf("Sending get contexts\n");
+   rbug_send_context_list(con, NULL);
+
+   debug_printf("Waiting for contexts\n");
+   header = rbug_get_message(con, NULL);
+   assert(header->opcode == RBUG_OP_CONTEXT_LIST_REPLY);
+   list = (struct rbug_proto_context_list_reply *)header;
+
+   debug_printf("Got contexts:\n");
+   for (i = 0; i < list->contexts_len; i++) {
+      shader_info(con, list->contexts[i]);
+   }
+
+   rbug_free_header(&list->header);
+   rbug_disconnect(con);
+}
+
+int main(int argc, char** argv)
+{
+   talk();
+   return 0;
+}
diff --git a/progs/rbug/shdr_info.c b/progs/rbug/shdr_info.c
new file mode 100644 (file)
index 0000000..b6864e9
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE 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 "pipe/p_compiler.h"
+#include "pipe/p_format.h"
+#include "util/u_memory.h"
+#include "util/u_debug.h"
+#include "util/u_network.h"
+
+#include "rbug/rbug.h"
+
+static void shader_info(struct rbug_connection *con, rbug_context_t ctx)
+{
+   struct rbug_header *header;
+   struct rbug_proto_shader_list_reply *list;
+   struct rbug_proto_shader_info_reply *info;
+   int i;
+
+   rbug_send_shader_list(con, ctx, NULL);
+
+   header = rbug_get_message(con, NULL);
+   assert(header->opcode == RBUG_OP_SHADER_LIST_REPLY);
+   list = (struct rbug_proto_shader_list_reply *)header;
+
+   debug_printf("        context |         shader |       disabled |\n");
+   for (i = 0; i < list->shaders_len; i++) {
+      rbug_send_shader_info(con, ctx, list->shaders[i], NULL);
+
+      header = rbug_get_message(con, NULL);
+      assert(header->opcode == RBUG_OP_SHADER_INFO_REPLY);
+      info = (struct rbug_proto_shader_info_reply *)header;
+
+      debug_printf("% 15llu |% 15llu |% 15u |\n",
+                   (unsigned long long)ctx,
+                   (unsigned long long)list->shaders[i],
+                   (unsigned)info->disabled);
+
+      rbug_free_header(header);
+   }
+
+   rbug_free_header(&list->header);
+}
+
+static void talk()
+{
+   int c = u_socket_connect("localhost", 13370);
+   struct rbug_connection *con = rbug_from_socket(c);
+   struct rbug_header *header;
+   struct rbug_proto_context_list_reply *list;
+   int i;
+
+   assert(c >= 0);
+   assert(con);
+   debug_printf("Connection get!\n");
+
+   debug_printf("Sending get contexts\n");
+   rbug_send_context_list(con, NULL);
+
+   debug_printf("Waiting for contexts\n");
+   header = rbug_get_message(con, NULL);
+   assert(header->opcode == RBUG_OP_CONTEXT_LIST_REPLY);
+   list = (struct rbug_proto_context_list_reply *)header;
+
+   debug_printf("Got contexts:\n");
+   for (i = 0; i < list->contexts_len; i++) {
+      shader_info(con, list->contexts[i]);
+   }
+
+   rbug_free_header(&list->header);
+   rbug_disconnect(con);
+}
+
+int main(int argc, char** argv)
+{
+   talk();
+   return 0;
+}
diff --git a/progs/rbug/simple_client.c b/progs/rbug/simple_client.c
new file mode 100644 (file)
index 0000000..38929fa
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE 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 "pipe/p_compiler.h"
+#include "util/u_memory.h"
+#include "util/u_debug.h"
+#include "util/u_network.h"
+
+#include "rbug/rbug.h"
+
+static void talk()
+{
+   int c = u_socket_connect("localhost", 13370);
+   struct rbug_connection *con = rbug_from_socket(c);
+   struct rbug_header *header;
+   struct rbug_proto_texture_list_reply *list;
+   int i;
+
+   assert(c >= 0);
+   assert(con);
+   debug_printf("Connection get!\n");
+
+   debug_printf("Sending get textures\n");
+   rbug_send_texture_list(con, NULL);
+
+   debug_printf("Waiting for textures\n");
+   header = rbug_get_message(con, NULL);
+   assert(header->opcode == RBUG_OP_TEXTURE_LIST_REPLY);
+   list = (struct rbug_proto_texture_list_reply *)header;
+
+   debug_printf("Got textures:\n");
+   for (i = 0; i < list->textures_len; i++)
+      debug_printf("\ttex %llu\n", (unsigned long long)list->textures[i]);
+
+   rbug_free_header(header);
+   rbug_disconnect(con);
+}
+
+int main(int argc, char** argv)
+{
+   talk();
+   return 0;
+}
diff --git a/progs/rbug/simple_server.c b/progs/rbug/simple_server.c
new file mode 100644 (file)
index 0000000..04380c3
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE 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 "pipe/p_compiler.h"
+#include "util/u_memory.h"
+#include "util/u_debug.h"
+#include "util/u_network.h"
+
+#include "rbug/rbug.h"
+
+static void wait()
+{
+   int s = u_socket_listen_on_port(13370);
+   int c = u_socket_accept(s);
+   struct rbug_connection *con = rbug_from_socket(c);
+   struct rbug_header *header;
+   rbug_texture_t texs[2];
+   uint32_t serial;
+   texs[0] = 1337;
+   texs[1] = 7331;
+
+   assert(s >= 0);
+   assert(c >= 0);
+   assert(con);
+   debug_printf("Connection get!\n");
+
+   debug_printf("Waiting for get textures\n");
+   header = rbug_get_message(con, &serial);
+   assert(header);
+   assert(header->opcode == RBUG_OP_TEXTURE_LIST);
+   rbug_free_header(header);
+
+   rbug_send_texture_list_reply(con, serial, texs, 2, NULL);
+   rbug_disconnect(con);
+}
+
+int main(int argc, char** argv)
+{
+   wait();
+   return 0;
+}
diff --git a/progs/rbug/tex_dump.c b/progs/rbug/tex_dump.c
new file mode 100644 (file)
index 0000000..f9e06ee
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE 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 "pipe/p_compiler.h"
+#include "pipe/p_format.h"
+#include "pipe/p_state.h"
+#include "util/u_memory.h"
+#include "util/u_debug.h"
+#include "util/u_network.h"
+#include "util/u_tile.h"
+#include "rbug/rbug.h"
+
+static void dump(rbug_texture_t tex,
+                 struct rbug_proto_texture_info_reply *info,
+                 struct rbug_proto_texture_read_reply *read,
+                 int mip)
+{
+   enum pipe_format format = info->format;
+   uint8_t *data = read->data;
+   unsigned width = info->width[mip];
+   unsigned height = info->height[mip];
+   unsigned dst_stride = width * 4 * 4;
+   unsigned src_stride = read->stride;
+   float *rgba = MALLOC(dst_stride * height);
+   int i;
+   char filename[512];
+
+   util_snprintf(filename, 512, "%llu_%s_%u.bmp",
+                 (unsigned long long)tex, pf_name(info->format), mip);
+
+   if (pf_is_compressed(info->format)) {
+      debug_printf("skipping: %s\n", filename);
+      return;
+   }
+
+   debug_printf("saving: %s\n", filename);
+
+   for (i = 0; i < height; i++) {
+      pipe_tile_raw_to_rgba(format, data + src_stride * i,
+                            width, 1,
+                            &rgba[width*4*i], dst_stride);
+   }
+
+   debug_dump_float_rgba_bmp(filename, width, height, rgba, width);
+
+   FREE(rgba);
+}
+
+static void talk()
+{
+   int c = u_socket_connect("localhost", 13370);
+   struct rbug_connection *con = rbug_from_socket(c);
+   struct rbug_header *header;
+   struct rbug_header *header2;
+   struct rbug_proto_texture_list_reply *list;
+   struct rbug_proto_texture_info_reply *info;
+   struct rbug_proto_texture_read_reply *read;
+   int i, j;
+
+   assert(c >= 0);
+   assert(con);
+   debug_printf("Connection get!\n");
+
+   debug_printf("Sending get textures\n");
+   rbug_send_texture_list(con, NULL);
+
+   debug_printf("Waiting for textures\n");
+   header = rbug_get_message(con, NULL);
+   assert(header->opcode == RBUG_OP_TEXTURE_LIST_REPLY);
+   list = (struct rbug_proto_texture_list_reply *)header;
+
+   debug_printf("Got textures:\n");
+   for (i = 0; i < list->textures_len; i++) {
+      rbug_send_texture_info(con, list->textures[i], NULL);
+
+      header = rbug_get_message(con, NULL);
+      assert(header->opcode == RBUG_OP_TEXTURE_INFO_REPLY);
+      info = (struct rbug_proto_texture_info_reply *)header;
+
+      for (j = 0; j <= info->last_level; j++) {
+         rbug_send_texture_read(con, list->textures[i],
+                                0, j, 0,
+                                0, 0, info->width[j], info->height[j],
+                                NULL);
+
+         header2 = rbug_get_message(con, NULL);
+         assert(header2->opcode == RBUG_OP_TEXTURE_READ_REPLY);
+         read = (struct rbug_proto_texture_read_reply *)header2;
+
+         dump(list->textures[i], info, read, j);
+
+         rbug_free_header(header2);
+      }
+
+      rbug_free_header(header);
+
+   }
+   rbug_free_header(&list->header);
+   rbug_disconnect(con);
+}
+
+int main(int argc, char** argv)
+{
+   talk();
+   return 0;
+}
diff --git a/progs/rbug/tex_info.c b/progs/rbug/tex_info.c
new file mode 100644 (file)
index 0000000..4a21bae
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE 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 "pipe/p_compiler.h"
+#include "pipe/p_format.h"
+#include "util/u_memory.h"
+#include "util/u_debug.h"
+#include "util/u_network.h"
+
+#include "rbug/rbug.h"
+
+static void talk()
+{
+   int c = u_socket_connect("localhost", 13370);
+   struct rbug_connection *con = rbug_from_socket(c);
+   struct rbug_header *header;
+   struct rbug_proto_texture_list_reply *list;
+   struct rbug_proto_texture_info_reply *info;
+   int i;
+
+   assert(c >= 0);
+   assert(con);
+   debug_printf("Connection get!\n");
+
+   debug_printf("Sending get textures\n");
+   rbug_send_texture_list(con, NULL);
+
+   debug_printf("Waiting for textures\n");
+   header = rbug_get_message(con, NULL);
+   assert(header->opcode == RBUG_OP_TEXTURE_LIST_REPLY);
+   list = (struct rbug_proto_texture_list_reply *)header;
+
+   debug_printf("Got textures:\n");
+   for (i = 0; i < list->textures_len; i++) {
+      rbug_send_texture_info(con, list->textures[i], NULL);
+
+      header = rbug_get_message(con, NULL);
+      assert(header->opcode == RBUG_OP_TEXTURE_INFO_REPLY);
+      info = (struct rbug_proto_texture_info_reply *)header;
+
+      debug_printf("%llu %s %u x %u x %u, block(%ux%u %u), last_level: %u, nr_samples: %u, usage: %u\n",
+                   (unsigned long long)list->textures[i], pf_name(info->format),
+                   info->width[0], info->height[0], info->depth[0],
+                   info->blockw, info->blockh, info->blocksize,
+                   info->last_level, info->nr_samples, info->tex_usage);
+      rbug_free_header(header);
+   }
+
+   rbug_free_header(&list->header);
+   rbug_disconnect(con);
+}
+
+int main(int argc, char** argv)
+{
+   talk();
+   return 0;
+}
index f47c60faefd160bc6ebbfc275479a8d86e6f4c91..c04750725fb6ed588b4efe76cab7a8f3b7a59468 100644 (file)
@@ -466,25 +466,22 @@ static void Draw(void)
     } else {
        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
     }
-#if 01
+
     Viewport(0, 0); Point();
     Viewport(0, 1); Lines();
     Viewport(0, 2); LineStrip();
     Viewport(0, 3); LineLoop();
 
     Viewport(1, 0); Bitmap();
-
     Viewport(1, 1); TriangleFan();
     Viewport(1, 2); Triangles();
     Viewport(1, 3); TriangleStrip();
 
     Viewport(2, 0); Rect();
-#endif
     Viewport(2, 1); PolygonFunc();
-#if 01
     Viewport(2, 2); Quads();
     Viewport(2, 3); QuadStrip();
-#endif
+
     glFlush();
 
     if (doubleBuffer) {
index 7604b227887934f0f7914326fb847713d7bde864..23fe3c35c1ff96a235e1512b4a2a580ffb338fbe 100644 (file)
@@ -17,6 +17,7 @@ SOURCES = \
        arbfptest1.c \
        arbfptexture.c \
        arbfptrig.c \
+       arbgpuprog.c \
        arbnpot.c \
        arbnpot-mipmap.c \
        arbvptest1.c \
@@ -48,7 +49,8 @@ SOURCES = \
        fptest1.c \
        fptexture.c \
        getprocaddress.c \
-       glutfx \
+       getteximage.c \
+       glutfx.c \
        interleave.c \
        invert.c \
        jkrahntest.c \
@@ -65,6 +67,7 @@ SOURCES = \
        no_s3tc.c \
        packedpixels.c \
        pbo.c \
+       persp_hint.c \
        prog_parameter.c \
        quads.c \
        random.c \
index 9d89ff6a0d019cf3f6fe8846b042986db589135a..9e3a646f806a4fcc539d0804d55f44ea1db30d58 100644 (file)
@@ -90,6 +90,7 @@ progs = [
     'no_s3tc',
     'packedpixels',
     'pbo',
+    'persp_hint',
     'prog_parameter',
     'quads',
     'random',
diff --git a/progs/tests/arbgpuprog.c b/progs/tests/arbgpuprog.c
new file mode 100644 (file)
index 0000000..23aa899
--- /dev/null
@@ -0,0 +1,230 @@
+/**
+ * Just compile ARB vert/frag program from named file(s).
+ */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+
+static GLuint FragProg;
+static GLuint VertProg;
+static GLint Win;
+
+static PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glProgramLocalParameter4fvARB_func;
+static PFNGLPROGRAMLOCALPARAMETER4DARBPROC glProgramLocalParameter4dARB_func;
+static PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC glGetProgramLocalParameterdvARB_func;
+static PFNGLGENPROGRAMSARBPROC glGenProgramsARB_func;
+static PFNGLPROGRAMSTRINGARBPROC glProgramStringARB_func;
+static PFNGLBINDPROGRAMARBPROC glBindProgramARB_func;
+static PFNGLISPROGRAMARBPROC glIsProgramARB_func;
+static PFNGLDELETEPROGRAMSARBPROC glDeleteProgramsARB_func;
+
+
+static void Redisplay( void )
+{
+   glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+   glutSwapBuffers();
+   exit(0);
+}
+
+
+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 )
+{
+   (void) x;
+   (void) y;
+   switch (key) {
+      case 27:
+         glDeleteProgramsARB_func(1, &VertProg);
+         glDeleteProgramsARB_func(1, &FragProg);
+         glutDestroyWindow(Win);
+         exit(0);
+         break;
+   }
+   glutPostRedisplay();
+}
+
+
+/* A helper for finding errors in program strings */
+static int FindLine( const char *program, int position )
+{
+   int i, line = 1;
+   for (i = 0; i < position; i++) {
+      if (program[i] == '\n')
+         line++;
+   }
+   return line;
+}
+
+
+static void Init( const char *vertProgFile,
+                  const char *fragProgFile )
+{
+   GLint errorPos;
+   char buf[10*1000];
+
+   if (!glutExtensionSupported("GL_ARB_vertex_program")) {
+      printf("Sorry, this demo requires GL_ARB_vertex_program\n");
+      exit(1);
+   }
+   if (!glutExtensionSupported("GL_ARB_fragment_program")) {
+      printf("Sorry, this demo requires GL_ARB_fragment_program\n");
+      exit(1);
+   }
+         
+   printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+
+   /*
+    * Get extension function pointers.
+    */
+   glProgramLocalParameter4fvARB_func = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) glutGetProcAddress("glProgramLocalParameter4fvARB");
+   assert(glProgramLocalParameter4fvARB_func);
+
+   glProgramLocalParameter4dARB_func = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC) glutGetProcAddress("glProgramLocalParameter4dARB");
+   assert(glProgramLocalParameter4dARB_func);
+
+   glGetProgramLocalParameterdvARB_func = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) glutGetProcAddress("glGetProgramLocalParameterdvARB");
+   assert(glGetProgramLocalParameterdvARB_func);
+
+   glGenProgramsARB_func = (PFNGLGENPROGRAMSARBPROC) glutGetProcAddress("glGenProgramsARB");
+   assert(glGenProgramsARB_func);
+
+   glProgramStringARB_func = (PFNGLPROGRAMSTRINGARBPROC) glutGetProcAddress("glProgramStringARB");
+   assert(glProgramStringARB_func);
+
+   glBindProgramARB_func = (PFNGLBINDPROGRAMARBPROC) glutGetProcAddress("glBindProgramARB");
+   assert(glBindProgramARB_func);
+
+   glIsProgramARB_func = (PFNGLISPROGRAMARBPROC) glutGetProcAddress("glIsProgramARB");
+   assert(glIsProgramARB_func);
+
+   glDeleteProgramsARB_func = (PFNGLDELETEPROGRAMSARBPROC) glutGetProcAddress("glDeleteProgramsARB");
+   assert(glDeleteProgramsARB_func);
+
+   /*
+    * Vertex program
+    */
+   if (vertProgFile) {
+      FILE *f;
+      int len;
+
+      glGenProgramsARB_func(1, &VertProg);
+      assert(VertProg > 0);
+      glBindProgramARB_func(GL_VERTEX_PROGRAM_ARB, VertProg);
+
+      f = fopen(vertProgFile, "r");
+      if (!f) {
+         printf("Unable to open %s\n", fragProgFile);
+         exit(1);
+      }
+
+      len = fread(buf, 1, 10*1000,f);
+      glProgramStringARB_func(GL_VERTEX_PROGRAM_ARB,
+                              GL_PROGRAM_FORMAT_ASCII_ARB,
+                              len,
+                              (const GLubyte *) buf);
+
+      glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
+      if (glGetError() != GL_NO_ERROR || errorPos != -1) {
+         int l = FindLine(buf, errorPos);
+         printf("Vertex Program Error (pos=%d line=%d): %s\n", errorPos, l,
+                (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+         exit(0);
+      }
+      else {
+         glEnable(GL_VERTEX_PROGRAM_ARB);
+         printf("Vertex Program OK\n");
+      }
+   }
+
+   /*
+    * Fragment program
+    */
+   if (fragProgFile) {
+      FILE *f;
+      int len;
+
+      glGenProgramsARB_func(1, &FragProg);
+      assert(FragProg > 0);
+      glBindProgramARB_func(GL_FRAGMENT_PROGRAM_ARB, FragProg);
+
+      f = fopen(fragProgFile, "r");
+      if (!f) {
+         printf("Unable to open %s\n", fragProgFile);
+         exit(1);
+      }
+
+      len = fread(buf, 1, 10*1000,f);
+      glProgramStringARB_func(GL_FRAGMENT_PROGRAM_ARB,
+                              GL_PROGRAM_FORMAT_ASCII_ARB,
+                              len,
+                              (const GLubyte *) buf);
+
+      glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
+      if (glGetError() != GL_NO_ERROR || errorPos != -1) {
+         int l = FindLine(buf, errorPos);
+         printf("Fragment Program Error (pos=%d line=%d): %s\n", errorPos, l,
+                (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+         exit(0);
+      }
+      else {
+         glEnable(GL_FRAGMENT_PROGRAM_ARB);
+         printf("Fragment Program OK\n");
+      }
+   }
+}
+
+
+int main( int argc, char *argv[] )
+{
+   const char *vertProgFile = NULL, *fragProgFile = NULL;
+   int i;
+
+   glutInit( &argc, argv );
+   glutInitWindowPosition( 0, 0 );
+   glutInitWindowSize( 200, 200 );
+   glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+   Win = glutCreateWindow(argv[0]);
+   glutReshapeFunc( Reshape );
+   glutKeyboardFunc( Key );
+   glutDisplayFunc( Redisplay );
+
+   if (argc == 1) {
+      printf("arbgpuprog:\n");
+      printf("  Compile GL_ARB_vertex/fragment_programs, report any errors.\n");
+      printf("Usage:\n");
+      printf("  arbgpuprog [--vp vertprogfile] [--fp fragprogfile]\n");
+      exit(1);
+   }
+
+   for (i = 1; i < argc; i++) {
+      if (strcmp(argv[i], "--vp") == 0) {
+         vertProgFile = argv[i+1];
+         i++;
+      }
+      else if (strcmp(argv[i], "--fp") == 0) {
+         fragProgFile = argv[i+1];
+         i++;
+      }
+   }
+
+   Init(vertProgFile, fragProgFile);
+
+   glutMainLoop();
+   return 0;
+}
diff --git a/progs/tests/getteximage.c b/progs/tests/getteximage.c
new file mode 100644 (file)
index 0000000..e4818a8
--- /dev/null
@@ -0,0 +1,217 @@
+/**
+ * Test glGetTexImage()
+ * Brian Paul
+ * 9 June 2009
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glew.h>
+#include <GL/glut.h>
+
+static int Win;
+
+
+static void
+TestGetTexImage(void)
+{
+   GLuint iter;
+   GLubyte *data = (GLubyte *) malloc(1024 * 1024 * 4);
+   GLubyte *data2 = (GLubyte *) malloc(1024 * 1024 * 4);
+
+   glEnable(GL_TEXTURE_2D);
+
+   printf("glTexImage2D + glGetTexImage:\n");
+
+   for (iter = 0; iter < 8; iter++) {
+      GLint p = (iter % 8) + 3;
+      GLint w = (1 << p);
+      GLint h = (1 << p);
+      GLuint i;
+      GLint level = 0;
+
+      printf("  Testing %d x %d tex image\n", w, h);
+
+      /* fill data */
+      for (i = 0; i < w * h * 4; i++) {
+         data[i] = i & 0xff;
+         data2[i] = 0;
+      }
+
+      glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, w, h, 0,
+                   GL_RGBA, GL_UNSIGNED_BYTE, data);
+
+      glBegin(GL_POINTS);
+      glVertex2f(0, 0);
+      glEnd();
+
+      /* get */
+      glGetTexImage(GL_TEXTURE_2D, level, GL_RGBA, GL_UNSIGNED_BYTE, data2);
+
+      /* compare */
+      for (i = 0; i < w * h * 4; i++) {
+         if (data2[i] != data[i]) {
+            printf("glTexImage + glGetTexImage failure!\n");
+            printf("Expected value %d, found %d\n", data[i], data2[i]);
+            abort();
+         }
+      }
+   }
+
+   printf("Passed\n");
+   glDisable(GL_TEXTURE_2D);
+   free(data);
+   free(data2);
+}
+
+
+static GLboolean
+ColorsEqual(const GLubyte ref[4], const GLubyte act[4])
+{
+   if (abs((int) ref[0] - (int) act[0]) > 1 ||
+       abs((int) ref[1] - (int) act[1]) > 1 ||
+       abs((int) ref[2] - (int) act[2]) > 1 ||
+       abs((int) ref[3] - (int) act[3]) > 1) {
+      printf("expected %d %d %d %d\n", ref[0], ref[1], ref[2], ref[3]);
+      printf("found    %d %d %d %d\n", act[0], act[1], act[2], act[3]);
+      return GL_FALSE;
+   }
+   return GL_TRUE;
+}
+
+
+static void
+TestGetTexImageRTT(void)
+{
+   GLuint iter;
+   GLuint fb, tex;
+   GLint w = 512;
+   GLint h = 256;
+   GLint level = 0;
+   
+   glGenTextures(1, &tex);
+   glGenFramebuffersEXT(1, &fb);
+
+   glBindTexture(GL_TEXTURE_2D, tex);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0,
+                GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+
+   glBindFramebuffer(GL_FRAMEBUFFER_EXT, fb);
+   glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+                             GL_TEXTURE_2D, tex, level);
+
+   printf("Render to texture + glGetTexImage:\n");
+   printf("  Testing %d x %d tex image\n", w, h);
+   for (iter = 0; iter < 8; iter++) {
+      GLubyte color[4];
+      GLubyte *data2 = (GLubyte *) malloc(w * h * 4);
+      GLuint i;
+
+      /* random clear color */
+      for (i = 0; i < 4; i++) {
+         color[i] = rand() % 256;
+      }
+
+      glClearColor(color[0] / 255.0,
+                   color[1] / 255.0,
+                   color[2] / 255.0,
+                   color[3] / 255.0);
+
+      glClear(GL_COLOR_BUFFER_BIT);
+
+      /* get */
+      glGetTexImage(GL_TEXTURE_2D, level, GL_RGBA, GL_UNSIGNED_BYTE, data2);
+
+      /* compare */
+      for (i = 0; i < w * h; i += 4) {
+         if (!ColorsEqual(color, data2 + i * 4)) {
+            printf("Render to texture failure!\n");
+            abort();
+         }
+      }
+
+      free(data2);
+   }
+
+   glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
+   glDeleteFramebuffersEXT(1, &fb);
+   glDeleteTextures(1, &tex);
+
+   printf("Passed\n");
+}
+
+
+
+
+static void
+Draw(void)
+{
+   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+   TestGetTexImage();
+
+   if (glutExtensionSupported("GL_EXT_framebuffer_object") ||
+       glutExtensionSupported("GL_ARB_framebuffer_object"))
+      TestGetTexImageRTT();
+
+   glutDestroyWindow(Win);
+   exit(0);
+
+   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)
+{
+   (void) x;
+   (void) y;
+   switch (key) {
+      case 27:
+         glutDestroyWindow(Win);
+         exit(0);
+         break;
+   }
+   glutPostRedisplay();
+}
+
+
+static void
+Init(void)
+{
+}
+
+
+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]);
+   glewInit();
+   glutReshapeFunc(Reshape);
+   glutKeyboardFunc(Key);
+   glutDisplayFunc(Draw);
+   Init();
+   glutMainLoop();
+   return 0;
+}
diff --git a/progs/tests/persp_hint.c b/progs/tests/persp_hint.c
new file mode 100644 (file)
index 0000000..27140d1
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * Test the GL_PERSPECTIVE_CORRECTION_HINT setting and its effect on
+ * color interpolation.
+ *
+ * Press 'i' to toggle between GL_NICEST/GL_FASTEST/GL_DONT_CARE.
+ *
+ * Depending on the driver, the hint may make a difference, or not.
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <GL/glut.h>
+
+
+static GLenum PerspHint = GL_DONT_CARE;
+
+
+static void
+init(void)
+{
+   GLubyte image[256][256][4];
+   GLuint i, j;
+   for (i = 0; i < 256; i++) {
+      for (j = 0; j < 256; j++) {
+         image[i][j][0] = j;
+         image[i][j][1] = j;
+         image[i][j][2] = j;
+         image[i][j][3] = 255;
+      }
+   }
+   glTexImage2D(GL_TEXTURE_2D, 0, 4, 256, 256, 0,
+                GL_RGBA, GL_UNSIGNED_BYTE, image);
+   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_MAG_FILTER, GL_NEAREST);
+   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
+
+   printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+}
+
+
+static void
+display(void)
+{
+   switch (PerspHint) {
+   case GL_NICEST:
+      printf("hint = GL_NICEST\n");
+      break;
+   case GL_FASTEST:
+      printf("hint = GL_FASTEST\n");
+      break;
+   case GL_DONT_CARE:
+      printf("hint = GL_DONT_CARE\n");
+      break;
+   default:
+      ;
+   }
+
+   glClear(GL_COLOR_BUFFER_BIT);
+
+#if 1
+   glBegin(GL_QUADS);
+   /* exercise perspective interpolation */
+   glColor3f(0.0, 0.0, 0.0); glVertex3f(-1.0, -1.0, -1.0);
+   glColor3f(0.0, 0.0, 0.0); glVertex3f(-1.0, 1.0, -1.0);
+   glColor3f(0.0, 1.0, 0.0); glVertex3f( 7.0, 1.0, -7.0);
+   glColor3f(0.0, 1.0, 0.0); glVertex3f( 7.0, -1.0, -7.0);
+
+   /* stripe of linear interpolation */
+   glColor3f(0.0, 0.0, 0.0); glVertex3f(-1.0, -0.1, -1.001);
+   glColor3f(0.0, 0.0, 0.0); glVertex3f(-1.0,  0.1, -1.001);
+   glColor3f(0.0, 1.0, 0.0); glVertex3f( 1.0,  0.1, -1.001);
+   glColor3f(0.0, 1.0, 0.0); glVertex3f( 1.0, -0.1, -1.001);
+   glEnd();
+#else
+   glEnable(GL_TEXTURE_2D);
+   glBegin(GL_QUADS);
+   glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, 0.0, -1.0);
+   glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0);
+   glTexCoord2f(1.0, 1.0); glVertex3f( 5.0, 1.0, -7.0);
+   glTexCoord2f(1.0, 0.0); glVertex3f( 5.0, 0.0, -7.0);
+
+   glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, -1.001);
+   glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 0.0, -1.001);
+   glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 0.0, -1.001);
+   glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, -1.0, -1.001);
+   glEnd();
+#endif
+
+   glFlush();
+}
+
+
+static void
+reshape(int w, int h)
+{
+   glViewport(0, 0, w, h);
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+   gluPerspective(90.0, (GLfloat) w / h, 1.0, 300.0);
+   glMatrixMode(GL_MODELVIEW);
+   glLoadIdentity();
+}
+
+
+static void
+key(unsigned char k, int x, int y)
+{
+   switch (k) {
+   case 27:  /* Escape */
+      exit(0);
+      break;
+   case 'i':
+      if (PerspHint == GL_FASTEST)
+         PerspHint = GL_NICEST;
+      else if (PerspHint == GL_NICEST)
+         PerspHint = GL_DONT_CARE;
+      else
+         PerspHint = GL_FASTEST;
+      glHint(GL_PERSPECTIVE_CORRECTION_HINT, PerspHint);
+      break;
+   default:
+      return;
+   }
+   glutPostRedisplay();
+}
+
+
+int
+main(int argc, char** argv)
+{
+    glutInit(&argc, argv);
+    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
+    glutInitWindowSize (500, 500);
+    glutCreateWindow (argv[0]);
+    glutReshapeFunc (reshape);
+    glutDisplayFunc(display);
+    glutKeyboardFunc(key);
+
+    printf("Main quad: perspective projection\n");
+    printf("Middle stripe: linear interpolation\n");
+    printf("Press 'i' to toggle interpolation hint\n");
+    init();
+
+    glutMainLoop();
+    return 0;
+}
index 8dcb20a68ffe960420e5c58cc72138441675efbb..dce733a70aecd8a00ca4c4ea88dd55c2c57ca834 100644 (file)
@@ -19,6 +19,7 @@ fs-tri
 line
 line-clip
 line-cull
+line-flat
 line-smooth
 line-stipple-wide
 line-userclip
@@ -130,6 +131,7 @@ tristrip-flat
 vbo-drawarrays
 vbo-drawelements
 vbo-drawrange
+vbo-noninterleaved
 vp-array
 vp-array-int
 vp-clip
@@ -139,6 +141,7 @@ vp-tri-cb
 vp-tri-cb-pos
 vp-tri-cb-tex
 vp-tri-imm
+vp-tri-invariant
 vp-tri-swap
 vp-tri-tex
 vp-unfilled
index 0469e2f2c4c97eac8fe44e4e349aa4c6ed57aabd..2bb57030a89373dbea31d0b41f46217a701016b0 100644 (file)
@@ -137,7 +137,6 @@ static PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample_
 static PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer_func = NULL;
 
 
-
 static void
 GetExtensionFuncs(void)
 {
index 5b3c9752bc4888842720b1eaee05aee0629aeb0f..6e924da303b5dfde92a124e68f41684b43ee6170 100644 (file)
@@ -42,17 +42,18 @@ import SCons.Scanner
 def quietCommandLines(env):
     # Quiet command lines
     # See also http://www.scons.org/wiki/HidingCommandLinesInOutput
-    env['ASCOMSTR'] = "Assembling $SOURCE ..."
-    env['CCCOMSTR'] = "Compiling $SOURCE ..."
-    env['SHCCCOMSTR'] = "Compiling $SOURCE ..."
-    env['CXXCOMSTR'] = "Compiling $SOURCE ..."
-    env['SHCXXCOMSTR'] = "Compiling $SOURCE ..."
-    env['ARCOMSTR'] = "Archiving $TARGET ..."
-    env['RANLIBCOMSTR'] = "Indexing $TARGET ..."
-    env['LINKCOMSTR'] = "Linking $TARGET ..."
-    env['SHLINKCOMSTR'] = "Linking $TARGET ..."
-    env['LDMODULECOMSTR'] = "Linking $TARGET ..."
-    env['SWIGCOMSTR'] = "Generating $TARGET ..."
+    env['ASCOMSTR'] = "  Assembling $SOURCE ..."
+    env['ASPPCOMSTR'] = "  Assembling $SOURCE ..."
+    env['CCCOMSTR'] = "  Compiling $SOURCE ..."
+    env['SHCCCOMSTR'] = "  Compiling $SOURCE ..."
+    env['CXXCOMSTR'] = "  Compiling $SOURCE ..."
+    env['SHCXXCOMSTR'] = "  Compiling $SOURCE ..."
+    env['ARCOMSTR'] = "  Archiving $TARGET ..."
+    env['RANLIBCOMSTR'] = "  Indexing $TARGET ..."
+    env['LINKCOMSTR'] = "  Linking $TARGET ..."
+    env['SHLINKCOMSTR'] = "  Linking $TARGET ..."
+    env['LDMODULECOMSTR'] = "  Linking $TARGET ..."
+    env['SWIGCOMSTR'] = "  Generating $TARGET ..."
 
 
 def createConvenienceLibBuilder(env):
index 4041d5c906a1f2fd8b18b88c5630d176313a2c11..567edfae973d2f6e9083e35996a5e8349ca07220 100644 (file)
@@ -50,7 +50,7 @@ $(TOP)/$(LIB_DIR)/libEGLdri.so: $(OBJECTS)
 
 install:
        $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
-       $(INSTALL) $(TOP)/$(LIB_DIR)/libEGLdri.so $(DESTDIR)$(INSTALL_LIB_DIR)
+       $(MINSTALL) $(TOP)/$(LIB_DIR)/libEGLdri.so $(DESTDIR)$(INSTALL_LIB_DIR)
 
 clean:
        -rm -f *.o
index 5f041a268f1bbc68c29c84921b027a6e6b4d4b3d..20ef0352ad9cb407a0d44e2f0c122e2c752a090f 100644 (file)
@@ -58,7 +58,7 @@ $(TOP)/$(LIB_DIR)/$(DRIVER_NAME): $(OBJECTS)
 
 install:
        $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
-       $(INSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(DESTDIR)$(INSTALL_LIB_DIR)
+       $(MINSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(DESTDIR)$(INSTALL_LIB_DIR)
 
 clean:
        rm -f *.o
index eb83867b71871d5ab6351665c08a3de9e4aa34fe..8a14027fc7b6065173fc1c8458ec8ab37b6400bb 100644 (file)
@@ -54,7 +54,7 @@ $(TOP)/$(LIB_DIR)/$(DRIVER_NAME): $(OBJECTS)
 
 install:
        $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
-       $(INSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(DESTDIR)$(INSTALL_LIB_DIR)
+       $(MINSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(DESTDIR)$(INSTALL_LIB_DIR)
 
 clean:
        rm -f *.o
index 8cfa25ca163683753a603550961db52a03e922c9..cddba9f088706b825335113fe6ec24b162ae179c 100644 (file)
@@ -66,7 +66,7 @@ $(TOP)/$(LIB_DIR)/libEGL.so: $(OBJECTS)
 
 install: default
        $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
-       $(INSTALL) $(TOP)/$(LIB_DIR)/libEGL.so* $(DESTDIR)$(INSTALL_LIB_DIR)
+       $(MINSTALL) $(TOP)/$(LIB_DIR)/libEGL.so* $(DESTDIR)$(INSTALL_LIB_DIR)
 
 clean:
        -rm -f *.o *.so*
index b6ceaf3edf9105719e9658b96f999588d8200e96..32b7c2980ab7bd433a89c6b5554fb439164e6ef8 100644 (file)
@@ -22,6 +22,7 @@ SConscript([
        'auxiliary/draw/SConscript',
        'auxiliary/pipebuffer/SConscript',
        'auxiliary/indices/SConscript',
+       'auxiliary/rbug/SConscript',
 ])
 
 for driver in env['drivers']:
index 6b7d02a19bc031843bf5734874abf1cffc7d8bb9..e7fe6b3b7687af024f8112b6dfc0b025320de0ea 100644 (file)
@@ -130,6 +130,10 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle,
       unsigned output_format;
 
       switch (vinfo->attrib[i].emit) {
+      case EMIT_4UB:
+        output_format = PIPE_FORMAT_R8G8B8A8_UNORM;
+        emit_sz = 4 * sizeof(unsigned char);
+         break;
       case EMIT_4F:
         output_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
         emit_sz = 4 * sizeof(float);
@@ -153,6 +157,8 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle,
         output_format = PIPE_FORMAT_R32_FLOAT;
         emit_sz = 1 * sizeof(float);
          break;
+      case EMIT_OMIT:
+         continue;
       default:
          assert(0);
         output_format = PIPE_FORMAT_NONE;
index dbbc33fffa72fce4d41e93ffbb75676ce0a96245..f2368dde5c291771d4ab34d69c943b6b971e7631 100644 (file)
@@ -114,6 +114,12 @@ vs_exec_run_linear( struct draw_vertex_shader *shader,
 #endif
 
          for (slot = 0; slot < shader->info.num_inputs; slot++) {
+#if 0
+            assert(!util_is_inf_or_nan(input[slot][0]));
+            assert(!util_is_inf_or_nan(input[slot][1]));
+            assert(!util_is_inf_or_nan(input[slot][2]));
+            assert(!util_is_inf_or_nan(input[slot][3]));
+#endif
             machine->Inputs[slot].xyzw[0].f[j] = input[slot][0];
             machine->Inputs[slot].xyzw[1].f[j] = input[slot][1];
             machine->Inputs[slot].xyzw[2].f[j] = input[slot][2];
index 925e948763ecf4139784b8606e8de01d15c57f26..2d2af3085e61482aa60dc89572ad4f07d8006641 100644 (file)
@@ -24,6 +24,8 @@
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  **************************************************************************/
+
+#include <cstdio>
 #include "instructionssoa.h"
 
 #include "storagesoa.h"
diff --git a/src/gallium/auxiliary/rbug/Makefile b/src/gallium/auxiliary/rbug/Makefile
new file mode 100644 (file)
index 0000000..cd12e84
--- /dev/null
@@ -0,0 +1,14 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = rbug
+
+C_SOURCES = \
+       rbug_connection.c \
+       rbug_core.c \
+       rbug_texture.c \
+       rbug_context.c \
+       rbug_shader.c \
+       rbug_demarshal.c
+
+include ../../Makefile.template
diff --git a/src/gallium/auxiliary/rbug/README b/src/gallium/auxiliary/rbug/README
new file mode 100644 (file)
index 0000000..33d7637
--- /dev/null
@@ -0,0 +1,21 @@
+                 GALLIUM REMOTE DEBUGGING COMMON CODE
+
+= About =
+
+This directory contains the common code for the Gallium 3D remote debugging
+driver and clients. The code is two parts the connection managment code and
+the (de)marsheller.
+
+The code currently uses tcp and ip4v for connections.
+
+Information about driver integration can be found in:
+
+src/gallium/drivers/trace/README
+
+for information about applications look in:
+
+progs/rbug/README
+
+
+--
+Jakob Bornecrantz <jakob@vmware.com>
diff --git a/src/gallium/auxiliary/rbug/SConscript b/src/gallium/auxiliary/rbug/SConscript
new file mode 100644 (file)
index 0000000..4a9afb4
--- /dev/null
@@ -0,0 +1,14 @@
+Import('*')
+
+rbug = env.ConvenienceLibrary(
+       target = 'rbug',
+       source = [
+               'rbug_core.c',
+               'rbug_shader.c',
+               'rbug_context.c',
+               'rbug_texture.c',
+               'rbug_demarshal.c',
+               'rbug_connection.c',
+       ])
+
+auxiliaries.insert(0, rbug)
diff --git a/src/gallium/auxiliary/rbug/rbug.h b/src/gallium/auxiliary/rbug/rbug.h
new file mode 100644 (file)
index 0000000..259bfc6
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE 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 all for users the remote debugger protocol code.
+ */
+
+#include "rbug/rbug_core.h"
+#include "rbug/rbug_shader.h"
+#include "rbug/rbug_context.h"
+#include "rbug/rbug_texture.h"
+#include "rbug/rbug_connection.h"
diff --git a/src/gallium/auxiliary/rbug/rbug_connection.c b/src/gallium/auxiliary/rbug/rbug_connection.c
new file mode 100644 (file)
index 0000000..52acb70
--- /dev/null
@@ -0,0 +1,167 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE 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 "rbug/rbug.h"
+#include "rbug/rbug_internal.h"
+
+#include "util/u_network.h"
+
+struct rbug_connection
+{
+   int socket;
+   uint32_t send_serial;
+   uint32_t recv_serial;
+   enum rbug_opcode opcode;
+};
+
+/**
+ * Create a rbug connection from a socket created with u_socket.
+ *
+ * Result:
+ *    A new allocated connection using socket as communication path
+ */
+struct rbug_connection *
+rbug_from_socket(int socket)
+{
+   struct rbug_connection *c = CALLOC_STRUCT(rbug_connection);
+   c->socket = socket;
+   return c;
+}
+
+/**
+ * Free a connection, also closes socket.
+ */
+void
+rbug_disconnect(struct rbug_connection *c)
+{
+   u_socket_close(c->socket);
+   FREE(c);
+}
+
+/**
+ * Waits for a message to be fully received.
+ * Also returns the serial for the message, serial is not touched for replys.
+ *
+ * Result:
+ *    demarshaled message on success, NULL on connection error
+ */
+struct rbug_header *
+rbug_get_message(struct rbug_connection *c, uint32_t *serial)
+{
+   struct rbug_proto_header header;
+   struct rbug_header *out;
+   struct rbug_proto_header *data;
+   size_t length = 0;
+   size_t read = 0;
+   int ret;
+
+
+   ret = u_socket_peek(c->socket, &header, sizeof(header));
+   if (ret <= 0) {
+      return NULL;
+   }
+
+   length = (size_t)header.length * 4;
+   data = MALLOC(length);
+   if (!data) {
+      return NULL;
+   }
+
+   do {
+      uint8_t *ptr = ((uint8_t*)data) + read;
+      ret = u_socket_recv(c->socket, ptr, length - read);
+
+      if (ret <= 0) {
+         FREE(data);
+         return NULL;
+      }
+
+      read += ret;
+   } while(read < length);
+
+   out = rbug_demarshal(data);
+   if (!out)
+      FREE(data);
+   else if (serial)
+      *serial = c->recv_serial++;
+   else
+      c->recv_serial++;
+
+   return out;
+}
+
+/**
+ * Frees a message and associated data.
+ */
+void
+rbug_free_header(struct rbug_header *header)
+{
+   if (!header)
+      return;
+
+   FREE(header->__message);
+   FREE(header);
+}
+
+/**
+ * Internal function used by rbug_send_* functions.
+ *
+ * Start sending a message.
+ */
+int
+rbug_connection_send_start(struct rbug_connection *c, enum rbug_opcode opcode, uint32_t length)
+{
+   c->opcode = opcode;
+   return 0;
+}
+
+/**
+ * Internal function used by rbug_send_* functions.
+ *
+ * Write data to the socket.
+ */
+int
+rbug_connection_write(struct rbug_connection *c, void *to, uint32_t size)
+{
+   int ret = u_socket_send(c->socket, to, size);
+   return ret;
+}
+
+/**
+ * Internal function used by rbug_send_* functions.
+ *
+ * Finish writeing data to the socket.
+ * Ups the send_serial and sets the serial argument if supplied.
+ */
+int rbug_connection_send_finish(struct rbug_connection *c, uint32_t *serial)
+{
+   if (c->opcode < 0)
+      return 0;
+   else if (serial)
+      *serial = c->send_serial++;
+   else
+      c->send_serial++;
+
+   return 0;
+}
diff --git a/src/gallium/auxiliary/rbug/rbug_connection.h b/src/gallium/auxiliary/rbug/rbug_connection.h
new file mode 100644 (file)
index 0000000..1f2c9ff
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * This file contains the function defentions for connection see c file for
+ * more comments covering function use.
+ */
+
+#ifndef _RBUG_CONNECTION_H_
+#define _RBUG_CONNECTION_H_
+
+#include "rbug/rbug_proto.h"
+
+struct rbug_connection * rbug_from_socket(int socket);
+
+void rbug_disconnect(struct rbug_connection *c);
+
+struct rbug_header * rbug_get_message(struct rbug_connection *c, uint32_t *serial);
+
+void rbug_free_header(struct rbug_header *header);
+
+struct rbug_header * rbug_demarshal(struct rbug_proto_header *header);
+
+#endif
diff --git a/src/gallium/auxiliary/rbug/rbug_context.c b/src/gallium/auxiliary/rbug/rbug_context.c
new file mode 100644 (file)
index 0000000..1832425
--- /dev/null
@@ -0,0 +1,759 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * This file holds the function implementation for one of the rbug extensions.
+ * Prototypes and declerations of functions and structs is in the same folder
+ * in the header file matching this file's name.
+ *
+ * The functions starting rbug_send_* encodes a call to the write format and
+ * sends that to the supplied connection, while functions starting with
+ * rbug_demarshal_* demarshal data in the wire protocol.
+ *
+ * Functions ending with _reply are replies to requests.
+ */
+
+#include "rbug_internal.h"
+#include "rbug/rbug_context.h"
+
+int rbug_send_context_list(struct rbug_connection *__con,
+                           uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_LIST));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_CONTEXT_LIST, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_context_info(struct rbug_connection *__con,
+                           rbug_context_t context,
+                           uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(8); /* context */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_INFO));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(8, rbug_context_t, context); /* context */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_CONTEXT_INFO, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_context_draw_block(struct rbug_connection *__con,
+                                 rbug_context_t context,
+                                 rbug_block_t block,
+                                 uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(8); /* context */
+       LEN(4); /* block */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_BLOCK));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(8, rbug_context_t, context); /* context */
+       WRITE(4, rbug_block_t, block); /* block */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_BLOCK, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_context_draw_step(struct rbug_connection *__con,
+                                rbug_context_t context,
+                                rbug_block_t step,
+                                uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(8); /* context */
+       LEN(4); /* step */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_STEP));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(8, rbug_context_t, context); /* context */
+       WRITE(4, rbug_block_t, step); /* step */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_STEP, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_context_draw_unblock(struct rbug_connection *__con,
+                                   rbug_context_t context,
+                                   rbug_block_t unblock,
+                                   uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(8); /* context */
+       LEN(4); /* unblock */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_UNBLOCK));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(8, rbug_context_t, context); /* context */
+       WRITE(4, rbug_block_t, unblock); /* unblock */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_UNBLOCK, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_context_draw_rule(struct rbug_connection *__con,
+                                rbug_context_t context,
+                                rbug_shader_t vertex,
+                                rbug_shader_t fragment,
+                                rbug_texture_t texture,
+                                rbug_texture_t surface,
+                                rbug_block_t block,
+                                uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(8); /* context */
+       LEN(8); /* vertex */
+       LEN(8); /* fragment */
+       LEN(8); /* texture */
+       LEN(8); /* surface */
+       LEN(4); /* block */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_RULE));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(8, rbug_context_t, context); /* context */
+       WRITE(8, rbug_shader_t, vertex); /* vertex */
+       WRITE(8, rbug_shader_t, fragment); /* fragment */
+       WRITE(8, rbug_texture_t, texture); /* texture */
+       WRITE(8, rbug_texture_t, surface); /* surface */
+       WRITE(4, rbug_block_t, block); /* block */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_RULE, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_context_flush(struct rbug_connection *__con,
+                            rbug_context_t context,
+                            int32_t flags,
+                            uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(8); /* context */
+       LEN(4); /* flags */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_FLUSH));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(8, rbug_context_t, context); /* context */
+       WRITE(4, int32_t, flags); /* flags */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_CONTEXT_FLUSH, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_context_list_reply(struct rbug_connection *__con,
+                                 uint32_t serial,
+                                 rbug_context_t *contexts,
+                                 uint32_t contexts_len,
+                                 uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(4); /* serial */
+       LEN_ARRAY(8, contexts); /* contexts */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_LIST_REPLY));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(4, uint32_t, serial); /* serial */
+       WRITE_ARRAY(8, rbug_context_t, contexts); /* contexts */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_CONTEXT_LIST_REPLY, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_context_info_reply(struct rbug_connection *__con,
+                                 uint32_t serial,
+                                 rbug_shader_t vertex,
+                                 rbug_shader_t fragment,
+                                 rbug_texture_t *texs,
+                                 uint32_t texs_len,
+                                 rbug_texture_t *cbufs,
+                                 uint32_t cbufs_len,
+                                 rbug_texture_t zsbuf,
+                                 rbug_block_t blocker,
+                                 rbug_block_t blocked,
+                                 uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(4); /* serial */
+       LEN(8); /* vertex */
+       LEN(8); /* fragment */
+       LEN_ARRAY(8, texs); /* texs */
+       LEN_ARRAY(8, cbufs); /* cbufs */
+       LEN(8); /* zsbuf */
+       LEN(4); /* blocker */
+       LEN(4); /* blocked */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_INFO_REPLY));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(4, uint32_t, serial); /* serial */
+       WRITE(8, rbug_shader_t, vertex); /* vertex */
+       WRITE(8, rbug_shader_t, fragment); /* fragment */
+       WRITE_ARRAY(8, rbug_texture_t, texs); /* texs */
+       WRITE_ARRAY(8, rbug_texture_t, cbufs); /* cbufs */
+       WRITE(8, rbug_texture_t, zsbuf); /* zsbuf */
+       WRITE(4, rbug_block_t, blocker); /* blocker */
+       WRITE(4, rbug_block_t, blocked); /* blocked */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_CONTEXT_INFO_REPLY, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_context_draw_blocked(struct rbug_connection *__con,
+                                   rbug_context_t context,
+                                   rbug_block_t block,
+                                   uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(8); /* context */
+       LEN(4); /* block */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_BLOCKED));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(8, rbug_context_t, context); /* context */
+       WRITE(4, rbug_block_t, block); /* block */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_BLOCKED, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+struct rbug_proto_context_list * rbug_demarshal_context_list(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_context_list *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_CONTEXT_LIST)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+
+       return ret;
+}
+
+struct rbug_proto_context_info * rbug_demarshal_context_info(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_context_info *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_CONTEXT_INFO)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(8, rbug_context_t, context); /* context */
+
+       return ret;
+}
+
+struct rbug_proto_context_draw_block * rbug_demarshal_context_draw_block(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_context_draw_block *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_CONTEXT_DRAW_BLOCK)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(8, rbug_context_t, context); /* context */
+       READ(4, rbug_block_t, block); /* block */
+
+       return ret;
+}
+
+struct rbug_proto_context_draw_step * rbug_demarshal_context_draw_step(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_context_draw_step *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_CONTEXT_DRAW_STEP)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(8, rbug_context_t, context); /* context */
+       READ(4, rbug_block_t, step); /* step */
+
+       return ret;
+}
+
+struct rbug_proto_context_draw_unblock * rbug_demarshal_context_draw_unblock(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_context_draw_unblock *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_CONTEXT_DRAW_UNBLOCK)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(8, rbug_context_t, context); /* context */
+       READ(4, rbug_block_t, unblock); /* unblock */
+
+       return ret;
+}
+
+struct rbug_proto_context_draw_rule * rbug_demarshal_context_draw_rule(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_context_draw_rule *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_CONTEXT_DRAW_RULE)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(8, rbug_context_t, context); /* context */
+       READ(8, rbug_shader_t, vertex); /* vertex */
+       READ(8, rbug_shader_t, fragment); /* fragment */
+       READ(8, rbug_texture_t, texture); /* texture */
+       READ(8, rbug_texture_t, surface); /* surface */
+       READ(4, rbug_block_t, block); /* block */
+
+       return ret;
+}
+
+struct rbug_proto_context_flush * rbug_demarshal_context_flush(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_context_flush *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_CONTEXT_FLUSH)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(8, rbug_context_t, context); /* context */
+       READ(4, int32_t, flags); /* flags */
+
+       return ret;
+}
+
+struct rbug_proto_context_list_reply * rbug_demarshal_context_list_reply(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_context_list_reply *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_CONTEXT_LIST_REPLY)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(4, uint32_t, serial); /* serial */
+       READ_ARRAY(8, rbug_context_t, contexts); /* contexts */
+
+       return ret;
+}
+
+struct rbug_proto_context_info_reply * rbug_demarshal_context_info_reply(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_context_info_reply *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_CONTEXT_INFO_REPLY)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(4, uint32_t, serial); /* serial */
+       READ(8, rbug_shader_t, vertex); /* vertex */
+       READ(8, rbug_shader_t, fragment); /* fragment */
+       READ_ARRAY(8, rbug_texture_t, texs); /* texs */
+       READ_ARRAY(8, rbug_texture_t, cbufs); /* cbufs */
+       READ(8, rbug_texture_t, zsbuf); /* zsbuf */
+       READ(4, rbug_block_t, blocker); /* blocker */
+       READ(4, rbug_block_t, blocked); /* blocked */
+
+       return ret;
+}
+
+struct rbug_proto_context_draw_blocked * rbug_demarshal_context_draw_blocked(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_context_draw_blocked *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_CONTEXT_DRAW_BLOCKED)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(8, rbug_context_t, context); /* context */
+       READ(4, rbug_block_t, block); /* block */
+
+       return ret;
+}
diff --git a/src/gallium/auxiliary/rbug/rbug_context.h b/src/gallium/auxiliary/rbug/rbug_context.h
new file mode 100644 (file)
index 0000000..da61c23
--- /dev/null
@@ -0,0 +1,212 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * This file holds structs decelerations and function prototypes for one of
+ * the rbug extensions. Implementation of the functions is in the same folder
+ * in the c file matching this file's name.
+ *
+ * The structs what is returned from the demarshal functions. The functions
+ * starting rbug_send_* encodes a call to the write format and sends that to
+ * the supplied connection, while functions starting with rbug_demarshal_*
+ * demarshal data from the wire protocol.
+ *
+ * Structs and functions ending with _reply are replies to requests.
+ */
+
+#ifndef _RBUG_PROTO_CONTEXT_H_
+#define _RBUG_PROTO_CONTEXT_H_
+
+#include "rbug/rbug_proto.h"
+#include "rbug/rbug_core.h"
+
+typedef enum
+{
+       RBUG_BLOCK_BEFORE = 1,
+       RBUG_BLOCK_AFTER = 2,
+       RBUG_BLOCK_RULE = 4,
+       RBUG_BLOCK_MASK = 7,
+} rbug_block_t;
+
+struct rbug_proto_context_list
+{
+       struct rbug_header header;
+};
+
+struct rbug_proto_context_info
+{
+       struct rbug_header header;
+       rbug_context_t context;
+};
+
+struct rbug_proto_context_draw_block
+{
+       struct rbug_header header;
+       rbug_context_t context;
+       rbug_block_t block;
+};
+
+struct rbug_proto_context_draw_step
+{
+       struct rbug_header header;
+       rbug_context_t context;
+       rbug_block_t step;
+};
+
+struct rbug_proto_context_draw_unblock
+{
+       struct rbug_header header;
+       rbug_context_t context;
+       rbug_block_t unblock;
+};
+
+struct rbug_proto_context_draw_rule
+{
+       struct rbug_header header;
+       rbug_context_t context;
+       rbug_shader_t vertex;
+       rbug_shader_t fragment;
+       rbug_texture_t texture;
+       rbug_texture_t surface;
+       rbug_block_t block;
+};
+
+struct rbug_proto_context_flush
+{
+       struct rbug_header header;
+       rbug_context_t context;
+       int32_t flags;
+};
+
+struct rbug_proto_context_list_reply
+{
+       struct rbug_header header;
+       uint32_t serial;
+       rbug_context_t *contexts;
+       uint32_t contexts_len;
+};
+
+struct rbug_proto_context_info_reply
+{
+       struct rbug_header header;
+       uint32_t serial;
+       rbug_shader_t vertex;
+       rbug_shader_t fragment;
+       rbug_texture_t *texs;
+       uint32_t texs_len;
+       rbug_texture_t *cbufs;
+       uint32_t cbufs_len;
+       rbug_texture_t zsbuf;
+       rbug_block_t blocker;
+       rbug_block_t blocked;
+};
+
+struct rbug_proto_context_draw_blocked
+{
+       struct rbug_header header;
+       rbug_context_t context;
+       rbug_block_t block;
+};
+
+int rbug_send_context_list(struct rbug_connection *__con,
+                           uint32_t *__serial);
+
+int rbug_send_context_info(struct rbug_connection *__con,
+                           rbug_context_t context,
+                           uint32_t *__serial);
+
+int rbug_send_context_draw_block(struct rbug_connection *__con,
+                                 rbug_context_t context,
+                                 rbug_block_t block,
+                                 uint32_t *__serial);
+
+int rbug_send_context_draw_step(struct rbug_connection *__con,
+                                rbug_context_t context,
+                                rbug_block_t step,
+                                uint32_t *__serial);
+
+int rbug_send_context_draw_unblock(struct rbug_connection *__con,
+                                   rbug_context_t context,
+                                   rbug_block_t unblock,
+                                   uint32_t *__serial);
+
+int rbug_send_context_draw_rule(struct rbug_connection *__con,
+                                rbug_context_t context,
+                                rbug_shader_t vertex,
+                                rbug_shader_t fragment,
+                                rbug_texture_t texture,
+                                rbug_texture_t surface,
+                                rbug_block_t block,
+                                uint32_t *__serial);
+
+int rbug_send_context_flush(struct rbug_connection *__con,
+                            rbug_context_t context,
+                            int32_t flags,
+                            uint32_t *__serial);
+
+int rbug_send_context_list_reply(struct rbug_connection *__con,
+                                 uint32_t serial,
+                                 rbug_context_t *contexts,
+                                 uint32_t contexts_len,
+                                 uint32_t *__serial);
+
+int rbug_send_context_info_reply(struct rbug_connection *__con,
+                                 uint32_t serial,
+                                 rbug_shader_t vertex,
+                                 rbug_shader_t fragment,
+                                 rbug_texture_t *texs,
+                                 uint32_t texs_len,
+                                 rbug_texture_t *cbufs,
+                                 uint32_t cbufs_len,
+                                 rbug_texture_t zsbuf,
+                                 rbug_block_t blocker,
+                                 rbug_block_t blocked,
+                                 uint32_t *__serial);
+
+int rbug_send_context_draw_blocked(struct rbug_connection *__con,
+                                   rbug_context_t context,
+                                   rbug_block_t block,
+                                   uint32_t *__serial);
+
+struct rbug_proto_context_list * rbug_demarshal_context_list(struct rbug_proto_header *header);
+
+struct rbug_proto_context_info * rbug_demarshal_context_info(struct rbug_proto_header *header);
+
+struct rbug_proto_context_draw_block * rbug_demarshal_context_draw_block(struct rbug_proto_header *header);
+
+struct rbug_proto_context_draw_step * rbug_demarshal_context_draw_step(struct rbug_proto_header *header);
+
+struct rbug_proto_context_draw_unblock * rbug_demarshal_context_draw_unblock(struct rbug_proto_header *header);
+
+struct rbug_proto_context_draw_rule * rbug_demarshal_context_draw_rule(struct rbug_proto_header *header);
+
+struct rbug_proto_context_flush * rbug_demarshal_context_flush(struct rbug_proto_header *header);
+
+struct rbug_proto_context_list_reply * rbug_demarshal_context_list_reply(struct rbug_proto_header *header);
+
+struct rbug_proto_context_info_reply * rbug_demarshal_context_info_reply(struct rbug_proto_header *header);
+
+struct rbug_proto_context_draw_blocked * rbug_demarshal_context_draw_blocked(struct rbug_proto_header *header);
+
+#endif
diff --git a/src/gallium/auxiliary/rbug/rbug_core.c b/src/gallium/auxiliary/rbug/rbug_core.c
new file mode 100644 (file)
index 0000000..876ae5a
--- /dev/null
@@ -0,0 +1,359 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * This file holds the function implementation for one of the rbug extensions.
+ * Prototypes and declerations of functions and structs is in the same folder
+ * in the header file matching this file's name.
+ *
+ * The functions starting rbug_send_* encodes a call to the write format and
+ * sends that to the supplied connection, while functions starting with
+ * rbug_demarshal_* demarshal data in the wire protocol.
+ *
+ * Functions ending with _reply are replies to requests.
+ */
+
+#include "rbug_internal.h"
+#include "rbug/rbug_core.h"
+
+int rbug_send_noop(struct rbug_connection *__con,
+                   uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_NOOP));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_NOOP, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_ping(struct rbug_connection *__con,
+                   uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_PING));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_PING, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_error(struct rbug_connection *__con,
+                    uint32_t error,
+                    uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(4); /* error */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_ERROR));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(4, uint32_t, error); /* error */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_ERROR, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_ping_reply(struct rbug_connection *__con,
+                         uint32_t serial,
+                         uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(4); /* serial */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_PING_REPLY));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(4, uint32_t, serial); /* serial */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_PING_REPLY, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_error_reply(struct rbug_connection *__con,
+                          uint32_t serial,
+                          uint32_t error,
+                          uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(4); /* serial */
+       LEN(4); /* error */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_ERROR_REPLY));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(4, uint32_t, serial); /* serial */
+       WRITE(4, uint32_t, error); /* error */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_ERROR_REPLY, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+struct rbug_proto_noop * rbug_demarshal_noop(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_noop *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_NOOP)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+
+       return ret;
+}
+
+struct rbug_proto_ping * rbug_demarshal_ping(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_ping *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_PING)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+
+       return ret;
+}
+
+struct rbug_proto_error * rbug_demarshal_error(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_error *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_ERROR)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(4, uint32_t, error); /* error */
+
+       return ret;
+}
+
+struct rbug_proto_ping_reply * rbug_demarshal_ping_reply(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_ping_reply *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_PING_REPLY)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(4, uint32_t, serial); /* serial */
+
+       return ret;
+}
+
+struct rbug_proto_error_reply * rbug_demarshal_error_reply(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_error_reply *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_ERROR_REPLY)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(4, uint32_t, serial); /* serial */
+       READ(4, uint32_t, error); /* error */
+
+       return ret;
+}
diff --git a/src/gallium/auxiliary/rbug/rbug_core.h b/src/gallium/auxiliary/rbug/rbug_core.h
new file mode 100644 (file)
index 0000000..99a36a0
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * This file holds structs decelerations and function prototypes for one of
+ * the rbug extensions. Implementation of the functions is in the same folder
+ * in the c file matching this file's name.
+ *
+ * The structs what is returned from the demarshal functions. The functions
+ * starting rbug_send_* encodes a call to the write format and sends that to
+ * the supplied connection, while functions starting with rbug_demarshal_*
+ * demarshal data from the wire protocol.
+ *
+ * Structs and functions ending with _reply are replies to requests.
+ */
+
+#ifndef _RBUG_PROTO_CORE_H_
+#define _RBUG_PROTO_CORE_H_
+
+#include "rbug/rbug_proto.h"
+
+typedef uint64_t rbug_shader_t;
+typedef uint64_t rbug_context_t;
+typedef uint64_t rbug_texture_t;
+
+struct rbug_proto_noop
+{
+       struct rbug_header header;
+};
+
+struct rbug_proto_ping
+{
+       struct rbug_header header;
+};
+
+struct rbug_proto_error
+{
+       struct rbug_header header;
+       uint32_t error;
+};
+
+struct rbug_proto_ping_reply
+{
+       struct rbug_header header;
+       uint32_t serial;
+};
+
+struct rbug_proto_error_reply
+{
+       struct rbug_header header;
+       uint32_t serial;
+       uint32_t error;
+};
+
+int rbug_send_noop(struct rbug_connection *__con,
+                   uint32_t *__serial);
+
+int rbug_send_ping(struct rbug_connection *__con,
+                   uint32_t *__serial);
+
+int rbug_send_error(struct rbug_connection *__con,
+                    uint32_t error,
+                    uint32_t *__serial);
+
+int rbug_send_ping_reply(struct rbug_connection *__con,
+                         uint32_t serial,
+                         uint32_t *__serial);
+
+int rbug_send_error_reply(struct rbug_connection *__con,
+                          uint32_t serial,
+                          uint32_t error,
+                          uint32_t *__serial);
+
+struct rbug_proto_noop * rbug_demarshal_noop(struct rbug_proto_header *header);
+
+struct rbug_proto_ping * rbug_demarshal_ping(struct rbug_proto_header *header);
+
+struct rbug_proto_error * rbug_demarshal_error(struct rbug_proto_header *header);
+
+struct rbug_proto_ping_reply * rbug_demarshal_ping_reply(struct rbug_proto_header *header);
+
+struct rbug_proto_error_reply * rbug_demarshal_error_reply(struct rbug_proto_header *header);
+
+#endif
diff --git a/src/gallium/auxiliary/rbug/rbug_demarshal.c b/src/gallium/auxiliary/rbug/rbug_demarshal.c
new file mode 100644 (file)
index 0000000..47390fb
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE 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 "rbug.h"
+
+/**
+ * Small function that looks at the proto_header and selects the correct
+ * demarshal functions and return the result.
+ */
+struct rbug_header * rbug_demarshal(struct rbug_proto_header *header)
+{
+       switch(header->opcode) {
+       case RBUG_OP_NOOP:
+               return (struct rbug_header *)rbug_demarshal_noop(header);
+       case RBUG_OP_PING:
+               return (struct rbug_header *)rbug_demarshal_ping(header);
+       case RBUG_OP_ERROR:
+               return (struct rbug_header *)rbug_demarshal_error(header);
+       case RBUG_OP_PING_REPLY:
+               return (struct rbug_header *)rbug_demarshal_ping_reply(header);
+       case RBUG_OP_ERROR_REPLY:
+               return (struct rbug_header *)rbug_demarshal_error_reply(header);
+       case RBUG_OP_TEXTURE_LIST:
+               return (struct rbug_header *)rbug_demarshal_texture_list(header);
+       case RBUG_OP_TEXTURE_INFO:
+               return (struct rbug_header *)rbug_demarshal_texture_info(header);
+       case RBUG_OP_TEXTURE_WRITE:
+               return (struct rbug_header *)rbug_demarshal_texture_write(header);
+       case RBUG_OP_TEXTURE_READ:
+               return (struct rbug_header *)rbug_demarshal_texture_read(header);
+       case RBUG_OP_TEXTURE_LIST_REPLY:
+               return (struct rbug_header *)rbug_demarshal_texture_list_reply(header);
+       case RBUG_OP_TEXTURE_INFO_REPLY:
+               return (struct rbug_header *)rbug_demarshal_texture_info_reply(header);
+       case RBUG_OP_TEXTURE_READ_REPLY:
+               return (struct rbug_header *)rbug_demarshal_texture_read_reply(header);
+       case RBUG_OP_CONTEXT_LIST:
+               return (struct rbug_header *)rbug_demarshal_context_list(header);
+       case RBUG_OP_CONTEXT_INFO:
+               return (struct rbug_header *)rbug_demarshal_context_info(header);
+       case RBUG_OP_CONTEXT_DRAW_BLOCK:
+               return (struct rbug_header *)rbug_demarshal_context_draw_block(header);
+       case RBUG_OP_CONTEXT_DRAW_STEP:
+               return (struct rbug_header *)rbug_demarshal_context_draw_step(header);
+       case RBUG_OP_CONTEXT_DRAW_UNBLOCK:
+               return (struct rbug_header *)rbug_demarshal_context_draw_unblock(header);
+       case RBUG_OP_CONTEXT_DRAW_RULE:
+               return (struct rbug_header *)rbug_demarshal_context_draw_rule(header);
+       case RBUG_OP_CONTEXT_FLUSH:
+               return (struct rbug_header *)rbug_demarshal_context_flush(header);
+       case RBUG_OP_CONTEXT_LIST_REPLY:
+               return (struct rbug_header *)rbug_demarshal_context_list_reply(header);
+       case RBUG_OP_CONTEXT_INFO_REPLY:
+               return (struct rbug_header *)rbug_demarshal_context_info_reply(header);
+       case RBUG_OP_CONTEXT_DRAW_BLOCKED:
+               return (struct rbug_header *)rbug_demarshal_context_draw_blocked(header);
+       case RBUG_OP_SHADER_LIST:
+               return (struct rbug_header *)rbug_demarshal_shader_list(header);
+       case RBUG_OP_SHADER_INFO:
+               return (struct rbug_header *)rbug_demarshal_shader_info(header);
+       case RBUG_OP_SHADER_DISABLE:
+               return (struct rbug_header *)rbug_demarshal_shader_disable(header);
+       case RBUG_OP_SHADER_REPLACE:
+               return (struct rbug_header *)rbug_demarshal_shader_replace(header);
+       case RBUG_OP_SHADER_LIST_REPLY:
+               return (struct rbug_header *)rbug_demarshal_shader_list_reply(header);
+       case RBUG_OP_SHADER_INFO_REPLY:
+               return (struct rbug_header *)rbug_demarshal_shader_info_reply(header);
+       default:
+               return NULL;
+       }
+}
diff --git a/src/gallium/auxiliary/rbug/rbug_internal.h b/src/gallium/auxiliary/rbug/rbug_internal.h
new file mode 100644 (file)
index 0000000..4aba1a8
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * This file is internal to the rbug protocol code, and contains asorted
+ * features needed by the code.
+ */
+
+#ifndef _RBUG_INTERNAL_H_
+#define _RBUG_INTERNAL_H_
+
+#include "rbug/rbug_proto.h"
+
+#include "util/u_memory.h"
+#include "util/u_debug.h"
+#include <errno.h>
+
+int rbug_connection_send_start(struct rbug_connection *con, enum rbug_opcode opcode, uint32_t length);
+int rbug_connection_write(struct rbug_connection *con, void *data, uint32_t size);
+int rbug_connection_send_finish(struct rbug_connection *con, uint32_t *c);
+
+/**
+ * Only works with multiples of 2
+ */
+#define PAD(from, to)                       \
+do {                                        \
+       from = (from + to - 1) & ~(to - 1); \
+} while(0)
+
+#define LEN(size)         \
+do {                      \
+       PAD(__len, size); \
+       __len += size;    \
+} while(0)
+
+#define LEN_ARRAY(size, name)       \
+do {                                \
+       LEN(4);                     \
+       PAD(__len, size);           \
+       __len += size * name##_len; \
+} while(0)
+
+#define WRITE(size, type, name)             \
+do {                                        \
+       PAD(__pos, size);                   \
+       *((type *)(&__data[__pos])) = name; \
+       __pos += size;                      \
+} while(0)
+
+#define WRITE_ARRAY(size, type, name)                    \
+do {                                                     \
+       WRITE(4, uint32_t, name##_len);                  \
+       PAD(__pos, size);                                \
+       memcpy(&__data[__pos], name, size * name##_len); \
+       __pos += size * name##_len;                      \
+} while(0)
+
+#define READ(size, type, name)                      \
+do {                                                \
+       PAD(pos, size);                             \
+       pos += size;                                \
+       if (pos > len)                              \
+               break;                              \
+       ret->name = *((type *)(&data[pos - size])); \
+} while(0)
+
+#define READ_ARRAY(size, type, name)                             \
+do {                                                             \
+       READ(4, uint32_t, name##_len);                           \
+       if (pos > len)                                           \
+               break;                                           \
+       PAD(pos, size);                                          \
+       pos += size * ret->name##_len;                           \
+       if (pos > len)                                           \
+               break;                                           \
+       ret->name = (type *)&data[pos - size * ret->name##_len]; \
+} while(0)
+
+#endif
diff --git a/src/gallium/auxiliary/rbug/rbug_proto.h b/src/gallium/auxiliary/rbug/rbug_proto.h
new file mode 100644 (file)
index 0000000..d273be0
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * This file holds common definitions of the gallium remote debugging protocol.
+ */
+
+#ifndef _RBUG_PROTO_H_
+#define _RBUG_PROTO_H_
+
+#include "pipe/p_compiler.h"
+
+/**
+ * Uniqe indentifier for each command.
+ *
+ * Replys are designated by negative.
+ */
+enum rbug_opcode
+{
+       RBUG_OP_NOOP = 0,
+       RBUG_OP_PING = 1,
+       RBUG_OP_ERROR = 2,
+       RBUG_OP_PING_REPLY = -1,
+       RBUG_OP_ERROR_REPLY = -2,
+       RBUG_OP_TEXTURE_LIST = 256,
+       RBUG_OP_TEXTURE_INFO = 257,
+       RBUG_OP_TEXTURE_WRITE = 258,
+       RBUG_OP_TEXTURE_READ = 259,
+       RBUG_OP_TEXTURE_LIST_REPLY = -256,
+       RBUG_OP_TEXTURE_INFO_REPLY = -257,
+       RBUG_OP_TEXTURE_READ_REPLY = -259,
+       RBUG_OP_CONTEXT_LIST = 512,
+       RBUG_OP_CONTEXT_INFO = 513,
+       RBUG_OP_CONTEXT_DRAW_BLOCK = 514,
+       RBUG_OP_CONTEXT_DRAW_STEP = 515,
+       RBUG_OP_CONTEXT_DRAW_UNBLOCK = 516,
+       RBUG_OP_CONTEXT_DRAW_RULE = 518,
+       RBUG_OP_CONTEXT_FLUSH = 519,
+       RBUG_OP_CONTEXT_LIST_REPLY = -512,
+       RBUG_OP_CONTEXT_INFO_REPLY = -513,
+       RBUG_OP_CONTEXT_DRAW_BLOCKED = 517,
+       RBUG_OP_SHADER_LIST = 768,
+       RBUG_OP_SHADER_INFO = 769,
+       RBUG_OP_SHADER_DISABLE = 770,
+       RBUG_OP_SHADER_REPLACE = 771,
+       RBUG_OP_SHADER_LIST_REPLY = -768,
+       RBUG_OP_SHADER_INFO_REPLY = -769,
+};
+
+/**
+ * Header for demarshaled message.
+ */
+struct rbug_header
+{
+       enum rbug_opcode opcode;
+       void *__message;
+};
+
+/**
+ * Header for a message in wire format.
+ */
+struct rbug_proto_header
+{
+       int32_t opcode;
+       uint32_t length;
+};
+
+/**
+ * Forward declare connection here, as this file is included by all users.
+ */
+struct rbug_connection;
+
+#endif
diff --git a/src/gallium/auxiliary/rbug/rbug_shader.c b/src/gallium/auxiliary/rbug/rbug_shader.c
new file mode 100644 (file)
index 0000000..fccd2f5
--- /dev/null
@@ -0,0 +1,468 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * This file holds the function implementation for one of the rbug extensions.
+ * Prototypes and declerations of functions and structs is in the same folder
+ * in the header file matching this file's name.
+ *
+ * The functions starting rbug_send_* encodes a call to the write format and
+ * sends that to the supplied connection, while functions starting with
+ * rbug_demarshal_* demarshal data in the wire protocol.
+ *
+ * Functions ending with _reply are replies to requests.
+ */
+
+#include "rbug_internal.h"
+#include "rbug/rbug_shader.h"
+
+int rbug_send_shader_list(struct rbug_connection *__con,
+                          rbug_context_t context,
+                          uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(8); /* context */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_LIST));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(8, rbug_context_t, context); /* context */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_SHADER_LIST, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_shader_info(struct rbug_connection *__con,
+                          rbug_context_t context,
+                          rbug_shader_t shader,
+                          uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(8); /* context */
+       LEN(8); /* shader */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_INFO));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(8, rbug_context_t, context); /* context */
+       WRITE(8, rbug_shader_t, shader); /* shader */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_SHADER_INFO, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_shader_disable(struct rbug_connection *__con,
+                             rbug_context_t context,
+                             rbug_shader_t shader,
+                             uint8_t disable,
+                             uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(8); /* context */
+       LEN(8); /* shader */
+       LEN(1); /* disable */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_DISABLE));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(8, rbug_context_t, context); /* context */
+       WRITE(8, rbug_shader_t, shader); /* shader */
+       WRITE(1, uint8_t, disable); /* disable */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_SHADER_DISABLE, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_shader_replace(struct rbug_connection *__con,
+                             rbug_context_t context,
+                             rbug_shader_t shader,
+                             uint32_t *tokens,
+                             uint32_t tokens_len,
+                             uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(8); /* context */
+       LEN(8); /* shader */
+       LEN_ARRAY(4, tokens); /* tokens */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_REPLACE));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(8, rbug_context_t, context); /* context */
+       WRITE(8, rbug_shader_t, shader); /* shader */
+       WRITE_ARRAY(4, uint32_t, tokens); /* tokens */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_SHADER_REPLACE, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_shader_list_reply(struct rbug_connection *__con,
+                                uint32_t serial,
+                                rbug_shader_t *shaders,
+                                uint32_t shaders_len,
+                                uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(4); /* serial */
+       LEN_ARRAY(8, shaders); /* shaders */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_LIST_REPLY));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(4, uint32_t, serial); /* serial */
+       WRITE_ARRAY(8, rbug_shader_t, shaders); /* shaders */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_SHADER_LIST_REPLY, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_shader_info_reply(struct rbug_connection *__con,
+                                uint32_t serial,
+                                uint32_t *original,
+                                uint32_t original_len,
+                                uint32_t *replaced,
+                                uint32_t replaced_len,
+                                uint8_t disabled,
+                                uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(4); /* serial */
+       LEN_ARRAY(4, original); /* original */
+       LEN_ARRAY(4, replaced); /* replaced */
+       LEN(1); /* disabled */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_INFO_REPLY));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(4, uint32_t, serial); /* serial */
+       WRITE_ARRAY(4, uint32_t, original); /* original */
+       WRITE_ARRAY(4, uint32_t, replaced); /* replaced */
+       WRITE(1, uint8_t, disabled); /* disabled */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_SHADER_INFO_REPLY, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+struct rbug_proto_shader_list * rbug_demarshal_shader_list(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_shader_list *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_SHADER_LIST)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(8, rbug_context_t, context); /* context */
+
+       return ret;
+}
+
+struct rbug_proto_shader_info * rbug_demarshal_shader_info(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_shader_info *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_SHADER_INFO)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(8, rbug_context_t, context); /* context */
+       READ(8, rbug_shader_t, shader); /* shader */
+
+       return ret;
+}
+
+struct rbug_proto_shader_disable * rbug_demarshal_shader_disable(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_shader_disable *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_SHADER_DISABLE)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(8, rbug_context_t, context); /* context */
+       READ(8, rbug_shader_t, shader); /* shader */
+       READ(1, uint8_t, disable); /* disable */
+
+       return ret;
+}
+
+struct rbug_proto_shader_replace * rbug_demarshal_shader_replace(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_shader_replace *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_SHADER_REPLACE)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(8, rbug_context_t, context); /* context */
+       READ(8, rbug_shader_t, shader); /* shader */
+       READ_ARRAY(4, uint32_t, tokens); /* tokens */
+
+       return ret;
+}
+
+struct rbug_proto_shader_list_reply * rbug_demarshal_shader_list_reply(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_shader_list_reply *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_SHADER_LIST_REPLY)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(4, uint32_t, serial); /* serial */
+       READ_ARRAY(8, rbug_shader_t, shaders); /* shaders */
+
+       return ret;
+}
+
+struct rbug_proto_shader_info_reply * rbug_demarshal_shader_info_reply(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_shader_info_reply *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_SHADER_INFO_REPLY)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(4, uint32_t, serial); /* serial */
+       READ_ARRAY(4, uint32_t, original); /* original */
+       READ_ARRAY(4, uint32_t, replaced); /* replaced */
+       READ(1, uint8_t, disabled); /* disabled */
+
+       return ret;
+}
diff --git a/src/gallium/auxiliary/rbug/rbug_shader.h b/src/gallium/auxiliary/rbug/rbug_shader.h
new file mode 100644 (file)
index 0000000..b5d8867
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * This file holds structs decelerations and function prototypes for one of
+ * the rbug extensions. Implementation of the functions is in the same folder
+ * in the c file matching this file's name.
+ *
+ * The structs what is returned from the demarshal functions. The functions
+ * starting rbug_send_* encodes a call to the write format and sends that to
+ * the supplied connection, while functions starting with rbug_demarshal_*
+ * demarshal data from the wire protocol.
+ *
+ * Structs and functions ending with _reply are replies to requests.
+ */
+
+#ifndef _RBUG_PROTO_SHADER_H_
+#define _RBUG_PROTO_SHADER_H_
+
+#include "rbug/rbug_proto.h"
+#include "rbug/rbug_core.h"
+
+struct rbug_proto_shader_list
+{
+       struct rbug_header header;
+       rbug_context_t context;
+};
+
+struct rbug_proto_shader_info
+{
+       struct rbug_header header;
+       rbug_context_t context;
+       rbug_shader_t shader;
+};
+
+struct rbug_proto_shader_disable
+{
+       struct rbug_header header;
+       rbug_context_t context;
+       rbug_shader_t shader;
+       uint8_t disable;
+};
+
+struct rbug_proto_shader_replace
+{
+       struct rbug_header header;
+       rbug_context_t context;
+       rbug_shader_t shader;
+       uint32_t *tokens;
+       uint32_t tokens_len;
+};
+
+struct rbug_proto_shader_list_reply
+{
+       struct rbug_header header;
+       uint32_t serial;
+       rbug_shader_t *shaders;
+       uint32_t shaders_len;
+};
+
+struct rbug_proto_shader_info_reply
+{
+       struct rbug_header header;
+       uint32_t serial;
+       uint32_t *original;
+       uint32_t original_len;
+       uint32_t *replaced;
+       uint32_t replaced_len;
+       uint8_t disabled;
+};
+
+int rbug_send_shader_list(struct rbug_connection *__con,
+                          rbug_context_t context,
+                          uint32_t *__serial);
+
+int rbug_send_shader_info(struct rbug_connection *__con,
+                          rbug_context_t context,
+                          rbug_shader_t shader,
+                          uint32_t *__serial);
+
+int rbug_send_shader_disable(struct rbug_connection *__con,
+                             rbug_context_t context,
+                             rbug_shader_t shader,
+                             uint8_t disable,
+                             uint32_t *__serial);
+
+int rbug_send_shader_replace(struct rbug_connection *__con,
+                             rbug_context_t context,
+                             rbug_shader_t shader,
+                             uint32_t *tokens,
+                             uint32_t tokens_len,
+                             uint32_t *__serial);
+
+int rbug_send_shader_list_reply(struct rbug_connection *__con,
+                                uint32_t serial,
+                                rbug_shader_t *shaders,
+                                uint32_t shaders_len,
+                                uint32_t *__serial);
+
+int rbug_send_shader_info_reply(struct rbug_connection *__con,
+                                uint32_t serial,
+                                uint32_t *original,
+                                uint32_t original_len,
+                                uint32_t *replaced,
+                                uint32_t replaced_len,
+                                uint8_t disabled,
+                                uint32_t *__serial);
+
+struct rbug_proto_shader_list * rbug_demarshal_shader_list(struct rbug_proto_header *header);
+
+struct rbug_proto_shader_info * rbug_demarshal_shader_info(struct rbug_proto_header *header);
+
+struct rbug_proto_shader_disable * rbug_demarshal_shader_disable(struct rbug_proto_header *header);
+
+struct rbug_proto_shader_replace * rbug_demarshal_shader_replace(struct rbug_proto_header *header);
+
+struct rbug_proto_shader_list_reply * rbug_demarshal_shader_list_reply(struct rbug_proto_header *header);
+
+struct rbug_proto_shader_info_reply * rbug_demarshal_shader_info_reply(struct rbug_proto_header *header);
+
+#endif
diff --git a/src/gallium/auxiliary/rbug/rbug_texture.c b/src/gallium/auxiliary/rbug/rbug_texture.c
new file mode 100644 (file)
index 0000000..5a918fe
--- /dev/null
@@ -0,0 +1,631 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * This file holds the function implementation for one of the rbug extensions.
+ * Prototypes and declerations of functions and structs is in the same folder
+ * in the header file matching this file's name.
+ *
+ * The functions starting rbug_send_* encodes a call to the write format and
+ * sends that to the supplied connection, while functions starting with
+ * rbug_demarshal_* demarshal data in the wire protocol.
+ *
+ * Functions ending with _reply are replies to requests.
+ */
+
+#include "rbug_internal.h"
+#include "rbug/rbug_texture.h"
+
+int rbug_send_texture_list(struct rbug_connection *__con,
+                           uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_LIST));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_TEXTURE_LIST, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_texture_info(struct rbug_connection *__con,
+                           rbug_texture_t texture,
+                           uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(8); /* texture */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_INFO));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(8, rbug_texture_t, texture); /* texture */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_TEXTURE_INFO, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_texture_write(struct rbug_connection *__con,
+                            rbug_texture_t texture,
+                            uint32_t face,
+                            uint32_t level,
+                            uint32_t zslice,
+                            uint32_t x,
+                            uint32_t y,
+                            uint32_t w,
+                            uint32_t h,
+                            uint8_t *data,
+                            uint32_t data_len,
+                            uint32_t stride,
+                            uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(8); /* texture */
+       LEN(4); /* face */
+       LEN(4); /* level */
+       LEN(4); /* zslice */
+       LEN(4); /* x */
+       LEN(4); /* y */
+       LEN(4); /* w */
+       LEN(4); /* h */
+       LEN_ARRAY(1, data); /* data */
+       LEN(4); /* stride */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_WRITE));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(8, rbug_texture_t, texture); /* texture */
+       WRITE(4, uint32_t, face); /* face */
+       WRITE(4, uint32_t, level); /* level */
+       WRITE(4, uint32_t, zslice); /* zslice */
+       WRITE(4, uint32_t, x); /* x */
+       WRITE(4, uint32_t, y); /* y */
+       WRITE(4, uint32_t, w); /* w */
+       WRITE(4, uint32_t, h); /* h */
+       WRITE_ARRAY(1, uint8_t, data); /* data */
+       WRITE(4, uint32_t, stride); /* stride */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_TEXTURE_WRITE, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_texture_read(struct rbug_connection *__con,
+                           rbug_texture_t texture,
+                           uint32_t face,
+                           uint32_t level,
+                           uint32_t zslice,
+                           uint32_t x,
+                           uint32_t y,
+                           uint32_t w,
+                           uint32_t h,
+                           uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(8); /* texture */
+       LEN(4); /* face */
+       LEN(4); /* level */
+       LEN(4); /* zslice */
+       LEN(4); /* x */
+       LEN(4); /* y */
+       LEN(4); /* w */
+       LEN(4); /* h */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_READ));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(8, rbug_texture_t, texture); /* texture */
+       WRITE(4, uint32_t, face); /* face */
+       WRITE(4, uint32_t, level); /* level */
+       WRITE(4, uint32_t, zslice); /* zslice */
+       WRITE(4, uint32_t, x); /* x */
+       WRITE(4, uint32_t, y); /* y */
+       WRITE(4, uint32_t, w); /* w */
+       WRITE(4, uint32_t, h); /* h */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_TEXTURE_READ, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_texture_list_reply(struct rbug_connection *__con,
+                                 uint32_t serial,
+                                 rbug_texture_t *textures,
+                                 uint32_t textures_len,
+                                 uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(4); /* serial */
+       LEN_ARRAY(8, textures); /* textures */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_LIST_REPLY));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(4, uint32_t, serial); /* serial */
+       WRITE_ARRAY(8, rbug_texture_t, textures); /* textures */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_TEXTURE_LIST_REPLY, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_texture_info_reply(struct rbug_connection *__con,
+                                 uint32_t serial,
+                                 uint32_t target,
+                                 uint32_t format,
+                                 uint32_t *width,
+                                 uint32_t width_len,
+                                 uint32_t *height,
+                                 uint32_t height_len,
+                                 uint32_t *depth,
+                                 uint32_t depth_len,
+                                 uint32_t blockw,
+                                 uint32_t blockh,
+                                 uint32_t blocksize,
+                                 uint32_t last_level,
+                                 uint32_t nr_samples,
+                                 uint32_t tex_usage,
+                                 uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(4); /* serial */
+       LEN(4); /* target */
+       LEN(4); /* format */
+       LEN_ARRAY(4, width); /* width */
+       LEN_ARRAY(4, height); /* height */
+       LEN_ARRAY(4, depth); /* depth */
+       LEN(4); /* blockw */
+       LEN(4); /* blockh */
+       LEN(4); /* blocksize */
+       LEN(4); /* last_level */
+       LEN(4); /* nr_samples */
+       LEN(4); /* tex_usage */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_INFO_REPLY));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(4, uint32_t, serial); /* serial */
+       WRITE(4, uint32_t, target); /* target */
+       WRITE(4, uint32_t, format); /* format */
+       WRITE_ARRAY(4, uint32_t, width); /* width */
+       WRITE_ARRAY(4, uint32_t, height); /* height */
+       WRITE_ARRAY(4, uint32_t, depth); /* depth */
+       WRITE(4, uint32_t, blockw); /* blockw */
+       WRITE(4, uint32_t, blockh); /* blockh */
+       WRITE(4, uint32_t, blocksize); /* blocksize */
+       WRITE(4, uint32_t, last_level); /* last_level */
+       WRITE(4, uint32_t, nr_samples); /* nr_samples */
+       WRITE(4, uint32_t, tex_usage); /* tex_usage */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_TEXTURE_INFO_REPLY, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+int rbug_send_texture_read_reply(struct rbug_connection *__con,
+                                 uint32_t serial,
+                                 uint32_t format,
+                                 uint32_t blockw,
+                                 uint32_t blockh,
+                                 uint32_t blocksize,
+                                 uint8_t *data,
+                                 uint32_t data_len,
+                                 uint32_t stride,
+                                 uint32_t *__serial)
+{
+       uint32_t __len = 0;
+       uint32_t __pos = 0;
+       uint8_t *__data = NULL;
+       int __ret = 0;
+
+       LEN(8); /* header */
+       LEN(4); /* serial */
+       LEN(4); /* format */
+       LEN(4); /* blockw */
+       LEN(4); /* blockh */
+       LEN(4); /* blocksize */
+       LEN_ARRAY(1, data); /* data */
+       LEN(4); /* stride */
+
+       /* align */
+       PAD(__len, 8);
+
+       __data = (uint8_t*)MALLOC(__len);
+       if (!__data)
+               return -ENOMEM;
+
+       WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_READ_REPLY));
+       WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
+       WRITE(4, uint32_t, serial); /* serial */
+       WRITE(4, uint32_t, format); /* format */
+       WRITE(4, uint32_t, blockw); /* blockw */
+       WRITE(4, uint32_t, blockh); /* blockh */
+       WRITE(4, uint32_t, blocksize); /* blocksize */
+       WRITE_ARRAY(1, uint8_t, data); /* data */
+       WRITE(4, uint32_t, stride); /* stride */
+
+       /* final pad */
+       PAD(__pos, 8);
+
+       if (__pos != __len) {
+               __ret = -EINVAL;
+       } else {
+               rbug_connection_send_start(__con, RBUG_OP_TEXTURE_READ_REPLY, __len);
+               rbug_connection_write(__con, __data, __len);
+               __ret = rbug_connection_send_finish(__con, __serial);
+       }
+
+       FREE(__data);
+       return __ret;
+}
+
+struct rbug_proto_texture_list * rbug_demarshal_texture_list(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_texture_list *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_TEXTURE_LIST)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+
+       return ret;
+}
+
+struct rbug_proto_texture_info * rbug_demarshal_texture_info(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_texture_info *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_TEXTURE_INFO)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(8, rbug_texture_t, texture); /* texture */
+
+       return ret;
+}
+
+struct rbug_proto_texture_write * rbug_demarshal_texture_write(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_texture_write *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_TEXTURE_WRITE)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(8, rbug_texture_t, texture); /* texture */
+       READ(4, uint32_t, face); /* face */
+       READ(4, uint32_t, level); /* level */
+       READ(4, uint32_t, zslice); /* zslice */
+       READ(4, uint32_t, x); /* x */
+       READ(4, uint32_t, y); /* y */
+       READ(4, uint32_t, w); /* w */
+       READ(4, uint32_t, h); /* h */
+       READ_ARRAY(1, uint8_t, data); /* data */
+       READ(4, uint32_t, stride); /* stride */
+
+       return ret;
+}
+
+struct rbug_proto_texture_read * rbug_demarshal_texture_read(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_texture_read *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_TEXTURE_READ)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(8, rbug_texture_t, texture); /* texture */
+       READ(4, uint32_t, face); /* face */
+       READ(4, uint32_t, level); /* level */
+       READ(4, uint32_t, zslice); /* zslice */
+       READ(4, uint32_t, x); /* x */
+       READ(4, uint32_t, y); /* y */
+       READ(4, uint32_t, w); /* w */
+       READ(4, uint32_t, h); /* h */
+
+       return ret;
+}
+
+struct rbug_proto_texture_list_reply * rbug_demarshal_texture_list_reply(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_texture_list_reply *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_TEXTURE_LIST_REPLY)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(4, uint32_t, serial); /* serial */
+       READ_ARRAY(8, rbug_texture_t, textures); /* textures */
+
+       return ret;
+}
+
+struct rbug_proto_texture_info_reply * rbug_demarshal_texture_info_reply(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_texture_info_reply *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_TEXTURE_INFO_REPLY)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(4, uint32_t, serial); /* serial */
+       READ(4, uint32_t, target); /* target */
+       READ(4, uint32_t, format); /* format */
+       READ_ARRAY(4, uint32_t, width); /* width */
+       READ_ARRAY(4, uint32_t, height); /* height */
+       READ_ARRAY(4, uint32_t, depth); /* depth */
+       READ(4, uint32_t, blockw); /* blockw */
+       READ(4, uint32_t, blockh); /* blockh */
+       READ(4, uint32_t, blocksize); /* blocksize */
+       READ(4, uint32_t, last_level); /* last_level */
+       READ(4, uint32_t, nr_samples); /* nr_samples */
+       READ(4, uint32_t, tex_usage); /* tex_usage */
+
+       return ret;
+}
+
+struct rbug_proto_texture_read_reply * rbug_demarshal_texture_read_reply(struct rbug_proto_header *header)
+{
+       uint32_t len = 0;
+       uint32_t pos = 0;
+       uint8_t *data =  NULL;
+       struct rbug_proto_texture_read_reply *ret;
+
+       if (!header)
+               return NULL;
+       if (header->opcode != (int16_t)RBUG_OP_TEXTURE_READ_REPLY)
+               return NULL;
+
+       pos = 0;
+       len = header->length * 4;
+       data = (uint8_t*)&header[1];
+       ret = MALLOC(sizeof(*ret));
+       if (!ret)
+               return NULL;
+
+       ret->header.__message = header;
+       ret->header.opcode = header->opcode;
+
+       READ(4, uint32_t, serial); /* serial */
+       READ(4, uint32_t, format); /* format */
+       READ(4, uint32_t, blockw); /* blockw */
+       READ(4, uint32_t, blockh); /* blockh */
+       READ(4, uint32_t, blocksize); /* blocksize */
+       READ_ARRAY(1, uint8_t, data); /* data */
+       READ(4, uint32_t, stride); /* stride */
+
+       return ret;
+}
diff --git a/src/gallium/auxiliary/rbug/rbug_texture.h b/src/gallium/auxiliary/rbug/rbug_texture.h
new file mode 100644 (file)
index 0000000..fbb247e
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * This file holds structs decelerations and function prototypes for one of
+ * the rbug extensions. Implementation of the functions is in the same folder
+ * in the c file matching this file's name.
+ *
+ * The structs what is returned from the demarshal functions. The functions
+ * starting rbug_send_* encodes a call to the write format and sends that to
+ * the supplied connection, while functions starting with rbug_demarshal_*
+ * demarshal data from the wire protocol.
+ *
+ * Structs and functions ending with _reply are replies to requests.
+ */
+
+#ifndef _RBUG_PROTO_TEXTURE_H_
+#define _RBUG_PROTO_TEXTURE_H_
+
+#include "rbug/rbug_proto.h"
+#include "rbug/rbug_core.h"
+
+struct rbug_proto_texture_list
+{
+       struct rbug_header header;
+};
+
+struct rbug_proto_texture_info
+{
+       struct rbug_header header;
+       rbug_texture_t texture;
+};
+
+struct rbug_proto_texture_write
+{
+       struct rbug_header header;
+       rbug_texture_t texture;
+       uint32_t face;
+       uint32_t level;
+       uint32_t zslice;
+       uint32_t x;
+       uint32_t y;
+       uint32_t w;
+       uint32_t h;
+       uint8_t *data;
+       uint32_t data_len;
+       uint32_t stride;
+};
+
+struct rbug_proto_texture_read
+{
+       struct rbug_header header;
+       rbug_texture_t texture;
+       uint32_t face;
+       uint32_t level;
+       uint32_t zslice;
+       uint32_t x;
+       uint32_t y;
+       uint32_t w;
+       uint32_t h;
+};
+
+struct rbug_proto_texture_list_reply
+{
+       struct rbug_header header;
+       uint32_t serial;
+       rbug_texture_t *textures;
+       uint32_t textures_len;
+};
+
+struct rbug_proto_texture_info_reply
+{
+       struct rbug_header header;
+       uint32_t serial;
+       uint32_t target;
+       uint32_t format;
+       uint32_t *width;
+       uint32_t width_len;
+       uint32_t *height;
+       uint32_t height_len;
+       uint32_t *depth;
+       uint32_t depth_len;
+       uint32_t blockw;
+       uint32_t blockh;
+       uint32_t blocksize;
+       uint32_t last_level;
+       uint32_t nr_samples;
+       uint32_t tex_usage;
+};
+
+struct rbug_proto_texture_read_reply
+{
+       struct rbug_header header;
+       uint32_t serial;
+       uint32_t format;
+       uint32_t blockw;
+       uint32_t blockh;
+       uint32_t blocksize;
+       uint8_t *data;
+       uint32_t data_len;
+       uint32_t stride;
+};
+
+int rbug_send_texture_list(struct rbug_connection *__con,
+                           uint32_t *__serial);
+
+int rbug_send_texture_info(struct rbug_connection *__con,
+                           rbug_texture_t texture,
+                           uint32_t *__serial);
+
+int rbug_send_texture_write(struct rbug_connection *__con,
+                            rbug_texture_t texture,
+                            uint32_t face,
+                            uint32_t level,
+                            uint32_t zslice,
+                            uint32_t x,
+                            uint32_t y,
+                            uint32_t w,
+                            uint32_t h,
+                            uint8_t *data,
+                            uint32_t data_len,
+                            uint32_t stride,
+                            uint32_t *__serial);
+
+int rbug_send_texture_read(struct rbug_connection *__con,
+                           rbug_texture_t texture,
+                           uint32_t face,
+                           uint32_t level,
+                           uint32_t zslice,
+                           uint32_t x,
+                           uint32_t y,
+                           uint32_t w,
+                           uint32_t h,
+                           uint32_t *__serial);
+
+int rbug_send_texture_list_reply(struct rbug_connection *__con,
+                                 uint32_t serial,
+                                 rbug_texture_t *textures,
+                                 uint32_t textures_len,
+                                 uint32_t *__serial);
+
+int rbug_send_texture_info_reply(struct rbug_connection *__con,
+                                 uint32_t serial,
+                                 uint32_t target,
+                                 uint32_t format,
+                                 uint32_t *width,
+                                 uint32_t width_len,
+                                 uint32_t *height,
+                                 uint32_t height_len,
+                                 uint32_t *depth,
+                                 uint32_t depth_len,
+                                 uint32_t blockw,
+                                 uint32_t blockh,
+                                 uint32_t blocksize,
+                                 uint32_t last_level,
+                                 uint32_t nr_samples,
+                                 uint32_t tex_usage,
+                                 uint32_t *__serial);
+
+int rbug_send_texture_read_reply(struct rbug_connection *__con,
+                                 uint32_t serial,
+                                 uint32_t format,
+                                 uint32_t blockw,
+                                 uint32_t blockh,
+                                 uint32_t blocksize,
+                                 uint8_t *data,
+                                 uint32_t data_len,
+                                 uint32_t stride,
+                                 uint32_t *__serial);
+
+struct rbug_proto_texture_list * rbug_demarshal_texture_list(struct rbug_proto_header *header);
+
+struct rbug_proto_texture_info * rbug_demarshal_texture_info(struct rbug_proto_header *header);
+
+struct rbug_proto_texture_write * rbug_demarshal_texture_write(struct rbug_proto_header *header);
+
+struct rbug_proto_texture_read * rbug_demarshal_texture_read(struct rbug_proto_header *header);
+
+struct rbug_proto_texture_list_reply * rbug_demarshal_texture_list_reply(struct rbug_proto_header *header);
+
+struct rbug_proto_texture_info_reply * rbug_demarshal_texture_info_reply(struct rbug_proto_header *header);
+
+struct rbug_proto_texture_read_reply * rbug_demarshal_texture_read_reply(struct rbug_proto_header *header);
+
+#endif
diff --git a/src/gallium/auxiliary/trace/trace_drm.h b/src/gallium/auxiliary/trace/trace_drm.h
new file mode 100644 (file)
index 0000000..892bd98
--- /dev/null
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2009 Jakob Bornecrantz <jakob@vmware.com>
+ *                Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * 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 AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#ifndef TRACE_DRM_H
+#define TRACE_DRM_H
+
+#include "state_tracker/drm_api.h"
+
+#include "trace/tr_buffer.h"
+#include "trace/tr_context.h"
+#include "trace/tr_screen.h"
+#include "trace/tr_texture.h"
+
+struct drm_api hooks;
+
+static struct pipe_screen *
+trace_drm_create_screen(int fd, struct drm_create_screen_arg *arg)
+{
+       struct pipe_screen *screen;
+
+       if (arg && arg->mode != DRM_CREATE_NORMAL)
+               return NULL;
+
+       screen = hooks.create_screen(fd, arg);
+
+       return trace_screen_create(screen);
+};
+
+static struct pipe_context *
+trace_drm_create_context(struct pipe_screen *_screen)
+{
+       struct pipe_screen *screen;
+       struct pipe_context *pipe;
+
+       if (trace_enabled())
+               screen = trace_screen(_screen)->screen;
+       else
+               screen = _screen;
+
+       pipe = hooks.create_context(screen);
+
+       if (trace_enabled())
+               pipe = trace_context_create(_screen, pipe);
+
+       return pipe;
+};
+
+static boolean
+trace_drm_buffer_from_texture(struct pipe_texture *_texture,
+                              struct pipe_buffer **_buffer,
+                              unsigned *stride)
+{
+       struct pipe_texture *texture;
+       struct pipe_buffer *buffer = NULL;
+       boolean result;
+
+       if (trace_enabled())
+               texture = trace_texture(_texture)->texture;
+       else
+               texture = _texture;
+
+       result = hooks.buffer_from_texture(texture, &buffer, stride);
+
+       if (result && _buffer)
+               buffer = trace_buffer_create(trace_screen(texture->screen), buffer);
+
+       if (_buffer)
+               *_buffer = buffer;
+       else
+               pipe_buffer_reference(&buffer, NULL);
+
+       return result;
+}
+
+static struct pipe_buffer *
+trace_drm_buffer_from_handle(struct pipe_screen *_screen,
+                             const char *name,
+                             unsigned handle)
+{
+       struct pipe_screen *screen;
+       struct pipe_buffer *result;
+
+       if (trace_enabled())
+               screen = trace_screen(_screen)->screen;
+       else
+               screen = _screen;
+
+       result = hooks.buffer_from_handle(screen, name, handle);
+
+       if (trace_enabled())
+               result = trace_buffer_create(trace_screen(_screen), result);
+
+       return result;
+}
+
+static boolean
+trace_drm_handle_from_buffer(struct pipe_screen *_screen,
+                             struct pipe_buffer *_buffer,
+                             unsigned *handle)
+{
+       struct pipe_screen *screen;
+       struct pipe_buffer *buffer;
+
+       if (trace_enabled()) {
+               screen = trace_screen(_screen)->screen;
+               buffer = trace_buffer(_buffer)->buffer;
+       } else {
+               screen = _screen;
+               buffer = _buffer;
+       }
+
+       return hooks.handle_from_buffer(screen, buffer, handle);
+}
+
+static boolean
+trace_drm_global_handle_from_buffer(struct pipe_screen *_screen,
+                                    struct pipe_buffer *_buffer,
+                                    unsigned *handle)
+{
+       struct pipe_screen *screen;
+       struct pipe_buffer *buffer;
+
+       if (trace_enabled()) {
+               screen = trace_screen(_screen)->screen;
+               buffer = trace_buffer(_buffer)->buffer;
+       } else {
+               screen = _screen;
+               buffer = _buffer;
+       }
+
+       return hooks.global_handle_from_buffer(screen, buffer, handle);
+}
+
+struct drm_api drm_api_hooks =
+{
+       .create_screen = trace_drm_create_screen,
+       .create_context = trace_drm_create_context,
+
+       .buffer_from_texture = trace_drm_buffer_from_texture,
+       .buffer_from_handle = trace_drm_buffer_from_handle,
+       .handle_from_buffer = trace_drm_handle_from_buffer,
+       .global_handle_from_buffer = trace_drm_global_handle_from_buffer,
+};
+
+#endif /* TRACE_DRM_H */
index 2995aba1b91711b0068b4637c9677fdd2b65a005..6a8eb73e84a34bb61e36163f0f5b718b3d817b8d 100644 (file)
@@ -16,6 +16,7 @@ C_SOURCES = \
        u_hash.c \
        u_keymap.c \
        u_linear.c \
+       u_network.c \
        u_math.c \
        u_mm.c \
        u_rect.c \
index d3ac7f747fd71ab93c63336be96329133b5c97d8..fb142eebca8e42a79b71a2d56fa5f80f1a30b27b 100644 (file)
@@ -17,6 +17,7 @@ util = env.ConvenienceLibrary(
                'u_hash.c',
                'u_hash_table.c',
                'u_keymap.c',
+               'u_network.c',
                'u_math.c',
                'u_mm.c',
                'u_rect.c',
diff --git a/src/gallium/auxiliary/util/u_network.c b/src/gallium/auxiliary/util/u_network.c
new file mode 100644 (file)
index 0000000..07d804e
--- /dev/null
@@ -0,0 +1,188 @@
+
+#include "pipe/p_compiler.h"
+#include "util/u_network.h"
+#include "util/u_debug.h"
+
+#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+#  include <winsock2.h>
+#  include <windows.h>
+#elif defined(PIPE_OS_LINUX)
+#  include <sys/socket.h>
+#  include <netinet/in.h>
+#  include <unistd.h>
+#  include <fcntl.h>
+#  include <netdb.h>
+#else
+#  warning "No socket implementation"
+#endif
+
+boolean
+u_socket_init()
+{
+#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+   WORD wVersionRequested;
+   WSADATA wsaData;
+   int err;
+
+   /* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */
+   wVersionRequested = MAKEWORD(1, 1);
+
+   err = WSAStartup(wVersionRequested, &wsaData);
+   if (err != 0) {
+      debug_printf("WSAStartup failed with error: %d\n", err);
+      return FALSE;
+   }
+   return TRUE;
+#elif defined(PIPE_HAVE_SOCKETS)
+   return TRUE;
+#else
+   return FALSE;
+#endif
+}
+
+void
+u_socket_stop()
+{
+#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+   WSACleanup();
+#endif
+}
+
+void
+u_socket_close(int s)
+{
+   if (s < 0)
+      return;
+
+#if defined(PIPE_OS_LINUX)
+   shutdown(s, SHUT_RDWR);
+   close(s);
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+   shutdown(s, SD_BOTH);
+   closesocket(s);
+#else
+   assert(0);
+#endif
+}
+
+int u_socket_accept(int s)
+{
+#if defined(PIPE_HAVE_SOCKETS)
+   return accept(s, NULL, NULL);
+#else
+   return -1;
+#endif
+}
+
+int
+u_socket_send(int s, void *data, size_t size)
+{
+#if defined(PIPE_HAVE_SOCKETS)
+   return send(s, data, size, 0);
+#else
+   return -1;
+#endif
+}
+
+int
+u_socket_peek(int s, void *data, size_t size)
+{
+#if defined(PIPE_HAVE_SOCKETS)
+   return recv(s, data, size, MSG_PEEK);
+#else
+   return -1;
+#endif
+}
+
+int
+u_socket_recv(int s, void *data, size_t size)
+{
+#if defined(PIPE_HAVE_SOCKETS)
+   return recv(s, data, size, 0);
+#else
+   return -1;
+#endif
+}
+
+int
+u_socket_connect(const char *hostname, uint16_t port)
+{
+#if defined(PIPE_HAVE_SOCKETS)
+   int s;
+   struct sockaddr_in sa;
+   struct hostent *host = NULL;
+
+   memset(&sa, 0, sizeof(struct sockaddr_in));
+   host = gethostbyname(hostname);
+   if (!host)
+      return -1;
+
+   memcpy((char *)&sa.sin_addr,host->h_addr,host->h_length);
+   sa.sin_family= host->h_addrtype;
+   sa.sin_port = htons(port);
+
+   s = socket(host->h_addrtype, SOCK_STREAM, IPPROTO_TCP);
+   if (s < 0)
+      return -1;
+
+   if (connect(s, (struct sockaddr *)&sa, sizeof(sa))) {
+      u_socket_close(s);
+      return -1;
+   }
+
+   return s;
+#else
+   assert(0);
+   return -1;
+#endif
+}
+
+int
+u_socket_listen_on_port(uint16_t portnum)
+{
+#if defined(PIPE_HAVE_SOCKETS)
+   int s;
+   struct sockaddr_in sa;
+   memset(&sa, 0, sizeof(struct sockaddr_in));
+
+   sa.sin_family = AF_INET;
+   sa.sin_port = htons(portnum);
+
+   s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+   if (s < 0)
+      return -1;
+
+   if (bind(s, (struct sockaddr *)&sa, sizeof(struct sockaddr_in)) == -1) {
+      u_socket_close(s);
+      return -1;
+   }
+
+   listen(s, 0);
+
+   return s;
+#else
+   assert(0);
+   return -1;
+#endif
+}
+
+void
+u_socket_block(int s, boolean block)
+{
+#if defined(PIPE_OS_LINUX)
+   int old = fcntl(s, F_GETFL, 0);
+   if (old == -1)
+      return;
+
+   /* TODO obey block */
+   if (block)
+      fcntl(s, F_SETFL, old & ~O_NONBLOCK);
+   else
+      fcntl(s, F_SETFL, old | O_NONBLOCK);
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+   u_long iMode = block ? 0 : 1;
+   ioctlsocket(s, FIONBIO, &iMode);
+#else
+   assert(0);
+#endif
+}
diff --git a/src/gallium/auxiliary/util/u_network.h b/src/gallium/auxiliary/util/u_network.h
new file mode 100644 (file)
index 0000000..14d3884
--- /dev/null
@@ -0,0 +1,24 @@
+
+#ifndef _U_NETWORK_H_
+#define _U_NETWORK_H_
+
+#include "pipe/p_compiler.h"
+
+#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+#  define PIPE_HAVE_SOCKETS
+#elif defined(PIPE_OS_LINUX)
+#  define PIPE_HAVE_SOCKETS
+#endif
+
+boolean u_socket_init(void);
+void u_socket_stop(void);
+void u_socket_close(int s);
+int u_socket_listen_on_port(uint16_t portnum);
+int u_socket_accept(int s);
+int u_socket_connect(const char *host, uint16_t port);
+int u_socket_send(int s, void *data, size_t size);
+int u_socket_peek(int s, void *data, size_t size);
+int u_socket_recv(int s, void *data, size_t size);
+void u_socket_block(int s, boolean block);
+
+#endif
index 7c225e2f27cdab9bee1f69ff6330f962e81a0e60..5ffb7073abf155c80ab87219cbfd99846f112a37 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "spu_main.h"
 #include "spu_render.h"
+#include "spu_shuffle.h"
 #include "spu_tri.h"
 #include "spu_tile.h"
 #include "cell/common.h"
@@ -267,15 +268,75 @@ cmd_render(const struct cell_command_render *render, uint *pos_incr)
 
       uint drawn = 0;
 
-      /* loop over tris */
-      for (j = 0; j < render->num_indexes; j += 3) {
-         const float *v0, *v1, *v2;
-
-         v0 = (const float *) (vertices + indexes[j+0] * vertex_size);
-         v1 = (const float *) (vertices + indexes[j+1] * vertex_size);
-         v2 = (const float *) (vertices + indexes[j+2] * vertex_size);
-
-         drawn += tri_draw(v0, v1, v2, tx, ty);
+      const qword vertex_sizes = (qword)spu_splats(vertex_size);
+      const qword verticess = (qword)spu_splats((uint)vertices);
+
+      ASSERT_ALIGN16(&indexes[0]);
+
+      const uint num_indexes = render->num_indexes;
+
+      /* loop over tris
+          * &indexes[0] will be 16 byte aligned.  This loop is heavily unrolled
+          * avoiding variable rotates when extracting vertex indices.
+          */
+      for (j = 0; j < num_indexes; j += 24) {
+         /* Load three vectors, containing 24 ushort indices */
+         const qword* lower_qword = (qword*)&indexes[j];
+         const qword indices0 = lower_qword[0];
+         const qword indices1 = lower_qword[1];
+         const qword indices2 = lower_qword[2];
+
+         /* stores three indices for each tri n in slots 0, 1 and 2 of vsn */
+                /* Straightforward rotates for these */
+         qword vs0 = indices0;
+         qword vs1 = si_shlqbyi(indices0, 6);
+         qword vs3 = si_shlqbyi(indices1, 2);
+         qword vs4 = si_shlqbyi(indices1, 8);
+         qword vs6 = si_shlqbyi(indices2, 4);
+         qword vs7 = si_shlqbyi(indices2, 10);
+
+         /* For tri 2 and 5, the three indices are split across two machine
+                 * words - rotate and combine */
+         const qword tmp2a = si_shlqbyi(indices0, 12);
+         const qword tmp2b = si_rotqmbyi(indices1, 12|16);
+         qword vs2 = si_selb(tmp2a, tmp2b, si_fsmh(si_from_uint(0x20)));
+
+         const qword tmp5a = si_shlqbyi(indices1, 14);
+         const qword tmp5b = si_rotqmbyi(indices2, 14|16);
+         qword vs5 = si_selb(tmp5a, tmp5b, si_fsmh(si_from_uint(0x60)));
+
+         /* unpack indices from halfword slots to word slots */
+         vs0 = si_shufb(vs0, vs0, SHUFB8(0,A,0,B,0,C,0,0));
+         vs1 = si_shufb(vs1, vs1, SHUFB8(0,A,0,B,0,C,0,0));
+         vs2 = si_shufb(vs2, vs2, SHUFB8(0,A,0,B,0,C,0,0));
+         vs3 = si_shufb(vs3, vs3, SHUFB8(0,A,0,B,0,C,0,0));
+         vs4 = si_shufb(vs4, vs4, SHUFB8(0,A,0,B,0,C,0,0));
+         vs5 = si_shufb(vs5, vs5, SHUFB8(0,A,0,B,0,C,0,0));
+         vs6 = si_shufb(vs6, vs6, SHUFB8(0,A,0,B,0,C,0,0));
+         vs7 = si_shufb(vs7, vs7, SHUFB8(0,A,0,B,0,C,0,0));
+
+         /* Calculate address of vertex in vertices[] */
+         vs0 = si_mpya(vs0, vertex_sizes, verticess);
+         vs1 = si_mpya(vs1, vertex_sizes, verticess);
+         vs2 = si_mpya(vs2, vertex_sizes, verticess);
+         vs3 = si_mpya(vs3, vertex_sizes, verticess);
+         vs4 = si_mpya(vs4, vertex_sizes, verticess);
+         vs5 = si_mpya(vs5, vertex_sizes, verticess);
+         vs6 = si_mpya(vs6, vertex_sizes, verticess);
+         vs7 = si_mpya(vs7, vertex_sizes, verticess);
+
+         /* Select the appropriate call based on the number of vertices 
+                 * remaining */
+         switch(num_indexes - j) {
+            default: drawn += tri_draw(vs7, tx, ty);
+            case 21: drawn += tri_draw(vs6, tx, ty);
+            case 18: drawn += tri_draw(vs5, tx, ty);
+            case 15: drawn += tri_draw(vs4, tx, ty);
+            case 12: drawn += tri_draw(vs3, tx, ty);
+            case 9:  drawn += tri_draw(vs2, tx, ty);
+            case 6:  drawn += tri_draw(vs1, tx, ty);
+            case 3:  drawn += tri_draw(vs0, tx, ty);
+         }
       }
 
       //printf("SPU %u: drew %u of %u\n", spu.init.id, drawn, render->num_indexes/3);
index d727268475e2a1a18a143cb89b23681e6d3afa56..58be001be4cf32c2131b1cae686d0374c81d471e 100644 (file)
@@ -133,7 +133,15 @@ struct setup_stage {
 
    uint tx, ty;  /**< position of current tile (x, y) */
 
-   int cliprect_minx, cliprect_maxx, cliprect_miny, cliprect_maxy;
+   union {
+      struct {
+         int cliprect_minx;
+         int cliprect_miny;
+         int cliprect_maxx;
+         int cliprect_maxy;
+      };
+      qword cliprect;
+   };
 
    struct interp_coef coef[PIPE_MAX_SHADER_INPUTS];
 
@@ -432,6 +440,41 @@ print_vertex(const struct vertex_header *v)
 }
 #endif
 
+/* Returns the minimum of each slot of two vec_float4s as qwords.
+ * i.e. return[n] = min(q0[n],q1[n]);
+ */
+static qword
+minfq(qword q0, qword q1)
+{
+   const qword q0q1m = si_fcgt(q0, q1);
+   return si_selb(q0, q1, q0q1m);
+}
+
+/* Returns the minimum of each slot of three vec_float4s as qwords.
+ * i.e. return[n] = min(q0[n],q1[n],q2[n]);
+ */
+static qword
+min3fq(qword q0, qword q1, qword q2)
+{
+   return minfq(minfq(q0, q1), q2);
+}
+
+/* Returns the maximum of each slot of two vec_float4s as qwords.
+ * i.e. return[n] = min(q0[n],q1[n],q2[n]);
+ */
+static qword
+maxfq(qword q0, qword q1) {
+   const qword q0q1m = si_fcgt(q0, q1);
+   return si_selb(q1, q0, q0q1m);
+}
+
+/* Returns the maximum of each slot of three vec_float4s as qwords.
+ * i.e. return[n] = min(q0[n],q1[n],q2[n]);
+ */
+static qword
+max3fq(qword q0, qword q1, qword q2) {
+   return maxfq(maxfq(q0, q1), q2);
+}
 
 /**
  * Sort vertices from top to bottom.
@@ -440,9 +483,7 @@ print_vertex(const struct vertex_header *v)
  * \return  FALSE if tri is totally outside tile, TRUE otherwise
  */
 static boolean
-setup_sort_vertices(const struct vertex_header *v0,
-                    const struct vertex_header *v1,
-                    const struct vertex_header *v2)
+setup_sort_vertices(const qword vs)
 {
    float area, sign;
 
@@ -455,57 +496,57 @@ setup_sort_vertices(const struct vertex_header *v0,
    }
 #endif
 
-   /* determine bottom to top order of vertices */
    {
+      /* Load the float values for various processing... */
+      const qword f0 = (qword)(((const struct vertex_header*)si_to_ptr(vs))->data[0]);
+      const qword f1 = (qword)(((const struct vertex_header*)si_to_ptr(si_rotqbyi(vs, 4)))->data[0]);
+      const qword f2 = (qword)(((const struct vertex_header*)si_to_ptr(si_rotqbyi(vs, 8)))->data[0]);
+
+      /* Check if triangle is completely outside the tile bounds
+       * Find the min and max x and y positions of the three poits */
+      const qword minf = min3fq(f0, f1, f2);
+      const qword maxf = max3fq(f0, f1, f2);
+
+      /* Compare min and max against cliprect vals */
+      const qword maxsmins = si_shufb(maxf, minf, SHUFB4(A,B,a,b));
+      const qword outside = si_fcgt(maxsmins, si_csflt(setup.cliprect, 0));
+
+      /* Use a little magic to work out of the tri is visible or not */
+      if(si_to_uint(si_xori(si_gb(outside), 0xc))) return FALSE;
+
+      /* determine bottom to top order of vertices */
       /* A table of shuffle patterns for putting vertex_header pointers into
          correct order.  Quite magical. */
-      const vec_uchar16 sort_order_patterns[] = {
-         SHUFFLE4(A,B,C,C),
-         SHUFFLE4(C,A,B,C),
-         SHUFFLE4(A,C,B,C),
-         SHUFFLE4(B,C,A,C),
-         SHUFFLE4(B,A,C,C),
-         SHUFFLE4(C,B,A,C) };
-
-      /* The vertex_header pointers, packed for easy shuffling later */
-      const vec_uint4 vs = {(unsigned)v0, (unsigned)v1, (unsigned)v2};
+      const qword sort_order_patterns[] = {
+         SHUFB4(A,B,C,C),
+         SHUFB4(C,A,B,C),
+         SHUFB4(A,C,B,C),
+         SHUFB4(B,C,A,C),
+         SHUFB4(B,A,C,C),
+         SHUFB4(C,B,A,C) };
 
       /* Collate y values into two vectors for comparison.
          Using only one shuffle constant! ;) */
-      const vec_float4 y_02_ = spu_shuffle(v0->data[0], v2->data[0], SHUFFLE4(0,B,b,C));
-      const vec_float4 y_10_ = spu_shuffle(v1->data[0], v0->data[0], SHUFFLE4(0,B,b,C));
-      const vec_float4 y_012 = spu_shuffle(y_02_, v1->data[0], SHUFFLE4(0,B,b,C));
-      const vec_float4 y_120 = spu_shuffle(y_10_, v2->data[0], SHUFFLE4(0,B,b,C));
+      const qword y_02_ = si_shufb(f0, f2, SHUFB4(0,B,b,C));
+      const qword y_10_ = si_shufb(f1, f0, SHUFB4(0,B,b,C));
+      const qword y_012 = si_shufb(y_02_, f1, SHUFB4(0,B,b,C));
+      const qword y_120 = si_shufb(y_10_, f2, SHUFB4(0,B,b,C));
 
       /* Perform comparison: {y0,y1,y2} > {y1,y2,y0} */
-      const vec_uint4 compare = spu_cmpgt(y_012, y_120);
+      const qword compare = si_fcgt(y_012, y_120);
       /* Compress the result of the comparison into 4 bits */
-      const vec_uint4 gather = spu_gather(compare);
+      const qword gather = si_gb(compare);
       /* Subtract one to attain the index into the LUT.  Magical. */
-      const unsigned int index = spu_extract(gather, 0) - 1;
+      const unsigned int index = si_to_uint(gather) - 1;
 
       /* Load the appropriate pattern and construct the desired vector. */
-      setup.vertex_headers = (qword)spu_shuffle(vs, vs, sort_order_patterns[index]);
+      setup.vertex_headers = si_shufb(vs, vs, sort_order_patterns[index]);
 
       /* Using the result of the comparison, set sign.
          Very magical. */
-      sign = ((si_to_uint(si_cntb((qword)gather)) == 2) ? 1.0f : -1.0f);
+      sign = ((si_to_uint(si_cntb(gather)) == 2) ? 1.0f : -1.0f);
    }
 
-   /* Check if triangle is completely outside the tile bounds */
-   if (spu_extract(setup.vmin->data[0], 1) > setup.cliprect_maxy)
-      return FALSE;
-   if (spu_extract(setup.vmax->data[0], 1) < setup.cliprect_miny)
-      return FALSE;
-   if (spu_extract(setup.vmin->data[0], 0) < setup.cliprect_minx &&
-       spu_extract(setup.vmid->data[0], 0) < setup.cliprect_minx &&
-       spu_extract(setup.vmax->data[0], 0) < setup.cliprect_minx)
-      return FALSE;
-   if (spu_extract(setup.vmin->data[0], 0) > setup.cliprect_maxx &&
-       spu_extract(setup.vmid->data[0], 0) > setup.cliprect_maxx &&
-       spu_extract(setup.vmax->data[0], 0) > setup.cliprect_maxx)
-      return FALSE;
-
    setup.ebot.ds = spu_sub(setup.vmid->data[0], setup.vmin->data[0]);
    setup.emaj.ds = spu_sub(setup.vmax->data[0], setup.vmin->data[0]);
    setup.etop.ds = spu_sub(setup.vmax->data[0], setup.vmid->data[0]);
@@ -761,21 +802,19 @@ subtriangle(struct edge *eleft, struct edge *eright, unsigned lines)
  * The tile data should have already been fetched.
  */
 boolean
-tri_draw(const float *v0, const float *v1, const float *v2,
+tri_draw(const qword vs,
          uint tx, uint ty)
 {
    setup.tx = tx;
    setup.ty = ty;
 
    /* set clipping bounds to tile bounds */
-   setup.cliprect_minx = tx * TILE_SIZE;
-   setup.cliprect_miny = ty * TILE_SIZE;
-   setup.cliprect_maxx = (tx + 1) * TILE_SIZE;
-   setup.cliprect_maxy = (ty + 1) * TILE_SIZE;
-
-   if (!setup_sort_vertices((struct vertex_header *) v0,
-                            (struct vertex_header *) v1,
-                            (struct vertex_header *) v2)) {
+   const qword clipbase = (qword)((vec_uint4){tx, ty});
+   const qword clipmin = si_mpyui(clipbase, TILE_SIZE);
+   const qword clipmax = si_ai(clipmin, TILE_SIZE);
+   setup.cliprect = si_shufb(clipmin, clipmax, SHUFB4(A,B,a,b));
+
+   if(!setup_sort_vertices(vs)) {
       return FALSE; /* totally clipped */
    }
 
index aa694dd7c934f975b7842631b637a36c119f8535..82e3b19ad7e9fe1cdd30ac84080473977971d195 100644 (file)
@@ -31,7 +31,7 @@
 
 
 extern boolean
-tri_draw(const float *v0, const float *v1, const float *v2, uint tx, uint ty);
+tri_draw(const qword vs, uint tx, uint ty);
 
 
 #endif /* SPU_TRI_H */
diff --git a/src/gallium/drivers/nouveau/Makefile b/src/gallium/drivers/nouveau/Makefile
new file mode 100644 (file)
index 0000000..dbe8a6e
--- /dev/null
@@ -0,0 +1,8 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = nouveau
+
+C_SOURCES = nouveau_screen.c
+
+include ../../Makefile.template
index 54ef1c1291e27156f70a712e3c77fe40eb8b4da1..9c235080a55a585a022373d6581919bf06251a34 100644 (file)
@@ -9,13 +9,13 @@
 
 #define OUT_RING(data) do {                                                    \
        NOUVEAU_PUSH_CONTEXT(pc);                                              \
-       (*pc->nvws->channel->pushbuf->cur++) = (data);                         \
+       (*pc->base.channel->pushbuf->cur++) = (data);                          \
 } while(0)
 
 #define OUT_RINGp(src,size) do {                                               \
        NOUVEAU_PUSH_CONTEXT(pc);                                              \
-       memcpy(pc->nvws->channel->pushbuf->cur, (src), (size) * 4);            \
-       pc->nvws->channel->pushbuf->cur += (size);                             \
+       memcpy(pc->base.channel->pushbuf->cur, (src), (size) * 4);             \
+       pc->base.channel->pushbuf->cur += (size);                              \
 } while(0)
 
 #define OUT_RINGf(data) do {                                                   \
 
 #define BEGIN_RING(obj,mthd,size) do {                                         \
        NOUVEAU_PUSH_CONTEXT(pc);                                              \
-       if (pc->nvws->channel->pushbuf->remaining < ((size) + 1))              \
-               pc->nvws->push_flush(pc->nvws, ((size) + 1), NULL);            \
+       struct nouveau_channel *chan = pc->base.channel;                       \
+       if (chan->pushbuf->remaining < ((size) + 1))                           \
+               nouveau_pushbuf_flush(chan, ((size) + 1));                     \
        OUT_RING((pc->obj->subc << 13) | ((size) << 18) | (mthd));             \
-       pc->nvws->channel->pushbuf->remaining -= ((size) + 1);                 \
+       chan->pushbuf->remaining -= ((size) + 1);                              \
 } while(0)
 
 #define BEGIN_RING_NI(obj,mthd,size) do {                                      \
        BEGIN_RING(obj, (mthd) | 0x40000000, (size));                          \
 } while(0)
 
+static inline void
+DO_FIRE_RING(struct nouveau_channel *chan, struct pipe_fence_handle **fence)
+{
+       nouveau_pushbuf_flush(chan, 0);
+       if (fence)
+               *fence = NULL;
+}
+
 #define FIRE_RING(fence) do {                                                  \
        NOUVEAU_PUSH_CONTEXT(pc);                                              \
-       pc->nvws->push_flush(pc->nvws, 0, fence);                              \
+       DO_FIRE_RING(pc->base.channel, fence);                                 \
 } while(0)
 
 #define OUT_RELOC(bo,data,flags,vor,tor) do {                                  \
        NOUVEAU_PUSH_CONTEXT(pc);                                              \
-       pc->nvws->push_reloc(pc->nvws, pc->nvws->channel->pushbuf->cur++,      \
-                            (bo), (data), (flags), (vor), (tor));             \
+       struct nouveau_channel *chan = pc->base.channel;                       \
+       nouveau_pushbuf_emit_reloc(chan, chan->pushbuf->cur++, nouveau_bo(bo), \
+                                  (data), 0, (flags), (vor), (tor));          \
 } while(0)
 
 /* Raw data + flags depending on FB/TT buffer */
@@ -55,8 +65,8 @@
 /* FB/TT object handle */
 #define OUT_RELOCo(bo,flags) do {                                              \
        OUT_RELOC((bo), 0, (flags) | NOUVEAU_BO_OR,                            \
-                 pc->nvws->channel->vram->handle,                             \
-                 pc->nvws->channel->gart->handle);                            \
+                 pc->base.channel->vram->handle,                              \
+                 pc->base.channel->gart->handle);                             \
 } while(0)
 
 /* Low 32-bits of offset */
 /* A reloc which'll recombine into a NV_DMA_METHOD packet header */
 #define OUT_RELOCm(bo, flags, obj, mthd, size) do {                            \
        NOUVEAU_PUSH_CONTEXT(pc);                                              \
-       if (pc->nvws->channel->pushbuf->remaining < ((size) + 1))              \
-               pc->nvws->push_flush(pc->nvws->channel, ((size) + 1), NULL);   \
+       struct nouveau_channel *chan = pc->base.channel;                       \
+       if (chan->pushbuf->remaining < ((size) + 1))                           \
+               nouveau_pushbuf_flush(chan, ((size) + 1));                     \
        OUT_RELOCd((bo), (pc->obj->subc << 13) | ((size) << 18) | (mthd),      \
                   (flags), 0, 0);                                             \
-       pc->nvws->channel->pushbuf->remaining -= ((size) + 1);                 \
+       chan->pushbuf->remaining -= ((size) + 1);                              \
 } while(0)
 
 #endif
diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c
new file mode 100644 (file)
index 0000000..832366e
--- /dev/null
@@ -0,0 +1,240 @@
+#include <pipe/p_defines.h>
+#include <pipe/p_screen.h>
+#include <pipe/p_state.h>
+
+#include <util/u_memory.h>
+
+#include "nouveau/nouveau_bo.h"
+#include "nouveau_winsys.h"
+#include "nouveau_screen.h"
+
+static const char *
+nouveau_screen_get_name(struct pipe_screen *pscreen)
+{
+       struct nouveau_device *dev = nouveau_screen(pscreen)->device;
+       static char buffer[128];
+
+       snprintf(buffer, sizeof(buffer), "NV%02X", dev->chipset);
+       return buffer;
+}
+
+static const char *
+nouveau_screen_get_vendor(struct pipe_screen *pscreen)
+{
+       return "nouveau";
+}
+
+static struct pipe_buffer *
+nouveau_screen_bo_skel(struct pipe_screen *pscreen, struct nouveau_bo *bo,
+                      unsigned alignment, unsigned usage, unsigned size)
+{
+       struct pipe_buffer *pb;
+       
+       pb = CALLOC(1, sizeof(struct pipe_buffer)+sizeof(struct nouveau_bo *));
+       if (!pb) {
+               nouveau_bo_ref(NULL, &bo);
+               return NULL;
+       }
+
+       pipe_reference_init(&pb->reference, 1);
+       pb->screen = pscreen;
+       pb->alignment = alignment;
+       pb->usage = usage;
+       pb->size = size;
+       *(struct nouveau_bo **)(pb + 1) = bo;
+       return pb;
+}
+
+static struct pipe_buffer *
+nouveau_screen_bo_new(struct pipe_screen *pscreen, unsigned alignment,
+                     unsigned usage, unsigned size)
+{
+       struct nouveau_device *dev = nouveau_screen(pscreen)->device;
+       struct nouveau_bo *bo = NULL;
+       uint32_t flags = NOUVEAU_BO_MAP;
+       int ret;
+
+       if (usage & NOUVEAU_BUFFER_USAGE_TRANSFER)
+               flags |= NOUVEAU_BO_GART;
+       else
+       if (usage & PIPE_BUFFER_USAGE_VERTEX) {
+               if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_VTXBUF))
+                       flags |= NOUVEAU_BO_GART;
+       } else
+       if (usage & PIPE_BUFFER_USAGE_INDEX) {
+               if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_IDXBUF))
+                       flags |= NOUVEAU_BO_GART;
+       }
+
+       if (usage & PIPE_BUFFER_USAGE_PIXEL) {
+               if (usage & NOUVEAU_BUFFER_USAGE_TEXTURE)
+                       flags |= NOUVEAU_BO_GART;
+               if (!(usage & PIPE_BUFFER_USAGE_CPU_READ_WRITE))
+                       flags |= NOUVEAU_BO_VRAM;
+
+               if (dev->chipset == 0x50 || dev->chipset >= 0x80) {
+                       flags |= NOUVEAU_BO_TILED;
+                       if (usage & NOUVEAU_BUFFER_USAGE_ZETA)
+                               flags |= NOUVEAU_BO_ZTILE;
+               }
+       }
+
+       ret = nouveau_bo_new(dev, flags, alignment, size, &bo);
+       if (ret)
+               return NULL;
+
+       return nouveau_screen_bo_skel(pscreen, bo, alignment, usage, size);
+}
+
+static struct pipe_buffer *
+nouveau_screen_bo_user(struct pipe_screen *pscreen, void *ptr, unsigned bytes)
+{
+       struct nouveau_device *dev = nouveau_screen(pscreen)->device;
+       struct nouveau_bo *bo = NULL;
+       int ret;
+
+       ret = nouveau_bo_user(dev, ptr, bytes, &bo);
+       if (ret)
+               return NULL;
+
+       return nouveau_screen_bo_skel(pscreen, bo, 0, 0, bytes);
+}
+
+static inline uint32_t
+nouveau_screen_map_flags(unsigned pipe)
+{
+       uint32_t flags = 0;
+
+       if (pipe & PIPE_BUFFER_USAGE_CPU_READ)
+               flags |= NOUVEAU_BO_RD;
+       if (pipe & PIPE_BUFFER_USAGE_CPU_WRITE)
+               flags |= NOUVEAU_BO_WR;
+       if (pipe & PIPE_BUFFER_USAGE_DISCARD)
+               flags |= NOUVEAU_BO_INVAL;
+       if (pipe & PIPE_BUFFER_USAGE_DONTBLOCK)
+               flags |= NOUVEAU_BO_NOWAIT;
+       else
+       if (pipe & 0 /*PIPE_BUFFER_USAGE_UNSYNCHRONIZED*/)
+               flags |= NOUVEAU_BO_NOSYNC;
+
+       return flags;
+}
+
+static void *
+nouveau_screen_bo_map(struct pipe_screen *pscreen, struct pipe_buffer *pb,
+                     unsigned usage)
+{
+       struct nouveau_bo *bo = nouveau_bo(pb);
+       int ret;
+
+       ret = nouveau_bo_map(bo, nouveau_screen_map_flags(usage));
+       if (ret) {
+               debug_printf("map failed: %d\n", ret);
+               return NULL;
+       }
+
+       return bo->map;
+}
+
+static void *
+nouveau_screen_bo_map_range(struct pipe_screen *pscreen, struct pipe_buffer *pb,
+                           unsigned offset, unsigned length, unsigned usage)
+{
+       struct nouveau_bo *bo = nouveau_bo(pb);
+       int ret;
+
+       ret = nouveau_bo_map_range(bo, offset, length,
+                                  nouveau_screen_map_flags(usage));
+       if (ret) {
+               debug_printf("map_range failed: %d\n", ret);
+               return NULL;
+       }
+
+       return (char *)bo->map - offset; /* why gallium? why? */
+}
+
+static void
+nouveau_screen_bo_map_flush(struct pipe_screen *pscreen, struct pipe_buffer *pb,
+                           unsigned offset, unsigned length)
+{
+       struct nouveau_bo *bo = nouveau_bo(pb);
+
+       nouveau_bo_map_flush(bo, offset, length);
+}
+
+static void
+nouveau_screen_bo_unmap(struct pipe_screen *pscreen, struct pipe_buffer *pb)
+{
+       struct nouveau_bo *bo = nouveau_bo(pb);
+
+       nouveau_bo_unmap(bo);
+}
+
+static void
+nouveau_screen_bo_del(struct pipe_buffer *pb)
+{
+       struct nouveau_bo *bo = nouveau_bo(pb);
+
+       nouveau_bo_ref(NULL, &bo);
+       FREE(pb);
+}
+
+static void
+nouveau_screen_fence_ref(struct pipe_screen *pscreen,
+                        struct pipe_fence_handle **ptr,
+                        struct pipe_fence_handle *pfence)
+{
+       *ptr = pfence;
+}
+
+static int
+nouveau_screen_fence_signalled(struct pipe_screen *screen,
+                              struct pipe_fence_handle *pfence,
+                              unsigned flags)
+{
+       return 0;
+}
+
+static int
+nouveau_screen_fence_finish(struct pipe_screen *screen,
+                           struct pipe_fence_handle *pfence,
+                           unsigned flags)
+{
+       return 0;
+}
+
+int
+nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev)
+{
+       struct pipe_screen *pscreen = &screen->base;
+       int ret;
+
+       ret = nouveau_channel_alloc(dev, 0xbeef0201, 0xbeef0202,
+                                   &screen->channel);
+       if (ret)
+               return ret;
+       screen->device = dev;
+
+       pscreen->get_name = nouveau_screen_get_name;
+       pscreen->get_vendor = nouveau_screen_get_vendor;
+
+       pscreen->buffer_create = nouveau_screen_bo_new;
+       pscreen->user_buffer_create = nouveau_screen_bo_user;
+       pscreen->buffer_map = nouveau_screen_bo_map;
+       pscreen->buffer_map_range = nouveau_screen_bo_map_range;
+       pscreen->buffer_flush_mapped_range = nouveau_screen_bo_map_flush;
+       pscreen->buffer_unmap = nouveau_screen_bo_unmap;
+       pscreen->buffer_destroy = nouveau_screen_bo_del;
+
+       pscreen->fence_reference = nouveau_screen_fence_ref;
+       pscreen->fence_signalled = nouveau_screen_fence_signalled;
+       pscreen->fence_finish = nouveau_screen_fence_finish;
+
+       return 0;
+}
+
+void
+nouveau_screen_fini(struct nouveau_screen *screen)
+{
+}
+
diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h
new file mode 100644 (file)
index 0000000..9968b07
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef __NOUVEAU_SCREEN_H__
+#define __NOUVEAU_SCREEN_H__
+
+struct nouveau_screen {
+       struct pipe_screen base;
+       struct nouveau_device *device;
+       struct nouveau_channel *channel;
+};
+
+static inline struct nouveau_screen *
+nouveau_screen(struct pipe_screen *pscreen)
+{
+       return (struct nouveau_screen *)pscreen;
+}
+
+static inline struct nouveau_bo *
+nouveau_bo(struct pipe_buffer *pb)
+{
+       return pb ? *(struct nouveau_bo **)(pb + 1) : NULL;
+}
+
+int nouveau_screen_init(struct nouveau_screen *, struct nouveau_device *);
+void nouveau_screen_fini(struct nouveau_screen *);
+
+#endif
index a54820e851204cf0253dd6ac155005eefba368df..b595405357f0044255261993c4887f1acdcfb8c5 100644 (file)
@@ -4,7 +4,7 @@
 #include "util/u_debug.h"
 
 struct nouveau_stateobj_reloc {
-       struct pipe_buffer *bo;
+       struct nouveau_bo *bo;
 
        unsigned offset;
        unsigned packet;
@@ -51,7 +51,7 @@ so_ref(struct nouveau_stateobj *ref, struct nouveau_stateobj **pso)
         if (pipe_reference((struct pipe_reference**)pso, &ref->reference)) {
                free(so->push);
                for (i = 0; i < so->cur_reloc; i++)
-                       pipe_buffer_reference(&so->reloc[i].bo, NULL);
+                       nouveau_bo_ref(NULL, &so->reloc[i].bo);
                free(so->reloc);
                free(so);
        }
@@ -81,13 +81,13 @@ so_method(struct nouveau_stateobj *so, struct nouveau_grobj *gr,
 }
 
 static INLINE void
-so_reloc(struct nouveau_stateobj *so, struct pipe_buffer *bo,
+so_reloc(struct nouveau_stateobj *so, struct nouveau_bo *bo,
         unsigned data, unsigned flags, unsigned vor, unsigned tor)
 {
        struct nouveau_stateobj_reloc *r = &so->reloc[so->cur_reloc++];
        
        r->bo = NULL;
-       pipe_buffer_reference(&r->bo, bo);
+       nouveau_bo_ref(bo, &r->bo);
        r->offset = so->cur - so->push;
        r->packet = so->cur_packet;
        r->data = data;
@@ -107,50 +107,52 @@ so_dump(struct nouveau_stateobj *so)
 }
 
 static INLINE void
-so_emit(struct nouveau_winsys *nvws, struct nouveau_stateobj *so)
+so_emit(struct nouveau_channel *chan, struct nouveau_stateobj *so)
 {
-       struct nouveau_pushbuf *pb = nvws->channel->pushbuf;
+       struct nouveau_pushbuf *pb = chan->pushbuf;
        unsigned nr, i;
 
        nr = so->cur - so->push;
        if (pb->remaining < nr)
-               nvws->push_flush(nvws, nr, NULL);
+               nouveau_pushbuf_flush(chan, nr);
        pb->remaining -= nr;
 
        memcpy(pb->cur, so->push, nr * 4);
        for (i = 0; i < so->cur_reloc; i++) {
                struct nouveau_stateobj_reloc *r = &so->reloc[i];
 
-               nvws->push_reloc(nvws, pb->cur + r->offset, r->bo,
-                                r->data, r->flags, r->vor, r->tor);
+               nouveau_pushbuf_emit_reloc(chan, pb->cur + r->offset,
+                                          r->bo, r->data, 0, r->flags,
+                                          r->vor, r->tor);
        }
        pb->cur += nr;
 }
 
 static INLINE void
-so_emit_reloc_markers(struct nouveau_winsys *nvws, struct nouveau_stateobj *so)
+so_emit_reloc_markers(struct nouveau_channel *chan, struct nouveau_stateobj *so)
 {
-       struct nouveau_pushbuf *pb = nvws->channel->pushbuf;
+       struct nouveau_pushbuf *pb = chan->pushbuf;
        unsigned i;
 
        if (!so)
                return;
 
        i = so->cur_reloc << 1;
-       if (nvws->channel->pushbuf->remaining < i)
-               nvws->push_flush(nvws, i, NULL);
-       nvws->channel->pushbuf->remaining -= i;
+       if (pb->remaining < i)
+               nouveau_pushbuf_flush(chan, i);
+       pb->remaining -= i;
 
        for (i = 0; i < so->cur_reloc; i++) {
                struct nouveau_stateobj_reloc *r = &so->reloc[i];
 
-               nvws->push_reloc(nvws, pb->cur++, r->bo, r->packet,
-                                (r->flags & (NOUVEAU_BO_VRAM |
-                                             NOUVEAU_BO_GART |
-                                             NOUVEAU_BO_RDWR)) |
-                                NOUVEAU_BO_DUMMY, 0, 0);
-               nvws->push_reloc(nvws, pb->cur++, r->bo, r->data,
-                                r->flags | NOUVEAU_BO_DUMMY, r->vor, r->tor);
+               nouveau_pushbuf_emit_reloc(chan, pb->cur++, r->bo, r->packet, 0,
+                                          (r->flags & (NOUVEAU_BO_VRAM |
+                                                       NOUVEAU_BO_GART |
+                                                       NOUVEAU_BO_RDWR)) |
+                                          NOUVEAU_BO_DUMMY, 0, 0);
+               nouveau_pushbuf_emit_reloc(chan, pb->cur++, r->bo, r->data, 0,
+                                          r->flags | NOUVEAU_BO_DUMMY,
+                                          r->vor, r->tor);
        }
 }
 
index ff7dd1c51c8fc5bcbe98ab60a47b769c07143f30..42c77e5e77890fb15e8403cbc6d485ea29f95255 100644 (file)
 #define NOUVEAU_BUFFER_USAGE_ZETA     (1 << 17)
 #define NOUVEAU_BUFFER_USAGE_TRANSFER (1 << 18)
 
-struct nouveau_winsys {
-       struct pipe_winsys *ws;
-
-       struct nouveau_channel *channel;
-
-       int  (*res_init)(struct nouveau_resource **heap, unsigned start,
-                        unsigned size);
-       int  (*res_alloc)(struct nouveau_resource *heap, int size, void *priv,
-                         struct nouveau_resource **);
-       void (*res_free)(struct nouveau_resource **);
-
-       int  (*push_reloc)(struct nouveau_winsys *, void *ptr,
-                          struct pipe_buffer *, uint32_t data,
-                          uint32_t flags, uint32_t vor, uint32_t tor);
-       int  (*push_flush)(struct nouveau_winsys *, unsigned size,
-                          struct pipe_fence_handle **fence);
-                              
-       int       (*grobj_alloc)(struct nouveau_winsys *, int grclass,
-                                struct nouveau_grobj **);
-       void      (*grobj_free)(struct nouveau_grobj **);
-
-       int       (*notifier_alloc)(struct nouveau_winsys *, int count,
-                                   struct nouveau_notifier **);
-       void      (*notifier_free)(struct nouveau_notifier **);
-       void      (*notifier_reset)(struct nouveau_notifier *, int id);
-       uint32_t  (*notifier_status)(struct nouveau_notifier *, int id);
-       uint32_t  (*notifier_retval)(struct nouveau_notifier *, int id);
-       int       (*notifier_wait)(struct nouveau_notifier *, int id,
-                                  int status, double timeout);
-
-       int (*surface_copy)(struct nouveau_winsys *, struct pipe_surface *,
-                           unsigned, unsigned, struct pipe_surface *,
-                           unsigned, unsigned, unsigned, unsigned);
-       int (*surface_fill)(struct nouveau_winsys *, struct pipe_surface *,
-                           unsigned, unsigned, unsigned, unsigned, unsigned);
-
-       struct nouveau_bo *(*get_bo)(struct pipe_buffer *);
-};
-
 extern struct pipe_screen *
-nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *);
+nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *);
 
 extern struct pipe_context *
 nv04_create(struct pipe_screen *, unsigned pctx_id);
 
 extern struct pipe_screen *
-nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *);
+nv10_screen_create(struct pipe_winsys *ws, struct nouveau_device *);
 
 extern struct pipe_context *
 nv10_create(struct pipe_screen *, unsigned pctx_id);
 
 extern struct pipe_screen *
-nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *);
+nv20_screen_create(struct pipe_winsys *ws, struct nouveau_device *);
 
 extern struct pipe_context *
 nv20_create(struct pipe_screen *, unsigned pctx_id);
 
 extern struct pipe_screen *
-nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *);
+nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *);
 
 extern struct pipe_context *
 nv30_create(struct pipe_screen *, unsigned pctx_id);
 
 extern struct pipe_screen *
-nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *);
+nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *);
 
 extern struct pipe_context *
 nv40_create(struct pipe_screen *, unsigned pctx_id);
 
 extern struct pipe_screen *
-nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *);
+nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *);
 
 extern struct pipe_context *
 nv50_create(struct pipe_screen *, unsigned pctx_id);
index 4da833c25e82335da2ef3ec7eebbe50f2fc159e4..93f752faec90c135e7b4e38f313b9a2bee4b3197 100644 (file)
@@ -31,7 +31,8 @@ nv04_miptree_layout(struct nv04_miptree *nv04mt)
 
        for (l = 0; l <= pt->last_level; l++) {
 
-               nv04mt->level[l].image_offset = offset;
+               nv04mt->level[l].image_offset = 
+                       CALLOC(nr_faces, sizeof(unsigned));
                offset += nv04mt->level[l].pitch * pt->height[l];
        }
 
index f9f6d974264588e2e4d9cba92ca93f0fbcc06c55..4bbedfb4d693048d8c3f3271b7dbfde9bdac34ce 100644 (file)
@@ -1,27 +1,9 @@
 #include "pipe/p_screen.h"
 #include "pipe/p_inlines.h"
-#include "util/u_simple_screen.h"
 
 #include "nv04_context.h"
 #include "nv04_screen.h"
 
-static const char *
-nv04_screen_get_name(struct pipe_screen *screen)
-{
-       struct nv04_screen *nv04screen = nv04_screen(screen);
-       struct nouveau_device *dev = nv04screen->nvws->channel->device;
-       static char buffer[128];
-
-       snprintf(buffer, sizeof(buffer), "NV%02X", dev->chipset);
-       return buffer;
-}
-
-static const char *
-nv04_screen_get_vendor(struct pipe_screen *screen)
-{
-       return "nouveau";
-}
-
 static int
 nv04_screen_get_param(struct pipe_screen *screen, int param)
 {
@@ -123,10 +105,9 @@ static void
 nv04_screen_destroy(struct pipe_screen *pscreen)
 {
        struct nv04_screen *screen = nv04_screen(pscreen);
-       struct nouveau_winsys *nvws = screen->nvws;
 
-       nvws->notifier_free(&screen->sync);
-       nvws->grobj_free(&screen->fahrenheit);
+       nouveau_notifier_free(&screen->sync);
+       nouveau_grobj_free(&screen->fahrenheit);
        nv04_surface_2d_takedown(&screen->eng2d);
 
        FREE(pscreen);
@@ -141,21 +122,38 @@ nv04_surface_buffer(struct pipe_surface *surf)
 }
 
 struct pipe_screen *
-nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
+nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
 {
        struct nv04_screen *screen = CALLOC_STRUCT(nv04_screen);
+       struct nouveau_channel *chan;
+       struct pipe_screen *pscreen;
        unsigned fahrenheit_class = 0, sub3d_class = 0;
-       unsigned chipset = nvws->channel->device->chipset;
        int ret;
 
        if (!screen)
                return NULL;
-       screen->nvws = nvws;
+       pscreen = &screen->base.base;
+
+       ret = nouveau_screen_init(&screen->base, dev);
+       if (ret) {
+               nv04_screen_destroy(pscreen);
+               return NULL;
+       }
+       chan = screen->base.channel;
+
+       pscreen->winsys = ws;
+       pscreen->destroy = nv04_screen_destroy;
+       pscreen->get_param = nv04_screen_get_param;
+       pscreen->get_paramf = nv04_screen_get_paramf;
+       pscreen->is_format_supported = nv04_screen_is_format_supported;
 
-       if (chipset>=0x20) {
+       nv04_screen_init_miptree_functions(pscreen);
+       nv04_screen_init_transfer_functions(pscreen);
+
+       if (dev->chipset >= 0x20) {
                fahrenheit_class = 0;
                sub3d_class = 0;
-       } else if (chipset>=0x10) {
+       } else if (dev->chipset >= 0x10) {
                fahrenheit_class = NV10_DX5_TEXTURED_TRIANGLE;
                sub3d_class = NV10_CONTEXT_SURFACES_3D;
        } else {
@@ -164,50 +162,40 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
        }
 
        if (!fahrenheit_class) {
-               NOUVEAU_ERR("Unknown nv04 chipset: nv%02x\n", chipset);
+               NOUVEAU_ERR("Unknown nv04 chipset: nv%02x\n", dev->chipset);
                return NULL;
        }
 
-       /* 2D engine setup */
-       screen->eng2d = nv04_surface_2d_init(nvws);
-       screen->eng2d->buf = nv04_surface_buffer;
-
        /* 3D object */
-       ret = nvws->grobj_alloc(nvws, fahrenheit_class, &screen->fahrenheit);
+       ret = nouveau_grobj_alloc(chan, 0xbeef0001, fahrenheit_class,
+                                 &screen->fahrenheit);
        if (ret) {
                NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
                return NULL;
        }
+       BIND_RING(chan, screen->fahrenheit, 7);
 
        /* 3D surface object */
-       ret = nvws->grobj_alloc(nvws, sub3d_class, &screen->context_surfaces_3d);
+       ret = nouveau_grobj_alloc(chan, 0xbeef0002, sub3d_class,
+                                 &screen->context_surfaces_3d);
        if (ret) {
                NOUVEAU_ERR("Error creating 3D surface object: %d\n", ret);
                return NULL;
        }
+       BIND_RING(chan, screen->context_surfaces_3d, 6);
+
+       /* 2D engine setup */
+       screen->eng2d = nv04_surface_2d_init(&screen->base);
+       screen->eng2d->buf = nv04_surface_buffer;
 
        /* Notifier for sync purposes */
-       ret = nvws->notifier_alloc(nvws, 1, &screen->sync);
+       ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync);
        if (ret) {
                NOUVEAU_ERR("Error creating notifier object: %d\n", ret);
-               nv04_screen_destroy(&screen->pipe);
+               nv04_screen_destroy(pscreen);
                return NULL;
        }
 
-       screen->pipe.winsys = ws;
-       screen->pipe.destroy = nv04_screen_destroy;
-
-       screen->pipe.get_name = nv04_screen_get_name;
-       screen->pipe.get_vendor = nv04_screen_get_vendor;
-       screen->pipe.get_param = nv04_screen_get_param;
-       screen->pipe.get_paramf = nv04_screen_get_paramf;
-
-       screen->pipe.is_format_supported = nv04_screen_is_format_supported;
-
-       nv04_screen_init_miptree_functions(&screen->pipe);
-       nv04_screen_init_transfer_functions(&screen->pipe);
-       u_simple_screen_init(&screen->pipe);
-
-       return &screen->pipe;
+       return pscreen;
 }
 
index ee6fb6db44a2aed3c8fc45dfbc0f0c5b840243b1..11466b9442ca7a162f30fa5e4eae66f7ebeb8945 100644 (file)
@@ -1,11 +1,11 @@
 #ifndef __NV04_SCREEN_H__
 #define __NV04_SCREEN_H__
 
-#include "pipe/p_screen.h"
+#include "nouveau/nouveau_screen.h"
 #include "nv04_surface_2d.h"
 
 struct nv04_screen {
-       struct pipe_screen pipe;
+       struct nouveau_screen base;
 
        struct nouveau_winsys *nvws;
        unsigned chipset;
index 87c635f962a6dcf5934174ab35805b57272f8591..d356ebd8b3688217740b49d490b644342f3253e3 100644 (file)
@@ -2,6 +2,7 @@
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_shader_tokens.h"
+#include "pipe/p_inlines.h"
 
 #include "tgsi/tgsi_parse.h"
 
@@ -334,7 +335,7 @@ nv04_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
                         const struct pipe_constant_buffer *buf )
 {
        struct nv04_context *nv04 = nv04_context(pipe);
-       struct pipe_winsys *ws = pipe->winsys;
+       struct pipe_screen *pscreen = pipe->screen;
 
        assert(shader < PIPE_SHADER_TYPES);
        assert(index == 0);
@@ -342,12 +343,12 @@ nv04_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
        if (buf) {
                void *mapped;
                if (buf->buffer && buf->buffer->size &&
-                    (mapped = ws->buffer_map(ws, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ)))
+                    (mapped = pipe_buffer_map(pscreen, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ)))
                {
                        memcpy(nv04->constbuf[shader], mapped, buf->buffer->size);
                        nv04->constbuf_nr[shader] =
                                buf->buffer->size / (4 * sizeof(float));
-                       ws->buffer_unmap(ws, buf->buffer);
+                       pipe_buffer_unmap(pscreen, buf->buffer);
                }
        }
 }
index 0d51439e3ffc9f4df2476562c96b37ffe67c1a77..399f750dbe7caf4de1d33036b2704aa297fc81d7 100644 (file)
@@ -37,7 +37,7 @@ struct nv04_miptree {
 
        struct {
                uint pitch;
-               uint image_offset;
+               uint *image_offset;
        } level[PIPE_MAX_TEXTURE_LEVELS];
 };
 
index f3a8d7efeed48ecd6ab430f973c2847d7eb0f03b..5afd028ddd2a0e85c3d288a3a6d26bb84699930a 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "nouveau/nouveau_winsys.h"
 #include "nouveau/nouveau_util.h"
+#include "nouveau/nouveau_screen.h"
 #include "nv04_surface_2d.h"
 
 static INLINE int
@@ -96,11 +97,11 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
                          struct pipe_surface *src, int sx, int sy,
                          int w, int h)
 {
-       struct nouveau_channel *chan = ctx->nvws->channel;
+       struct nouveau_channel *chan = ctx->swzsurf->channel;
        struct nouveau_grobj *swzsurf = ctx->swzsurf;
        struct nouveau_grobj *sifm = ctx->sifm;
-       struct nouveau_bo *src_bo = ctx->nvws->get_bo(ctx->buf(src));
-       struct nouveau_bo *dst_bo = ctx->nvws->get_bo(ctx->buf(dst));
+       struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src));
+       struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
        const unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
        const unsigned max_w = 1024;
        const unsigned max_h = 1024;
@@ -167,10 +168,10 @@ nv04_surface_copy_m2mf(struct nv04_surface_2d *ctx,
                       struct pipe_surface *dst, int dx, int dy,
                       struct pipe_surface *src, int sx, int sy, int w, int h)
 {
-       struct nouveau_channel *chan = ctx->nvws->channel;
+       struct nouveau_channel *chan = ctx->m2mf->channel;
        struct nouveau_grobj *m2mf = ctx->m2mf;
-       struct nouveau_bo *src_bo = ctx->nvws->get_bo(ctx->buf(src));
-       struct nouveau_bo *dst_bo = ctx->nvws->get_bo(ctx->buf(dst));
+       struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src));
+       struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
        unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
        unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
        unsigned dst_offset = dst->offset + dy * dst_pitch +
@@ -213,11 +214,11 @@ nv04_surface_copy_blit(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
                       int dx, int dy, struct pipe_surface *src, int sx, int sy,
                       int w, int h)
 {
-       struct nouveau_channel *chan = ctx->nvws->channel;
+       struct nouveau_channel *chan = ctx->surf2d->channel;
        struct nouveau_grobj *surf2d = ctx->surf2d;
        struct nouveau_grobj *blit = ctx->blit;
-       struct nouveau_bo *src_bo = ctx->nvws->get_bo(ctx->buf(src));
-       struct nouveau_bo *dst_bo = ctx->nvws->get_bo(ctx->buf(dst));
+       struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src));
+       struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
        unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
        unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
        int format;
@@ -279,10 +280,10 @@ static void
 nv04_surface_fill(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
                  int dx, int dy, int w, int h, unsigned value)
 {
-       struct nouveau_channel *chan = ctx->nvws->channel;
+       struct nouveau_channel *chan = ctx->surf2d->channel;
        struct nouveau_grobj *surf2d = ctx->surf2d;
        struct nouveau_grobj *rect = ctx->rect;
-       struct nouveau_bo *dst_bo = ctx->nvws->get_bo(ctx->buf(dst));
+       struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
        unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
        int cs2d_format, gdirect_format;
 
@@ -334,10 +335,10 @@ nv04_surface_2d_takedown(struct nv04_surface_2d **pctx)
 }
 
 struct nv04_surface_2d *
-nv04_surface_2d_init(struct nouveau_winsys *nvws)
+nv04_surface_2d_init(struct nouveau_screen *screen)
 {
        struct nv04_surface_2d *ctx = CALLOC_STRUCT(nv04_surface_2d);
-       struct nouveau_channel *chan = nvws->channel;
+       struct nouveau_channel *chan = screen->channel;
        unsigned handle = 0x88000000, class;
        int ret;
 
@@ -460,7 +461,6 @@ nv04_surface_2d_init(struct nouveau_winsys *nvws)
                return NULL;
        }
 
-       ctx->nvws = nvws;
        ctx->copy = nv04_surface_copy;
        ctx->fill = nv04_surface_fill;
        return ctx;
index 82ce7189c8bf5f9e7fa281455e34574ed40759a7..02b3f56ba8b8c89a06f19e9488334803b5a08c92 100644 (file)
@@ -7,7 +7,6 @@ struct nv04_surface {
 };
 
 struct nv04_surface_2d {
-       struct nouveau_winsys *nvws;
        struct nouveau_notifier *ntfy;
        struct nouveau_grobj *surf2d;
        struct nouveau_grobj *swzsurf;
@@ -26,7 +25,7 @@ struct nv04_surface_2d {
 };
 
 struct nv04_surface_2d *
-nv04_surface_2d_init(struct nouveau_winsys *nvws);
+nv04_surface_2d_init(struct nouveau_screen *screen);
 
 void
 nv04_surface_2d_takedown(struct nv04_surface_2d **);
index d21a0e34f7136c445c88e0c63e07e32a128170fb..e3167814f2bcb39d5ec92280c3391f8b1fea9c40 100644 (file)
@@ -1,6 +1,7 @@
 #include "draw/draw_context.h"
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
+#include "pipe/p_inlines.h"
 
 #include "nv04_context.h"
 #include "nv04_state.h"
@@ -13,6 +14,7 @@ boolean nv04_draw_elements( struct pipe_context *pipe,
                     unsigned indexSize,
                     unsigned prim, unsigned start, unsigned count)
 {
+       struct pipe_screen *pscreen = pipe->screen;
        struct nv04_context *nv04 = nv04_context( pipe );
        struct draw_context *draw = nv04->draw;
        unsigned i;
@@ -25,17 +27,17 @@ boolean nv04_draw_elements( struct pipe_context *pipe,
        for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
                if (nv04->vtxbuf[i].buffer) {
                        void *buf
-                               = pipe->winsys->buffer_map(pipe->winsys,
-                                               nv04->vtxbuf[i].buffer,
-                                               PIPE_BUFFER_USAGE_CPU_READ);
+                               = pipe_buffer_map(pscreen,
+                                                 nv04->vtxbuf[i].buffer,
+                                                 PIPE_BUFFER_USAGE_CPU_READ);
                        draw_set_mapped_vertex_buffer(draw, i, buf);
                }
        }
        /* Map index buffer, if present */
        if (indexBuffer) {
                void *mapped_indexes
-                       = pipe->winsys->buffer_map(pipe->winsys, indexBuffer,
-                                       PIPE_BUFFER_USAGE_CPU_READ);
+                       = pipe_buffer_map(pscreen, indexBuffer,
+                                         PIPE_BUFFER_USAGE_CPU_READ);
                draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
        }
        else {
@@ -55,12 +57,12 @@ boolean nv04_draw_elements( struct pipe_context *pipe,
         */
        for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
                if (nv04->vtxbuf[i].buffer) {
-                       pipe->winsys->buffer_unmap(pipe->winsys, nv04->vtxbuf[i].buffer);
+                       pipe_buffer_unmap(pscreen, nv04->vtxbuf[i].buffer);
                        draw_set_mapped_vertex_buffer(draw, i, NULL);
                }
        }
        if (indexBuffer) {
-               pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer);
+               pipe_buffer_unmap(pscreen, indexBuffer);
                draw_set_mapped_element_buffer(draw, 0, NULL);
        }
 
index 3da8d2f568f7f331c52be549491f188594f18cc3..a127b134ecd5043369915ae96b9d90e707b70156 100644 (file)
@@ -30,18 +30,18 @@ nv10_destroy(struct pipe_context *pipe)
 static void nv10_init_hwctx(struct nv10_context *nv10)
 {
        struct nv10_screen *screen = nv10->screen;
-       struct nouveau_winsys *nvws = screen->nvws;
+       struct nouveau_channel *chan = screen->base.channel;
        int i;
        float projectionmatrix[16];
 
        BEGIN_RING(celsius, NV10TCL_DMA_NOTIFY, 1);
        OUT_RING  (screen->sync->handle);
        BEGIN_RING(celsius, NV10TCL_DMA_IN_MEMORY0, 2);
-       OUT_RING  (nvws->channel->vram->handle);
-       OUT_RING  (nvws->channel->gart->handle);
+       OUT_RING  (chan->vram->handle);
+       OUT_RING  (chan->gart->handle);
        BEGIN_RING(celsius, NV10TCL_DMA_IN_MEMORY2, 2);
-       OUT_RING  (nvws->channel->vram->handle);
-       OUT_RING  (nvws->channel->vram->handle);
+       OUT_RING  (chan->vram->handle);
+       OUT_RING  (chan->vram->handle);
 
        BEGIN_RING(celsius, NV10TCL_NOP, 1);
        OUT_RING  (0);
index 089c236302a5c02d637581b823a8132cce028248..1806d5f8ccc3ac17cbe97d0bd1fb4d470bf22d6d 100644 (file)
@@ -40,7 +40,6 @@
 
 #include "util/u_debug.h"
 #include "pipe/p_inlines.h"
-#include "pipe/internal/p_winsys_screen.h"
 
 #include "nv10_context.h"
 #include "nv10_state.h"
@@ -124,11 +123,10 @@ nv10_vbuf_render_map_vertices( struct vbuf_render *render )
 {
        struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render);
        struct nv10_context *nv10 = nv10_render->nv10;
-       struct pipe_winsys *winsys = nv10->pipe.winsys;
+       struct pipe_screen *pscreen = nv10->pipe.screen;
 
-       return winsys->buffer_map(winsys, 
-                       nv10_render->buffer, 
-                       PIPE_BUFFER_USAGE_CPU_WRITE);
+       return pipe_buffer_map(pscreen, nv10_render->buffer,
+                              PIPE_BUFFER_USAGE_CPU_WRITE);
 }
 
 static void
@@ -138,10 +136,10 @@ nv10_vbuf_render_unmap_vertices( struct vbuf_render *render,
 {
        struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render);
        struct nv10_context *nv10 = nv10_render->nv10;
-       struct pipe_winsys *winsys = nv10->pipe.winsys;
+       struct pipe_screen *pscreen = nv10->pipe.screen;
 
        assert(!nv10_render->buffer);
-       winsys->buffer_unmap(winsys, nv10_render->buffer);
+       pipe_buffer_unmap(pscreen, nv10_render->buffer);
 }
 
 static boolean
@@ -202,8 +200,6 @@ static void
 nv10_vbuf_render_release_vertices( struct vbuf_render *render )
 {
        struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render);
-       struct nv10_context *nv10 = nv10_render->nv10;
-       struct pipe_screen *pscreen = &nv10->screen->pipe;
 
        assert(nv10_render->buffer);
        pipe_buffer_reference(&nv10_render->buffer, NULL);
index 6532a93c7ba10de5860fc390813b5d54483a8649..b03c291f9d92d10d23d770b9a3a56a5aee0bd7d2 100644 (file)
@@ -1,26 +1,8 @@
 #include "pipe/p_screen.h"
-#include "util/u_simple_screen.h"
 
 #include "nv10_context.h"
 #include "nv10_screen.h"
 
-static const char *
-nv10_screen_get_name(struct pipe_screen *screen)
-{
-       struct nv10_screen *nv10screen = nv10_screen(screen);
-       struct nouveau_device *dev = nv10screen->nvws->channel->device;
-       static char buffer[128];
-
-       snprintf(buffer, sizeof(buffer), "NV%02X", dev->chipset);
-       return buffer;
-}
-
-static const char *
-nv10_screen_get_vendor(struct pipe_screen *screen)
-{
-       return "nouveau";
-}
-
 static int
 nv10_screen_get_param(struct pipe_screen *screen, int param)
 {
@@ -120,10 +102,9 @@ static void
 nv10_screen_destroy(struct pipe_screen *pscreen)
 {
        struct nv10_screen *screen = nv10_screen(pscreen);
-       struct nouveau_winsys *nvws = screen->nvws;
 
-       nvws->notifier_free(&screen->sync);
-       nvws->grobj_free(&screen->celsius);
+       nouveau_notifier_free(&screen->sync);
+       nouveau_grobj_free(&screen->celsius);
 
        FREE(pscreen);
 }
@@ -137,64 +118,69 @@ nv10_surface_buffer(struct pipe_surface *surf)
 }
 
 struct pipe_screen *
-nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
+nv10_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
 {
        struct nv10_screen *screen = CALLOC_STRUCT(nv10_screen);
+       struct nouveau_channel *chan;
+       struct pipe_screen *pscreen;
        unsigned celsius_class;
-       unsigned chipset = nvws->channel->device->chipset;
        int ret;
 
        if (!screen)
                return NULL;
-       screen->nvws = nvws;
+       pscreen = &screen->base.base;
 
-       /* 2D engine setup */
-       screen->eng2d = nv04_surface_2d_init(nvws);
-       screen->eng2d->buf = nv10_surface_buffer;
+       ret = nouveau_screen_init(&screen->base, dev);
+       if (ret) {
+               nv10_screen_destroy(pscreen);
+               return NULL;
+       }
+       chan = screen->base.channel;
+
+       pscreen->winsys = ws;
+       pscreen->destroy = nv10_screen_destroy;
+       pscreen->get_param = nv10_screen_get_param;
+       pscreen->get_paramf = nv10_screen_get_paramf;
+       pscreen->is_format_supported = nv10_screen_is_format_supported;
+
+       nv10_screen_init_miptree_functions(pscreen);
+       nv10_screen_init_transfer_functions(pscreen);
 
        /* 3D object */
-       if (chipset>=0x20)
-               celsius_class=NV11TCL;
-       else if (chipset>=0x17)
-               celsius_class=NV17TCL;
-       else if (chipset>=0x11)
-               celsius_class=NV11TCL;
+       if (dev->chipset >= 0x20)
+               celsius_class = NV11TCL;
+       else if (dev->chipset >= 0x17)
+               celsius_class = NV17TCL;
+       else if (dev->chipset >= 0x11)
+               celsius_class = NV11TCL;
        else
-               celsius_class=NV10TCL;
+               celsius_class = NV10TCL;
 
        if (!celsius_class) {
-               NOUVEAU_ERR("Unknown nv1x chipset: nv%02x\n", chipset);
+               NOUVEAU_ERR("Unknown nv1x chipset: nv%02x\n", dev->chipset);
                return NULL;
        }
 
-       ret = nvws->grobj_alloc(nvws, celsius_class, &screen->celsius);
+       ret = nouveau_grobj_alloc(chan, 0xbeef0001, celsius_class,
+                                 &screen->celsius);
        if (ret) {
                NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
                return FALSE;
        }
+       BIND_RING(chan, screen->celsius, 7);
+
+       /* 2D engine setup */
+       screen->eng2d = nv04_surface_2d_init(&screen->base);
+       screen->eng2d->buf = nv10_surface_buffer;
 
        /* Notifier for sync purposes */
-       ret = nvws->notifier_alloc(nvws, 1, &screen->sync);
+       ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync);
        if (ret) {
                NOUVEAU_ERR("Error creating notifier object: %d\n", ret);
-               nv10_screen_destroy(&screen->pipe);
+               nv10_screen_destroy(pscreen);
                return NULL;
        }
 
-       screen->pipe.winsys = ws;
-       screen->pipe.destroy = nv10_screen_destroy;
-
-       screen->pipe.get_name = nv10_screen_get_name;
-       screen->pipe.get_vendor = nv10_screen_get_vendor;
-       screen->pipe.get_param = nv10_screen_get_param;
-       screen->pipe.get_paramf = nv10_screen_get_paramf;
-
-       screen->pipe.is_format_supported = nv10_screen_is_format_supported;
-
-       nv10_screen_init_miptree_functions(&screen->pipe);
-       nv10_screen_init_transfer_functions(&screen->pipe);
-       u_simple_screen_init(&screen->pipe);
-
-       return &screen->pipe;
+       return pscreen;
 }
 
index ad829ee3fd4d9b68a81eb1e905aceb75c4c67f84..86b6d8def54c5bd27f9daf520d30866ab16a9507 100644 (file)
@@ -1,11 +1,11 @@
 #ifndef __NV10_SCREEN_H__
 #define __NV10_SCREEN_H__
 
-#include "pipe/p_screen.h"
+#include "nouveau/nouveau_screen.h"
 #include "nv04/nv04_surface_2d.h"
 
 struct nv10_screen {
-       struct pipe_screen pipe;
+       struct nouveau_screen base;
 
        struct nouveau_winsys *nvws;
 
index 119af66dfd054e357184c34602964e1c7f7b9e56..9b38219b996d70cbc1d607c11e35586b8fe6db1f 100644 (file)
@@ -2,6 +2,7 @@
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_shader_tokens.h"
+#include "pipe/p_inlines.h"
 
 #include "tgsi/tgsi_parse.h"
 
@@ -460,7 +461,7 @@ nv10_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
                         const struct pipe_constant_buffer *buf )
 {
        struct nv10_context *nv10 = nv10_context(pipe);
-       struct pipe_winsys *ws = pipe->winsys;
+       struct pipe_screen *pscreen = pipe->screen;
 
        assert(shader < PIPE_SHADER_TYPES);
        assert(index == 0);
@@ -468,12 +469,12 @@ nv10_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
        if (buf) {
                void *mapped;
                if (buf->buffer && buf->buffer->size &&
-                    (mapped = ws->buffer_map(ws, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ)))
+                    (mapped = pipe_buffer_map(pscreen, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ)))
                {
                        memcpy(nv10->constbuf[shader], mapped, buf->buffer->size);
                        nv10->constbuf_nr[shader] =
                                buf->buffer->size / (4 * sizeof(float));
-                       ws->buffer_unmap(ws, buf->buffer);
+                       pipe_buffer_unmap(pscreen, buf->buffer);
                }
        }
 }
index d0e788ac0368262e48ad907b76bf8ac38ea8e13a..441a4f75f3f84ddfde01116b4ed01d44e1b16b0a 100644 (file)
@@ -1,6 +1,7 @@
 #include "draw/draw_context.h"
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
+#include "pipe/p_inlines.h"
 
 #include "nv10_context.h"
 #include "nv10_state.h"
@@ -15,6 +16,7 @@ boolean nv10_draw_elements( struct pipe_context *pipe,
 {
        struct nv10_context *nv10 = nv10_context( pipe );
        struct draw_context *draw = nv10->draw;
+       struct pipe_screen *pscreen = pipe->screen;
        unsigned i;
 
        nv10_emit_hw_state(nv10);
@@ -24,9 +26,8 @@ boolean nv10_draw_elements( struct pipe_context *pipe,
         */
        for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
                if (nv10->vtxbuf[i].buffer) {
-                       void *buf
-                               = pipe->winsys->buffer_map(pipe->winsys,
-                                               nv10->vtxbuf[i].buffer,
+                       void *buf =
+                               pipe_buffer_map(pscreen, nv10->vtxbuf[i].buffer,
                                                PIPE_BUFFER_USAGE_CPU_READ);
                        draw_set_mapped_vertex_buffer(draw, i, buf);
                }
@@ -34,8 +35,8 @@ boolean nv10_draw_elements( struct pipe_context *pipe,
        /* Map index buffer, if present */
        if (indexBuffer) {
                void *mapped_indexes
-                       = pipe->winsys->buffer_map(pipe->winsys, indexBuffer,
-                                       PIPE_BUFFER_USAGE_CPU_READ);
+                       = pipe_buffer_map(pscreen, indexBuffer,
+                                         PIPE_BUFFER_USAGE_CPU_READ);
                draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
        }
        else {
@@ -55,12 +56,12 @@ boolean nv10_draw_elements( struct pipe_context *pipe,
         */
        for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
                if (nv10->vtxbuf[i].buffer) {
-                       pipe->winsys->buffer_unmap(pipe->winsys, nv10->vtxbuf[i].buffer);
+                       pipe_buffer_unmap(pscreen, nv10->vtxbuf[i].buffer);
                        draw_set_mapped_vertex_buffer(draw, i, NULL);
                }
        }
        if (indexBuffer) {
-               pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer);
+               pipe_buffer_unmap(pscreen, indexBuffer);
                draw_set_mapped_element_buffer(draw, 0, NULL);
        }
 
index cbc41707d54c037752fb506e4ee49175b36b034d..b32d0d83ba0642fd111352c74be272447c866277 100644 (file)
@@ -30,7 +30,7 @@ nv20_destroy(struct pipe_context *pipe)
 static void nv20_init_hwctx(struct nv20_context *nv20)
 {
        struct nv20_screen *screen = nv20->screen;
-       struct nouveau_winsys *nvws = screen->nvws;
+       struct nouveau_channel *chan = screen->base.channel;
        int i;
        float projectionmatrix[16];
        const boolean is_nv25tcl = (nv20->screen->kelvin->grclass == NV25TCL);
@@ -38,11 +38,11 @@ static void nv20_init_hwctx(struct nv20_context *nv20)
        BEGIN_RING(kelvin, NV20TCL_DMA_NOTIFY, 1);
        OUT_RING  (screen->sync->handle);
        BEGIN_RING(kelvin, NV20TCL_DMA_TEXTURE0, 2);
-       OUT_RING  (nvws->channel->vram->handle);
-       OUT_RING  (nvws->channel->gart->handle); /* TEXTURE1 */
+       OUT_RING  (chan->vram->handle);
+       OUT_RING  (chan->gart->handle); /* TEXTURE1 */
        BEGIN_RING(kelvin, NV20TCL_DMA_COLOR, 2);
-       OUT_RING  (nvws->channel->vram->handle);
-       OUT_RING  (nvws->channel->vram->handle); /* ZETA */
+       OUT_RING  (chan->vram->handle);
+       OUT_RING  (chan->vram->handle); /* ZETA */
 
        BEGIN_RING(kelvin, NV20TCL_DMA_QUERY, 1);
        OUT_RING  (0); /* renouveau: beef0351, unique */
@@ -99,9 +99,9 @@ static void nv20_init_hwctx(struct nv20_context *nv20)
                OUT_RING  (3);
 
                BEGIN_RING(kelvin, NV25TCL_DMA_IN_MEMORY9, 1);
-               OUT_RING  (nvws->channel->vram->handle);
+               OUT_RING  (chan->vram->handle);
                BEGIN_RING(kelvin, NV25TCL_DMA_IN_MEMORY8, 1);
-               OUT_RING  (nvws->channel->vram->handle);
+               OUT_RING  (chan->vram->handle);
        }
        BEGIN_RING(kelvin, NV20TCL_DMA_FENCE, 1);
        OUT_RING  (0);  /* renouveau: beef1e10 */
index 8aa342cd2db5a180663d3541f32fe2378a94c1c8..ddfcdb8057ae19535fa697e976a4e47531e8a701 100644 (file)
@@ -152,12 +152,11 @@ static void *
 nv20_vbuf_render_map_vertices( struct vbuf_render *render )
 {
        struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render);
-       struct pipe_winsys *winsys = nv20_render->nv20->pipe.winsys;
+       struct pipe_screen *pscreen = nv20_render->nv20->pipe.screen;
 
        if (nv20_render->pbuffer) {
-               return winsys->buffer_map(winsys,
-                               nv20_render->pbuffer,
-                               PIPE_BUFFER_USAGE_CPU_WRITE);
+               return pipe_buffer_map(pscreen, nv20_render->pbuffer,
+                                      PIPE_BUFFER_USAGE_CPU_WRITE);
        } else if (nv20_render->mbuffer) {
                return nv20_render->mbuffer;
        } else
@@ -173,10 +172,10 @@ nv20_vbuf_render_unmap_vertices( struct vbuf_render *render,
                ushort max_index )
 {
        struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render);
-       struct pipe_winsys *winsys = nv20_render->nv20->pipe.winsys;
+       struct pipe_screen *pscreen = nv20_render->nv20->pipe.screen;
 
        if (nv20_render->pbuffer)
-               winsys->buffer_unmap(winsys, nv20_render->pbuffer);
+               pipe_buffer_unmap(pscreen, nv20_render->pbuffer);
 }
 
 static boolean
@@ -358,7 +357,6 @@ nv20_vbuf_render_release_vertices( struct vbuf_render *render )
 {
        struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render);
        struct nv20_context *nv20 = nv20_render->nv20;
-       struct pipe_screen *pscreen = &nv20->screen->pipe;
 
        if (nv20_render->pbuffer) {
                pipe_buffer_reference(&nv20_render->pbuffer, NULL);
index 7760ae27c0ed566879d29b011f8343dafbf65bc9..024356ca74c53a7097af6989b1c2f0f49fde55de 100644 (file)
@@ -1,26 +1,8 @@
 #include "pipe/p_screen.h"
-#include "util/u_simple_screen.h"
 
 #include "nv20_context.h"
 #include "nv20_screen.h"
 
-static const char *
-nv20_screen_get_name(struct pipe_screen *screen)
-{
-       struct nv20_screen *nv20screen = nv20_screen(screen);
-       struct nouveau_device *dev = nv20screen->nvws->channel->device;
-       static char buffer[128];
-
-       snprintf(buffer, sizeof(buffer), "NV%02X", dev->chipset);
-       return buffer;
-}
-
-static const char *
-nv20_screen_get_vendor(struct pipe_screen *screen)
-{
-       return "nouveau";
-}
-
 static int
 nv20_screen_get_param(struct pipe_screen *screen, int param)
 {
@@ -120,10 +102,9 @@ static void
 nv20_screen_destroy(struct pipe_screen *pscreen)
 {
        struct nv20_screen *screen = nv20_screen(pscreen);
-       struct nouveau_winsys *nvws = screen->nvws;
 
-       nvws->notifier_free(&screen->sync);
-       nvws->grobj_free(&screen->kelvin);
+       nouveau_notifier_free(&screen->sync);
+       nouveau_grobj_free(&screen->kelvin);
 
        FREE(pscreen);
 }
@@ -137,60 +118,65 @@ nv20_surface_buffer(struct pipe_surface *surf)
 }
 
 struct pipe_screen *
-nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
+nv20_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
 {
        struct nv20_screen *screen = CALLOC_STRUCT(nv20_screen);
+       struct nouveau_channel *chan;
+       struct pipe_screen *pscreen;
        unsigned kelvin_class = 0;
-       unsigned chipset = nvws->channel->device->chipset;
        int ret;
 
        if (!screen)
                return NULL;
-       screen->nvws = nvws;
+       pscreen = &screen->base.base;
 
-       /* 2D engine setup */
-       screen->eng2d = nv04_surface_2d_init(nvws);
-       screen->eng2d->buf = nv20_surface_buffer;
+       ret = nouveau_screen_init(&screen->base, dev);
+       if (ret) {
+               nv20_screen_destroy(pscreen);
+               return NULL;
+       }
+       chan = screen->base.channel;
+
+       pscreen->winsys = ws;
+       pscreen->destroy = nv20_screen_destroy;
+       pscreen->get_param = nv20_screen_get_param;
+       pscreen->get_paramf = nv20_screen_get_paramf;
+       pscreen->is_format_supported = nv20_screen_is_format_supported;
+
+       nv20_screen_init_miptree_functions(pscreen);
+       nv20_screen_init_transfer_functions(pscreen);
 
        /* 3D object */
-       if (chipset >= 0x25)
+       if (dev->chipset >= 0x25)
                kelvin_class = NV25TCL;
-       else if (chipset >= 0x20)
+       else if (dev->chipset >= 0x20)
                kelvin_class = NV20TCL;
 
-       if (!kelvin_class || chipset >= 0x30) {
-               NOUVEAU_ERR("Unknown nv2x chipset: nv%02x\n", chipset);
+       if (!kelvin_class || dev->chipset >= 0x30) {
+               NOUVEAU_ERR("Unknown nv2x chipset: nv%02x\n", dev->chipset);
                return NULL;
        }
 
-       ret = nvws->grobj_alloc(nvws, kelvin_class, &screen->kelvin);
+       ret = nouveau_grobj_alloc(chan, 0xbeef0097, kelvin_class,
+                                 &screen->kelvin);
        if (ret) {
                NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
                return FALSE;
        }
+       BIND_RING(chan, screen->kelvin, 7);
+
+       /* 2D engine setup */
+       screen->eng2d = nv04_surface_2d_init(&screen->base);
+       screen->eng2d->buf = nv20_surface_buffer;
 
        /* Notifier for sync purposes */
-       ret = nvws->notifier_alloc(nvws, 1, &screen->sync);
+       ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync);
        if (ret) {
                NOUVEAU_ERR("Error creating notifier object: %d\n", ret);
-               nv20_screen_destroy(&screen->pipe);
+               nv20_screen_destroy(pscreen);
                return NULL;
        }
 
-       screen->pipe.winsys = ws;
-       screen->pipe.destroy = nv20_screen_destroy;
-
-       screen->pipe.get_name = nv20_screen_get_name;
-       screen->pipe.get_vendor = nv20_screen_get_vendor;
-       screen->pipe.get_param = nv20_screen_get_param;
-       screen->pipe.get_paramf = nv20_screen_get_paramf;
-
-       screen->pipe.is_format_supported = nv20_screen_is_format_supported;
-
-       nv20_screen_init_miptree_functions(&screen->pipe);
-       nv20_screen_init_transfer_functions(&screen->pipe);
-       u_simple_screen_init(&screen->pipe);
-
-       return &screen->pipe;
+       return pscreen;
 }
 
index d9fce2bced890b282c8c6d80dd65663cb7a70454..fc7bb0503345d39e46d5b98e9a22a56a00007266 100644 (file)
@@ -1,11 +1,11 @@
 #ifndef __NV20_SCREEN_H__
 #define __NV20_SCREEN_H__
 
-#include "pipe/p_screen.h"
+#include "nouveau/nouveau_screen.h"
 #include "nv04/nv04_surface_2d.h"
 
 struct nv20_screen {
-       struct pipe_screen pipe;
+       struct nouveau_screen base;
 
        struct nouveau_winsys *nvws;
 
index ecec4f49a0c56c85a5ee50ce3aede23f5b4121e7..ed4084980f20148af52ae8aec449511eff03d531 100644 (file)
@@ -2,6 +2,7 @@
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_shader_tokens.h"
+#include "pipe/p_inlines.h"
 
 #include "tgsi/tgsi_parse.h"
 
@@ -453,7 +454,7 @@ nv20_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
                         const struct pipe_constant_buffer *buf )
 {
        struct nv20_context *nv20 = nv20_context(pipe);
-       struct pipe_winsys *ws = pipe->winsys;
+       struct pipe_screen *pscreen = pipe->screen;
 
        assert(shader < PIPE_SHADER_TYPES);
        assert(index == 0);
@@ -461,12 +462,12 @@ nv20_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
        if (buf) {
                void *mapped;
                if (buf->buffer && buf->buffer->size &&
-                    (mapped = ws->buffer_map(ws, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ)))
+                    (mapped = pipe_buffer_map(pscreen, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ)))
                {
                        memcpy(nv20->constbuf[shader], mapped, buf->buffer->size);
                        nv20->constbuf_nr[shader] =
                                buf->buffer->size / (4 * sizeof(float));
-                       ws->buffer_unmap(ws, buf->buffer);
+                       pipe_buffer_unmap(pscreen, buf->buffer);
                }
        }
 }
index 24d8f4bef094f5e630f90152b0153e26492d6339..84d7db6c5e27c3274eea2f40340e06311db8a04e 100644 (file)
@@ -1,6 +1,7 @@
 #include "draw/draw_context.h"
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
+#include "pipe/p_inlines.h"
 
 #include "nv20_context.h"
 #include "nv20_state.h"
@@ -13,6 +14,7 @@ boolean nv20_draw_elements( struct pipe_context *pipe,
                     unsigned indexSize,
                     unsigned prim, unsigned start, unsigned count)
 {
+       struct pipe_screen *pscreen = pipe->screen;
        struct nv20_context *nv20 = nv20_context( pipe );
        struct draw_context *draw = nv20->draw;
        unsigned i;
@@ -25,17 +27,17 @@ boolean nv20_draw_elements( struct pipe_context *pipe,
        for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
                if (nv20->vtxbuf[i].buffer) {
                        void *buf
-                               = pipe->winsys->buffer_map(pipe->winsys,
-                                               nv20->vtxbuf[i].buffer,
-                                               PIPE_BUFFER_USAGE_CPU_READ);
+                               = pipe_buffer_map(pscreen,
+                                                 nv20->vtxbuf[i].buffer,
+                                                 PIPE_BUFFER_USAGE_CPU_READ);
                        draw_set_mapped_vertex_buffer(draw, i, buf);
                }
        }
        /* Map index buffer, if present */
        if (indexBuffer) {
                void *mapped_indexes
-                       = pipe->winsys->buffer_map(pipe->winsys, indexBuffer,
-                                       PIPE_BUFFER_USAGE_CPU_READ);
+                       = pipe_buffer_map(pscreen, indexBuffer,
+                                         PIPE_BUFFER_USAGE_CPU_READ);
                draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
        }
        else {
@@ -55,12 +57,12 @@ boolean nv20_draw_elements( struct pipe_context *pipe,
         */
        for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
                if (nv20->vtxbuf[i].buffer) {
-                       pipe->winsys->buffer_unmap(pipe->winsys, nv20->vtxbuf[i].buffer);
+                       pipe_buffer_unmap(pscreen, nv20->vtxbuf[i].buffer);
                        draw_set_mapped_vertex_buffer(draw, i, NULL);
                }
        }
        if (indexBuffer) {
-               pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer);
+               pipe_buffer_unmap(pscreen, indexBuffer);
                draw_set_mapped_element_buffer(draw, 0, NULL);
        }
 
index 5db0e807ff52a98b7bce0fd5879f618b2a7213a1..c1e588902b23ef116a690ef00646bcb128c034e6 100644 (file)
@@ -1,6 +1,7 @@
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_state.h"
+#include "pipe/p_inlines.h"
 
 #include "pipe/p_shader_tokens.h"
 #include "tgsi/tgsi_parse.h"
@@ -645,8 +646,8 @@ out_err:
 static boolean
 nv20_vertprog_validate(struct nv20_context *nv20)
 { 
+       struct pipe_screen *pscreen = nv20->pipe.screen;
        struct nouveau_winsys *nvws = nv20->nvws;
-       struct pipe_winsys *ws = nv20->pipe.winsys;
        struct nouveau_grobj *rankine = nv20->screen->rankine;
        struct nv20_vertex_program *vp;
        struct pipe_buffer *constbuf;
@@ -749,8 +750,8 @@ nv20_vertprog_validate(struct nv20_context *nv20)
                float *map = NULL;
 
                if (constbuf) {
-                       map = ws->buffer_map(ws, constbuf,
-                                            PIPE_BUFFER_USAGE_CPU_READ);
+                       map = pipe_buffer_map(pscreen, constbuf,
+                                             PIPE_BUFFER_USAGE_CPU_READ);
                }
 
                for (i = 0; i < vp->nr_consts; i++) {
@@ -770,9 +771,8 @@ nv20_vertprog_validate(struct nv20_context *nv20)
                        OUT_RINGp ((uint32_t *)vpd->value, 4);
                }
 
-               if (constbuf) {
-                       ws->buffer_unmap(ws, constbuf);
-               }
+               if (constbuf)
+                       pipe_buffer_unmap(pscreen, constbuf);
        }
 
        /* Upload vtxprog */
index bdfe1425d24628042bdb048136b5a2b57598b5aa..1d1c556fb11b8417479813696bec0a6ed4008aff 100644 (file)
@@ -1,6 +1,7 @@
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_state.h"
+#include "pipe/p_inlines.h"
 
 #include "pipe/p_shader_tokens.h"
 #include "tgsi/tgsi_parse.h"
@@ -798,12 +799,12 @@ static void
 nv30_fragprog_upload(struct nv30_context *nv30,
                     struct nv30_fragment_program *fp)
 {
-       struct pipe_winsys *ws = nv30->pipe.winsys;
+       struct pipe_screen *pscreen = nv30->pipe.screen;
        const uint32_t le = 1;
        uint32_t *map;
        int i;
 
-       map = ws->buffer_map(ws, fp->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
+       map = pipe_buffer_map(pscreen, fp->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
 
 #if 0
        for (i = 0; i < fp->insn_len; i++) {
@@ -825,7 +826,7 @@ nv30_fragprog_upload(struct nv30_context *nv30,
                }
        }
 
-       ws->buffer_unmap(ws, fp->buffer);
+       pipe_buffer_unmap(pscreen, fp->buffer);
 }
 
 static boolean
@@ -834,8 +835,7 @@ nv30_fragprog_validate(struct nv30_context *nv30)
        struct nv30_fragment_program *fp = nv30->fragprog;
        struct pipe_buffer *constbuf =
                nv30->constbuf[PIPE_SHADER_FRAGMENT];
-       struct pipe_screen *screen = nv30->pipe.screen;
-       struct pipe_winsys *ws = nv30->pipe.winsys;
+       struct pipe_screen *pscreen = nv30->pipe.screen;
        struct nouveau_stateobj *so;
        boolean new_consts = FALSE;
        int i;
@@ -850,14 +850,15 @@ nv30_fragprog_validate(struct nv30_context *nv30)
                return FALSE;
        }
 
-       fp->buffer = screen->buffer_create(screen, 0x100, 0, fp->insn_len * 4);
+       fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4);
        nv30_fragprog_upload(nv30, fp);
 
        so = so_new(8, 1);
        so_method(so, nv30->screen->rankine, NV34TCL_FP_ACTIVE_PROGRAM, 1);
-       so_reloc (so, fp->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART |
-                 NOUVEAU_BO_RD | NOUVEAU_BO_LOW | NOUVEAU_BO_OR,
-                 NV34TCL_FP_ACTIVE_PROGRAM_DMA0, NV34TCL_FP_ACTIVE_PROGRAM_DMA1);
+       so_reloc (so, nouveau_bo(fp->buffer), 0, NOUVEAU_BO_VRAM |
+                     NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW |
+                     NOUVEAU_BO_OR, NV34TCL_FP_ACTIVE_PROGRAM_DMA0,
+                     NV34TCL_FP_ACTIVE_PROGRAM_DMA1);
        so_method(so, nv30->screen->rankine, NV34TCL_FP_CONTROL, 1);
        so_data  (so, fp->fp_control);
        so_method(so, nv30->screen->rankine, NV34TCL_FP_REG_CONTROL, 1);
@@ -871,7 +872,8 @@ update_constants:
        if (fp->nr_consts) {
                float *map;
                
-               map = ws->buffer_map(ws, constbuf, PIPE_BUFFER_USAGE_CPU_READ);
+               map = pipe_buffer_map(pscreen, constbuf,
+                                     PIPE_BUFFER_USAGE_CPU_READ);
                for (i = 0; i < fp->nr_consts; i++) {
                        struct nv30_fragment_program_data *fpd = &fp->consts[i];
                        uint32_t *p = &fp->insn[fpd->offset];
@@ -882,7 +884,7 @@ update_constants:
                        memcpy(p, cb, 4 * sizeof(float));
                        new_consts = TRUE;
                }
-               ws->buffer_unmap(ws, constbuf);
+               pipe_buffer_unmap(pscreen, constbuf);
 
                if (new_consts)
                        nv30_fragprog_upload(nv30, fp);
index 8b6ab992d16887ac2abf13f8e522ed1cd90795c5..822e1d8defe7c42b0f1dcdceb6737d306cf62131 100644 (file)
@@ -61,6 +61,7 @@ nv30_fragtex_build(struct nv30_context *nv30, int unit)
        struct nv30_sampler_state *ps = nv30->tex_sampler[unit];
        struct nv30_miptree *nv30mt = nv30->tex_miptree[unit];
        struct pipe_texture *pt = &nv30mt->base;
+       struct nouveau_bo *bo = nouveau_bo(nv30mt->buffer);
        struct nv30_texture_format *tf;
        struct nouveau_stateobj *so;
        uint32_t txf, txs , txp;
@@ -106,9 +107,9 @@ nv30_fragtex_build(struct nv30_context *nv30, int unit)
 
        so = so_new(16, 2);
        so_method(so, nv30->screen->rankine, NV34TCL_TX_OFFSET(unit), 8);
-       so_reloc (so, nv30mt->buffer, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0);
-       so_reloc (so, nv30mt->buffer, txf, tex_flags | NOUVEAU_BO_OR,
-                 NV34TCL_TX_FORMAT_DMA0, NV34TCL_TX_FORMAT_DMA1);
+       so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0);
+       so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,
+                     NV34TCL_TX_FORMAT_DMA0, NV34TCL_TX_FORMAT_DMA1);
        so_data  (so, ps->wrap);
        so_data  (so, NV34TCL_TX_ENABLE_ENABLE | ps->en);
        so_data  (so, txs);
index 2f974cf5c4047685b635f9a944f6045fb23142de..1d1c8a484e1933da0d78cab6297e01bbce5377a4 100644 (file)
@@ -29,11 +29,10 @@ nv30_query_create(struct pipe_context *pipe, unsigned query_type)
 static void
 nv30_query_destroy(struct pipe_context *pipe, struct pipe_query *pq)
 {
-       struct nv30_context *nv30 = nv30_context(pipe);
        struct nv30_query *q = nv30_query(pq);
 
        if (q->object)
-               nv30->nvws->res_free(&q->object);
+               nouveau_resource_free(&q->object);
        FREE(q);
 }
 
@@ -54,9 +53,9 @@ nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
                pipe->get_query_result(pipe, pq, 1, &tmp);
        }
 
-       if (nv30->nvws->res_alloc(nv30->screen->query_heap, 1, NULL, &q->object))
+       if (nouveau_resource_alloc(nv30->screen->query_heap, 1, NULL, &q->object))
                assert(0);
-       nv30->nvws->notifier_reset(nv30->screen->query, q->object->start);
+       nouveau_notifier_reset(nv30->screen->query, q->object->start);
 
        BEGIN_RING(rankine, NV34TCL_QUERY_RESET, 1);
        OUT_RING  (1);
@@ -84,27 +83,27 @@ nv30_query_result(struct pipe_context *pipe, struct pipe_query *pq,
 {
        struct nv30_context *nv30 = nv30_context(pipe);
        struct nv30_query *q = nv30_query(pq);
-       struct nouveau_winsys *nvws = nv30->nvws;
 
        assert(q->object && q->type == PIPE_QUERY_OCCLUSION_COUNTER);
 
        if (!q->ready) {
                unsigned status;
 
-               status = nvws->notifier_status(nv30->screen->query,
-                                              q->object->start);
+               status = nouveau_notifier_status(nv30->screen->query,
+                                                q->object->start);
                if (status != NV_NOTIFY_STATE_STATUS_COMPLETED) {
                        if (wait == FALSE)
                                return FALSE;
-                       nvws->notifier_wait(nv30->screen->query, q->object->start,
-                                           NV_NOTIFY_STATE_STATUS_COMPLETED,
-                                           0);
+
+                       nouveau_notifier_wait_status(nv30->screen->query,
+                                       q->object->start,
+                                       NV_NOTIFY_STATE_STATUS_COMPLETED, 0);
                }
 
-               q->result = nvws->notifier_retval(nv30->screen->query,
-                                                 q->object->start);
+               q->result = nouveau_notifier_return_val(nv30->screen->query,
+                                                       q->object->start);
                q->ready = TRUE;
-               nvws->res_free(&q->object);
+               nouveau_resource_free(&q->object);
        }
 
        *result = q->result;
index d395c5e1b7f5db77a52ea582d6fc2c50a38ea6a6..31bc1f317347c19bc6e263b04fb21c68a0a69a76 100644 (file)
@@ -1,5 +1,7 @@
 #include "pipe/p_screen.h"
-#include "util/u_simple_screen.h"
+#include "pipe/p_state.h"
+
+#include "nouveau/nouveau_screen.h"
 
 #include "nv30_context.h"
 #include "nv30_screen.h"
@@ -8,23 +10,6 @@
 #define NV34TCL_CHIPSET_3X_MASK 0x00000010
 #define NV35TCL_CHIPSET_3X_MASK 0x000001e0
 
-static const char *
-nv30_screen_get_name(struct pipe_screen *pscreen)
-{
-       struct nv30_screen *screen = nv30_screen(pscreen);
-       struct nouveau_device *dev = screen->nvws->channel->device;
-       static char buffer[128];
-
-       snprintf(buffer, sizeof(buffer), "NV%02X", dev->chipset);
-       return buffer;
-}
-
-static const char *
-nv30_screen_get_vendor(struct pipe_screen *pscreen)
-{
-       return "nouveau";
-}
-
 static int
 nv30_screen_get_param(struct pipe_screen *pscreen, int param)
 {
@@ -139,45 +124,57 @@ static void
 nv30_screen_destroy(struct pipe_screen *pscreen)
 {
        struct nv30_screen *screen = nv30_screen(pscreen);
-       struct nouveau_winsys *nvws = screen->nvws;
 
-       nvws->res_free(&screen->vp_exec_heap);
-       nvws->res_free(&screen->vp_data_heap);
-       nvws->res_free(&screen->query_heap);
-       nvws->notifier_free(&screen->query);
-       nvws->notifier_free(&screen->sync);
-       nvws->grobj_free(&screen->rankine);
+       nouveau_resource_free(&screen->vp_exec_heap);
+       nouveau_resource_free(&screen->vp_data_heap);
+       nouveau_resource_free(&screen->query_heap);
+       nouveau_notifier_free(&screen->query);
+       nouveau_notifier_free(&screen->sync);
+       nouveau_grobj_free(&screen->rankine);
 
        FREE(pscreen);
 }
 
 struct pipe_screen *
-nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
+nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
 {
        struct nv30_screen *screen = CALLOC_STRUCT(nv30_screen);
+       struct nouveau_channel *chan;
+       struct pipe_screen *pscreen;
        struct nouveau_stateobj *so;
        unsigned rankine_class = 0;
-       unsigned chipset = nvws->channel->device->chipset;
        int ret, i;
 
        if (!screen)
                return NULL;
-       screen->nvws = nvws;
+       pscreen = &screen->base.base;
 
-       /* 2D engine setup */
-       screen->eng2d = nv04_surface_2d_init(nvws);
-       screen->eng2d->buf = nv30_surface_buffer;
+       ret = nouveau_screen_init(&screen->base, dev);
+       if (ret) {
+               nv30_screen_destroy(pscreen);
+               return NULL;
+       }
+       chan = screen->base.channel;
+
+       pscreen->winsys = ws;
+       pscreen->destroy = nv30_screen_destroy;
+       pscreen->get_param = nv30_screen_get_param;
+       pscreen->get_paramf = nv30_screen_get_paramf;
+       pscreen->is_format_supported = nv30_screen_surface_format_supported;
+
+       nv30_screen_init_miptree_functions(pscreen);
+       nv30_screen_init_transfer_functions(pscreen);
 
        /* 3D object */
-       switch (chipset & 0xf0) {
+       switch (dev->chipset & 0xf0) {
        case 0x30:
-               if (NV30TCL_CHIPSET_3X_MASK & (1 << (chipset & 0x0f)))
+               if (NV30TCL_CHIPSET_3X_MASK & (1 << (dev->chipset & 0x0f)))
                        rankine_class = 0x0397;
                else
-               if (NV34TCL_CHIPSET_3X_MASK & (1 << (chipset & 0x0f)))
+               if (NV34TCL_CHIPSET_3X_MASK & (1 << (dev->chipset & 0x0f)))
                        rankine_class = 0x0697;
                else
-               if (NV35TCL_CHIPSET_3X_MASK & (1 << (chipset & 0x0f)))
+               if (NV35TCL_CHIPSET_3X_MASK & (1 << (dev->chipset & 0x0f)))
                        rankine_class = 0x0497;
                break;
        default:
@@ -185,43 +182,49 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
        }
 
        if (!rankine_class) {
-               NOUVEAU_ERR("Unknown nv3x chipset: nv%02x\n", chipset);
+               NOUVEAU_ERR("Unknown nv3x chipset: nv%02x\n", dev->chipset);
                return NULL;
        }
 
-       ret = nvws->grobj_alloc(nvws, rankine_class, &screen->rankine);
+       ret = nouveau_grobj_alloc(chan, 0xbeef3097, rankine_class,
+                                 &screen->rankine);
        if (ret) {
                NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
                return FALSE;
        }
+       BIND_RING(chan, screen->rankine, 7);
+
+       /* 2D engine setup */
+       screen->eng2d = nv04_surface_2d_init(&screen->base);
+       screen->eng2d->buf = nv30_surface_buffer;
 
        /* Notifier for sync purposes */
-       ret = nvws->notifier_alloc(nvws, 1, &screen->sync);
+       ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync);
        if (ret) {
                NOUVEAU_ERR("Error creating notifier object: %d\n", ret);
-               nv30_screen_destroy(&screen->pipe);
+               nv30_screen_destroy(pscreen);
                return NULL;
        }
 
        /* Query objects */
-       ret = nvws->notifier_alloc(nvws, 32, &screen->query);
+       ret = nouveau_notifier_alloc(chan, 0xbeef0302, 32, &screen->query);
        if (ret) {
                NOUVEAU_ERR("Error initialising query objects: %d\n", ret);
-               nv30_screen_destroy(&screen->pipe);
+               nv30_screen_destroy(pscreen);
                return NULL;
        }
 
-       ret = nvws->res_init(&screen->query_heap, 0, 32);
+       ret = nouveau_resource_init(&screen->query_heap, 0, 32);
        if (ret) {
                NOUVEAU_ERR("Error initialising query object heap: %d\n", ret);
-               nv30_screen_destroy(&screen->pipe);
+               nv30_screen_destroy(pscreen);
                return NULL;
        }
 
        /* Vtxprog resources */
-       if (nvws->res_init(&screen->vp_exec_heap, 0, 256) ||
-           nvws->res_init(&screen->vp_data_heap, 0, 256)) {
-               nv30_screen_destroy(&screen->pipe);
+       if (nouveau_resource_init(&screen->vp_exec_heap, 0, 256) ||
+           nouveau_resource_init(&screen->vp_data_heap, 0, 256)) {
+               nv30_screen_destroy(pscreen);
                return NULL;
        }
 
@@ -230,23 +233,23 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
        so_method(so, screen->rankine, NV34TCL_DMA_NOTIFY, 1);
        so_data  (so, screen->sync->handle);
        so_method(so, screen->rankine, NV34TCL_DMA_TEXTURE0, 2);
-       so_data  (so, nvws->channel->vram->handle);
-       so_data  (so, nvws->channel->gart->handle);
+       so_data  (so, chan->vram->handle);
+       so_data  (so, chan->gart->handle);
        so_method(so, screen->rankine, NV34TCL_DMA_COLOR1, 1);
-       so_data  (so, nvws->channel->vram->handle);
+       so_data  (so, chan->vram->handle);
        so_method(so, screen->rankine, NV34TCL_DMA_COLOR0, 2);
-       so_data  (so, nvws->channel->vram->handle);
-       so_data  (so, nvws->channel->vram->handle);
+       so_data  (so, chan->vram->handle);
+       so_data  (so, chan->vram->handle);
        so_method(so, screen->rankine, NV34TCL_DMA_VTXBUF0, 2);
-       so_data  (so, nvws->channel->vram->handle);
-       so_data  (so, nvws->channel->gart->handle);
+       so_data  (so, chan->vram->handle);
+       so_data  (so, chan->gart->handle);
 /*     so_method(so, screen->rankine, NV34TCL_DMA_FENCE, 2);
        so_data  (so, 0);
        so_data  (so, screen->query->handle);*/
        so_method(so, screen->rankine, NV34TCL_DMA_IN_MEMORY7, 1);
-       so_data  (so, nvws->channel->vram->handle);
+       so_data  (so, chan->vram->handle);
        so_method(so, screen->rankine, NV34TCL_DMA_IN_MEMORY8, 1);
-       so_data  (so, nvws->channel->vram->handle);
+       so_data  (so, chan->vram->handle);
 
        for (i=1; i<8; i++) {
                so_method(so, screen->rankine, NV34TCL_VIEWPORT_CLIP_HORIZ(i), 1);
@@ -301,23 +304,9 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
        so_method(so, screen->rankine, 0x1e94, 1);
        so_data  (so, 0x13);
 
-       so_emit(nvws, so);
+       so_emit(chan, so);
        so_ref(NULL, &so);
-       nvws->push_flush(nvws, 0, NULL);
-
-       screen->pipe.winsys = ws;
-       screen->pipe.destroy = nv30_screen_destroy;
-
-       screen->pipe.get_name = nv30_screen_get_name;
-       screen->pipe.get_vendor = nv30_screen_get_vendor;
-       screen->pipe.get_param = nv30_screen_get_param;
-       screen->pipe.get_paramf = nv30_screen_get_paramf;
-
-       screen->pipe.is_format_supported = nv30_screen_surface_format_supported;
-
-       nv30_screen_init_miptree_functions(&screen->pipe);
-       nv30_screen_init_transfer_functions(&screen->pipe);
-       u_simple_screen_init(&screen->pipe);
+       nouveau_pushbuf_flush(chan, 0);
 
-       return &screen->pipe;
+       return pscreen;
 }
index 8e36883975926cd67cbc5427605d14706247d6a7..5fbd998b53943c35ebac43b449d7bd4106b4401e 100644 (file)
@@ -1,11 +1,12 @@
 #ifndef __NV30_SCREEN_H__
 #define __NV30_SCREEN_H__
 
-#include "pipe/p_screen.h"
+#include "nouveau/nouveau_screen.h"
+
 #include "nv04/nv04_surface_2d.h"
 
 struct nv30_screen {
-       struct pipe_screen pipe;
+       struct nouveau_screen base;
 
        struct nouveau_winsys *nvws;
 
index c18be20a32779d7e848047702745175b70e00060..621b8846c8ed3835c97fd809ddfbe0dcba208e26 100644 (file)
@@ -38,6 +38,7 @@ nv30_state_do_validate(struct nv30_context *nv30,
 void
 nv30_state_emit(struct nv30_context *nv30)
 {
+       struct nouveau_channel *chan = nv30->screen->base.channel;
        struct nv30_state *state = &nv30->state;
        struct nv30_screen *screen = nv30->screen;
        unsigned i, samplers;
@@ -57,23 +58,23 @@ nv30_state_emit(struct nv30_context *nv30)
                        continue;
                so_ref (state->hw[i], &nv30->screen->state[i]);
                if (state->hw[i])
-                       so_emit(nv30->nvws, nv30->screen->state[i]);
+                       so_emit(chan, nv30->screen->state[i]);
                states &= ~(1ULL << i);
        }
 
        state->dirty = 0;
 
-       so_emit_reloc_markers(nv30->nvws, state->hw[NV30_STATE_FB]);
+       so_emit_reloc_markers(chan, state->hw[NV30_STATE_FB]);
        for (i = 0, samplers = state->fp_samplers; i < 16 && samplers; i++) {
                if (!(samplers & (1 << i)))
                        continue;
-               so_emit_reloc_markers(nv30->nvws,
+               so_emit_reloc_markers(chan,
                                      state->hw[NV30_STATE_FRAGTEX0+i]);
                samplers &= ~(1ULL << i);
        }
-       so_emit_reloc_markers(nv30->nvws, state->hw[NV30_STATE_FRAGPROG]);
+       so_emit_reloc_markers(chan, state->hw[NV30_STATE_FRAGPROG]);
        if (state->hw[NV30_STATE_VTXBUF] /*&& nv30->render_mode == HW*/)
-               so_emit_reloc_markers(nv30->nvws, state->hw[NV30_STATE_VTXBUF]);
+               so_emit_reloc_markers(chan, state->hw[NV30_STATE_VTXBUF]);
 }
 
 boolean
index fdc1cade905124a164245084771870338b71a771..cb1a260eaad652a3ba7896232941684e0bb37785 100644 (file)
@@ -5,6 +5,8 @@ static boolean
 nv30_state_framebuffer_validate(struct nv30_context *nv30)
 {
        struct pipe_framebuffer_state *fb = &nv30->framebuffer;
+       struct nouveau_channel *chan = nv30->screen->base.channel;
+       struct nouveau_grobj *rankine = nv30->screen->rankine;
        struct nv04_surface *rt[2], *zeta = NULL;
        uint32_t rt_enable, rt_format;
        int i, colour_format = 0, zeta_format = 0;
@@ -79,56 +81,53 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
                }
 
                nv30mt = (struct nv30_miptree *)rt[0]->base.texture;
-               so_method(so, nv30->screen->rankine, NV34TCL_DMA_COLOR0, 1);
-               so_reloc (so, nv30mt->buffer, 0, rt_flags | NOUVEAU_BO_OR,
-                         nv30->nvws->channel->vram->handle,
-                         nv30->nvws->channel->gart->handle);
-               so_method(so, nv30->screen->rankine, NV34TCL_COLOR0_PITCH, 2);
+               so_method(so, rankine, NV34TCL_DMA_COLOR0, 1);
+               so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR,
+                             chan->vram->handle, chan->gart->handle);
+               so_method(so, rankine, NV34TCL_COLOR0_PITCH, 2);
                so_data  (so, pitch);
-               so_reloc (so, nv30mt->buffer, rt[0]->base.offset, rt_flags |
-                         NOUVEAU_BO_LOW, 0, 0);
+               so_reloc (so, nouveau_bo(nv30mt->buffer), rt[0]->base.offset,
+                             rt_flags | NOUVEAU_BO_LOW, 0, 0);
        }
 
        if (rt_enable & NV34TCL_RT_ENABLE_COLOR1) {
                nv30mt = (struct nv30_miptree *)rt[1]->base.texture;
-               so_method(so, nv30->screen->rankine, NV34TCL_DMA_COLOR1, 1);
-               so_reloc (so, nv30mt->buffer, 0, rt_flags | NOUVEAU_BO_OR,
-                         nv30->nvws->channel->vram->handle,
-                         nv30->nvws->channel->gart->handle);
-               so_method(so, nv30->screen->rankine, NV34TCL_COLOR1_OFFSET, 2);
-               so_reloc (so, nv30mt->buffer, rt[1]->base.offset, rt_flags |
-                         NOUVEAU_BO_LOW, 0, 0);
+               so_method(so, rankine, NV34TCL_DMA_COLOR1, 1);
+               so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR,
+                             chan->vram->handle, chan->gart->handle);
+               so_method(so, rankine, NV34TCL_COLOR1_OFFSET, 2);
+               so_reloc (so, nouveau_bo(nv30mt->buffer), rt[1]->base.offset,
+                             rt_flags | NOUVEAU_BO_LOW, 0, 0);
                so_data  (so, rt[1]->pitch);
        }
 
        if (zeta_format) {
                nv30mt = (struct nv30_miptree *)zeta->base.texture;
-               so_method(so, nv30->screen->rankine, NV34TCL_DMA_ZETA, 1);
-               so_reloc (so, nv30mt->buffer, 0, rt_flags | NOUVEAU_BO_OR,
-                         nv30->nvws->channel->vram->handle,
-                         nv30->nvws->channel->gart->handle);
-               so_method(so, nv30->screen->rankine, NV34TCL_ZETA_OFFSET, 1);
-               so_reloc (so, nv30mt->buffer, zeta->base.offset, rt_flags |
-                         NOUVEAU_BO_LOW, 0, 0);
+               so_method(so, rankine, NV34TCL_DMA_ZETA, 1);
+               so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR,
+                             chan->vram->handle, chan->gart->handle);
+               so_method(so, rankine, NV34TCL_ZETA_OFFSET, 1);
+               so_reloc (so, nouveau_bo(nv30mt->buffer), zeta->base.offset,
+                             rt_flags | NOUVEAU_BO_LOW, 0, 0);
                /* TODO: allocate LMA depth buffer */
        }
 
-       so_method(so, nv30->screen->rankine, NV34TCL_RT_ENABLE, 1);
+       so_method(so, rankine, NV34TCL_RT_ENABLE, 1);
        so_data  (so, rt_enable);
-       so_method(so, nv30->screen->rankine, NV34TCL_RT_HORIZ, 3);
+       so_method(so, rankine, NV34TCL_RT_HORIZ, 3);
        so_data  (so, (w << 16) | 0);
        so_data  (so, (h << 16) | 0);
        so_data  (so, rt_format);
-       so_method(so, nv30->screen->rankine, NV34TCL_VIEWPORT_HORIZ, 2);
+       so_method(so, rankine, NV34TCL_VIEWPORT_HORIZ, 2);
        so_data  (so, (w << 16) | 0);
        so_data  (so, (h << 16) | 0);
-       so_method(so, nv30->screen->rankine, NV34TCL_VIEWPORT_CLIP_HORIZ(0), 2);
+       so_method(so, rankine, NV34TCL_VIEWPORT_CLIP_HORIZ(0), 2);
        so_data  (so, ((w - 1) << 16) | 0);
        so_data  (so, ((h - 1) << 16) | 0);
-       so_method(so, nv30->screen->rankine, 0x1d88, 1);
+       so_method(so, rankine, 0x1d88, 1);
        so_data  (so, (1 << 12) | h);
        /* Wonder why this is needed, context should all be set to zero on init */
-       so_method(so, nv30->screen->rankine, NV34TCL_VIEWPORT_TX_ORIGIN, 1);
+       so_method(so, rankine, NV34TCL_VIEWPORT_TX_ORIGIN, 1);
        so_data  (so, 0);
 
        so_ref(so, &nv30->state.hw[NV30_STATE_FB]);
index 990a8763824ad5974143ce3d7825151161a1a768..189656ec817aadb637c83b47fe31614400ab3d45 100644 (file)
@@ -1,5 +1,6 @@
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
+#include "pipe/p_inlines.h"
 
 #include "nv30_context.h"
 #include "nv30_state.h"
@@ -70,7 +71,7 @@ static boolean
 nv30_vbo_set_idxbuf(struct nv30_context *nv30, struct pipe_buffer *ib,
                    unsigned ib_size)
 {
-       struct pipe_screen *pscreen = &nv30->screen->pipe;
+       struct pipe_screen *pscreen = &nv30->screen->base.base;
        unsigned type;
 
        if (!ib) {
@@ -108,7 +109,7 @@ nv30_vbo_static_attrib(struct nv30_context *nv30, struct nouveau_stateobj *so,
                       int attrib, struct pipe_vertex_element *ve,
                       struct pipe_vertex_buffer *vb)
 {
-       struct pipe_winsys *ws = nv30->pipe.winsys;
+       struct pipe_screen *pscreen = nv30->pipe.screen;
        struct nouveau_grobj *rankine = nv30->screen->rankine;
        unsigned type, ncomp;
        void *map;
@@ -116,7 +117,7 @@ nv30_vbo_static_attrib(struct nv30_context *nv30, struct nouveau_stateobj *so,
        if (nv30_vbo_format_to_hw(ve->src_format, &type, &ncomp))
                return FALSE;
 
-       map  = ws->buffer_map(ws, vb->buffer, PIPE_BUFFER_USAGE_CPU_READ);
+       map  = pipe_buffer_map(pscreen, vb->buffer, PIPE_BUFFER_USAGE_CPU_READ);
        map += vb->buffer_offset + ve->src_offset;
 
        switch (type) {
@@ -148,18 +149,17 @@ nv30_vbo_static_attrib(struct nv30_context *nv30, struct nouveau_stateobj *so,
                        so_data  (so, fui(v[0]));
                        break;
                default:
-                       ws->buffer_unmap(ws, vb->buffer);
+                       pipe_buffer_unmap(pscreen, vb->buffer);
                        return FALSE;
                }
        }
                break;
        default:
-               ws->buffer_unmap(ws, vb->buffer);
+               pipe_buffer_unmap(pscreen, vb->buffer);
                return FALSE;
        }
 
-       ws->buffer_unmap(ws, vb->buffer);
-
+       pipe_buffer_unmap(pscreen, vb->buffer);
        return TRUE;
 }
 
@@ -168,7 +168,7 @@ nv30_draw_arrays(struct pipe_context *pipe,
                 unsigned mode, unsigned start, unsigned count)
 {
        struct nv30_context *nv30 = nv30_context(pipe);
-       struct nouveau_channel *chan = nv30->nvws->channel;
+       struct nouveau_channel *chan = nv30->screen->base.channel;
        unsigned restart = 0;
 
        nv30_vbo_set_idxbuf(nv30, NULL, 0);
@@ -228,7 +228,7 @@ static INLINE void
 nv30_draw_elements_u08(struct nv30_context *nv30, void *ib,
                       unsigned mode, unsigned start, unsigned count)
 {
-       struct nouveau_channel *chan = nv30->nvws->channel;
+       struct nouveau_channel *chan = nv30->screen->base.channel;
 
        while (count) {
                uint8_t *elts = (uint8_t *)ib + start;
@@ -277,7 +277,7 @@ static INLINE void
 nv30_draw_elements_u16(struct nv30_context *nv30, void *ib,
                       unsigned mode, unsigned start, unsigned count)
 {
-       struct nouveau_channel *chan = nv30->nvws->channel;
+       struct nouveau_channel *chan = nv30->screen->base.channel;
 
        while (count) {
                uint16_t *elts = (uint16_t *)ib + start;
@@ -326,7 +326,7 @@ static INLINE void
 nv30_draw_elements_u32(struct nv30_context *nv30, void *ib,
                       unsigned mode, unsigned start, unsigned count)
 {
-       struct nouveau_channel *chan = nv30->nvws->channel;
+       struct nouveau_channel *chan = nv30->screen->base.channel;
 
        while (count) {
                uint32_t *elts = (uint32_t *)ib + start;
@@ -368,10 +368,10 @@ nv30_draw_elements_inline(struct pipe_context *pipe,
                          unsigned mode, unsigned start, unsigned count)
 {
        struct nv30_context *nv30 = nv30_context(pipe);
-       struct pipe_winsys *ws = pipe->winsys;
+       struct pipe_screen *pscreen = pipe->screen;
        void *map;
 
-       map = ws->buffer_map(ws, ib, PIPE_BUFFER_USAGE_CPU_READ);
+       map = pipe_buffer_map(pscreen, ib, PIPE_BUFFER_USAGE_CPU_READ);
        if (!ib) {
                NOUVEAU_ERR("failed mapping ib\n");
                return FALSE;
@@ -392,7 +392,7 @@ nv30_draw_elements_inline(struct pipe_context *pipe,
                break;
        }
 
-       ws->buffer_unmap(ws, ib);
+       pipe_buffer_unmap(pscreen, ib);
        return TRUE;
 }
 
@@ -401,7 +401,7 @@ nv30_draw_elements_vbo(struct pipe_context *pipe,
                       unsigned mode, unsigned start, unsigned count)
 {
        struct nv30_context *nv30 = nv30_context(pipe);
-       struct nouveau_channel *chan = nv30->nvws->channel;
+       struct nouveau_channel *chan = nv30->screen->base.channel;
        unsigned restart = 0;
 
        while (count) {
@@ -521,18 +521,20 @@ nv30_vbo_validate(struct nv30_context *nv30)
                        return FALSE;
                }
 
-               so_reloc(vtxbuf, vb->buffer, vb->buffer_offset + ve->src_offset,
-                        vb_flags | NOUVEAU_BO_LOW | NOUVEAU_BO_OR,
-                        0, NV34TCL_VTXBUF_ADDRESS_DMA1);
+               so_reloc(vtxbuf, nouveau_bo(vb->buffer), vb->buffer_offset +
+                                ve->src_offset, vb_flags | NOUVEAU_BO_LOW |
+                                NOUVEAU_BO_OR, 0, NV34TCL_VTXBUF_ADDRESS_DMA1);
                so_data (vtxfmt, ((vb->stride << NV34TCL_VTXFMT_STRIDE_SHIFT) |
                                  (ncomp << NV34TCL_VTXFMT_SIZE_SHIFT) | type));
        }
 
        if (ib) {
+               struct nouveau_bo *bo = nouveau_bo(ib);
+
                so_method(vtxbuf, rankine, NV34TCL_IDXBUF_ADDRESS, 2);
-               so_reloc (vtxbuf, ib, 0, vb_flags | NOUVEAU_BO_LOW, 0, 0);
-               so_reloc (vtxbuf, ib, ib_format, vb_flags | NOUVEAU_BO_OR,
-                         0, NV34TCL_IDXBUF_FORMAT_DMA1);
+               so_reloc (vtxbuf, bo, 0, vb_flags | NOUVEAU_BO_LOW, 0, 0);
+               so_reloc (vtxbuf, bo, ib_format, vb_flags | NOUVEAU_BO_OR,
+                                 0, NV34TCL_IDXBUF_FORMAT_DMA1);
        }
 
        so_method(vtxbuf, rankine, 0x1710, 1);
index eaf543b8f791568cbf78a43c3ed796505c1d5feb..c7514efcfeaf6d753e6bc6c6b0c42dc09ef9f487 100644 (file)
@@ -1,6 +1,7 @@
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_state.h"
+#include "pipe/p_inlines.h"
 
 #include "pipe/p_shader_tokens.h"
 #include "tgsi/tgsi_parse.h"
@@ -645,8 +646,7 @@ out_err:
 static boolean
 nv30_vertprog_validate(struct nv30_context *nv30)
 { 
-       struct nouveau_winsys *nvws = nv30->nvws;
-       struct pipe_winsys *ws = nv30->pipe.winsys;
+       struct pipe_screen *pscreen = nv30->pipe.screen;
        struct nouveau_grobj *rankine = nv30->screen->rankine;
        struct nv30_vertex_program *vp;
        struct pipe_buffer *constbuf;
@@ -669,15 +669,15 @@ nv30_vertprog_validate(struct nv30_context *nv30)
                struct nouveau_stateobj *so;
                uint vplen = vp->nr_insns;
 
-               if (nvws->res_alloc(heap, vplen, vp, &vp->exec)) {
+               if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec)) {
                        while (heap->next && heap->size < vplen) {
                                struct nv30_vertex_program *evict;
                                
                                evict = heap->next->priv;
-                               nvws->res_free(&evict->exec);
+                               nouveau_resource_free(&evict->exec);
                        }
 
-                       if (nvws->res_alloc(heap, vplen, vp, &vp->exec))
+                       if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec))
                                assert(0);
                }
 
@@ -694,15 +694,16 @@ nv30_vertprog_validate(struct nv30_context *nv30)
        if (vp->nr_consts && !vp->data) {
                struct nouveau_resource *heap = nv30->screen->vp_data_heap;
 
-               if (nvws->res_alloc(heap, vp->nr_consts, vp, &vp->data)) {
+               if (nouveau_resource_alloc(heap, vp->nr_consts, vp, &vp->data)) {
                        while (heap->next && heap->size < vp->nr_consts) {
                                struct nv30_vertex_program *evict;
                                
                                evict = heap->next->priv;
-                               nvws->res_free(&evict->data);
+                               nouveau_resource_free(&evict->data);
                        }
 
-                       if (nvws->res_alloc(heap, vp->nr_consts, vp, &vp->data))
+                       if (nouveau_resource_alloc(heap, vp->nr_consts, vp,
+                                                  &vp->data))
                                assert(0);
                }
 
@@ -750,8 +751,8 @@ nv30_vertprog_validate(struct nv30_context *nv30)
                float *map = NULL;
 
                if (constbuf) {
-                       map = ws->buffer_map(ws, constbuf,
-                                            PIPE_BUFFER_USAGE_CPU_READ);
+                       map = pipe_buffer_map(pscreen, constbuf,
+                                             PIPE_BUFFER_USAGE_CPU_READ);
                }
 
                for (i = 0; i < vp->nr_consts; i++) {
@@ -771,9 +772,8 @@ nv30_vertprog_validate(struct nv30_context *nv30)
                        OUT_RINGp ((uint32_t *)vpd->value, 4);
                }
 
-               if (constbuf) {
-                       ws->buffer_unmap(ws, constbuf);
-               }
+               if (constbuf)
+                       pipe_buffer_unmap(pscreen, constbuf);
        }
 
        /* Upload vtxprog */
@@ -804,8 +804,6 @@ nv30_vertprog_validate(struct nv30_context *nv30)
 void
 nv30_vertprog_destroy(struct nv30_context *nv30, struct nv30_vertex_program *vp)
 {
-       struct nouveau_winsys *nvws = nv30->screen->nvws;
-
        vp->translated = FALSE;
 
        if (vp->nr_insns) {
@@ -820,9 +818,9 @@ nv30_vertprog_destroy(struct nv30_context *nv30, struct nv30_vertex_program *vp)
                vp->nr_consts = 0;
        }
 
-       nvws->res_free(&vp->exec);
+       nouveau_resource_free(&vp->exec);
        vp->exec_start = 0;
-       nvws->res_free(&vp->data);
+       nouveau_resource_free(&vp->data);
        vp->data_start = 0;
        vp->data_start_min = 0;
 
index c83ff91d7e35c968756e3417478b821cf9050de1..b2f19ecb699826bccd729640a6834b7dca64cf6e 100644 (file)
@@ -1,4 +1,5 @@
 #include "pipe/p_shader_tokens.h"
+#include "pipe/p_inlines.h"
 
 #include "util/u_pack_color.h"
 
@@ -81,7 +82,7 @@ nv40_render_prim(struct draw_stage *stage, struct prim_header *prim,
 {
        struct nv40_render_stage *rs = nv40_render_stage(stage);
        struct nv40_context *nv40 = rs->nv40;
-       struct nouveau_pushbuf *pb = nv40->nvws->channel->pushbuf;
+       struct nouveau_pushbuf *pb = nv40->screen->base.channel->pushbuf;
        unsigned i;
 
        /* Ensure there's room for 4xfloat32 + potentially 3 begin/end */
@@ -231,7 +232,7 @@ nv40_draw_elements_swtnl(struct pipe_context *pipe,
                         unsigned mode, unsigned start, unsigned count)
 {
        struct nv40_context *nv40 = nv40_context(pipe);
-       struct pipe_winsys *ws = pipe->winsys;
+       struct pipe_screen *pscreen = pipe->screen;
        unsigned i;
        void *map;
 
@@ -241,13 +242,14 @@ nv40_draw_elements_swtnl(struct pipe_context *pipe,
        nv40_state_emit(nv40);
 
        for (i = 0; i < nv40->vtxbuf_nr; i++) {
-               map = ws->buffer_map(ws, nv40->vtxbuf[i].buffer,
+               map = pipe_buffer_map(pscreen, nv40->vtxbuf[i].buffer,
                                       PIPE_BUFFER_USAGE_CPU_READ);
                draw_set_mapped_vertex_buffer(nv40->draw, i, map);
        }
 
        if (idxbuf) {
-               map = ws->buffer_map(ws, idxbuf, PIPE_BUFFER_USAGE_CPU_READ);
+               map = pipe_buffer_map(pscreen, idxbuf,
+                                     PIPE_BUFFER_USAGE_CPU_READ);
                draw_set_mapped_element_buffer(nv40->draw, idxbuf_size, map);
        } else {
                draw_set_mapped_element_buffer(nv40->draw, 0, NULL);
@@ -256,21 +258,22 @@ nv40_draw_elements_swtnl(struct pipe_context *pipe,
        if (nv40->constbuf[PIPE_SHADER_VERTEX]) {
                const unsigned nr = nv40->constbuf_nr[PIPE_SHADER_VERTEX];
 
-               map = ws->buffer_map(ws, nv40->constbuf[PIPE_SHADER_VERTEX],
-                                    PIPE_BUFFER_USAGE_CPU_READ);
+               map = pipe_buffer_map(pscreen,
+                                     nv40->constbuf[PIPE_SHADER_VERTEX],
+                                     PIPE_BUFFER_USAGE_CPU_READ);
                draw_set_mapped_constant_buffer(nv40->draw, map, nr);
        }
 
        draw_arrays(nv40->draw, mode, start, count);
 
        for (i = 0; i < nv40->vtxbuf_nr; i++)
-               ws->buffer_unmap(ws, nv40->vtxbuf[i].buffer);
+               pipe_buffer_unmap(pscreen, nv40->vtxbuf[i].buffer);
 
        if (idxbuf)
-               ws->buffer_unmap(ws, idxbuf);
+               pipe_buffer_unmap(pscreen, idxbuf);
 
        if (nv40->constbuf[PIPE_SHADER_VERTEX])
-               ws->buffer_unmap(ws, nv40->constbuf[PIPE_SHADER_VERTEX]);
+               pipe_buffer_unmap(pscreen, nv40->constbuf[PIPE_SHADER_VERTEX]);
 
        draw_flush(nv40->draw);
        pipe->flush(pipe, 0, NULL);
index 16e40889ec302fc1f1cbd71028b68ef859e1f7d3..680976da56b5a3a48216fbcdbc996219d44cc0d9 100644 (file)
@@ -1,6 +1,7 @@
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_state.h"
+#include "pipe/p_inlines.h"
 
 #include "pipe/p_shader_tokens.h"
 #include "tgsi/tgsi_parse.h"
@@ -881,12 +882,12 @@ static void
 nv40_fragprog_upload(struct nv40_context *nv40,
                     struct nv40_fragment_program *fp)
 {
-       struct pipe_winsys *ws = nv40->pipe.winsys;
+       struct pipe_screen *pscreen = nv40->pipe.screen;
        const uint32_t le = 1;
        uint32_t *map;
        int i;
 
-       map = ws->buffer_map(ws, fp->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
+       map = pipe_buffer_map(pscreen, fp->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
 
 #if 0
        for (i = 0; i < fp->insn_len; i++) {
@@ -908,7 +909,7 @@ nv40_fragprog_upload(struct nv40_context *nv40,
                }
        }
 
-       ws->buffer_unmap(ws, fp->buffer);
+       pipe_buffer_unmap(pscreen, fp->buffer);
 }
 
 static boolean
@@ -917,8 +918,7 @@ nv40_fragprog_validate(struct nv40_context *nv40)
        struct nv40_fragment_program *fp = nv40->fragprog;
        struct pipe_buffer *constbuf =
                nv40->constbuf[PIPE_SHADER_FRAGMENT];
-       struct pipe_screen *screen = nv40->pipe.screen;
-       struct pipe_winsys *ws = nv40->pipe.winsys;
+       struct pipe_screen *pscreen = nv40->pipe.screen;
        struct nouveau_stateobj *so;
        boolean new_consts = FALSE;
        int i;
@@ -933,14 +933,15 @@ nv40_fragprog_validate(struct nv40_context *nv40)
                return FALSE;
        }
 
-       fp->buffer = screen->buffer_create(screen, 0x100, 0, fp->insn_len * 4);
+       fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4);
        nv40_fragprog_upload(nv40, fp);
 
        so = so_new(4, 1);
        so_method(so, nv40->screen->curie, NV40TCL_FP_ADDRESS, 1);
-       so_reloc (so, fp->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART |
-                 NOUVEAU_BO_RD | NOUVEAU_BO_LOW | NOUVEAU_BO_OR,
-                 NV40TCL_FP_ADDRESS_DMA0, NV40TCL_FP_ADDRESS_DMA1);
+       so_reloc (so, nouveau_bo(fp->buffer), 0, NOUVEAU_BO_VRAM |
+                     NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW |
+                     NOUVEAU_BO_OR, NV40TCL_FP_ADDRESS_DMA0,
+                     NV40TCL_FP_ADDRESS_DMA1);
        so_method(so, nv40->screen->curie, NV40TCL_FP_CONTROL, 1);
        so_data  (so, fp->fp_control);
        so_ref(so, &fp->so);
@@ -950,7 +951,8 @@ update_constants:
        if (fp->nr_consts) {
                float *map;
                
-               map = ws->buffer_map(ws, constbuf, PIPE_BUFFER_USAGE_CPU_READ);
+               map = pipe_buffer_map(pscreen, constbuf,
+                                     PIPE_BUFFER_USAGE_CPU_READ);
                for (i = 0; i < fp->nr_consts; i++) {
                        struct nv40_fragment_program_data *fpd = &fp->consts[i];
                        uint32_t *p = &fp->insn[fpd->offset];
@@ -961,7 +963,7 @@ update_constants:
                        memcpy(p, cb, 4 * sizeof(float));
                        new_consts = TRUE;
                }
-               ws->buffer_unmap(ws, constbuf);
+               pipe_buffer_unmap(pscreen, constbuf);
 
                if (new_consts)
                        nv40_fragprog_upload(nv40, fp);
index eb3002dc05387bfbab4153a6bedcf13e353f9e84..f6cdf31dfee282093fdccb91186821b4cba4bca8 100644 (file)
@@ -62,6 +62,7 @@ nv40_fragtex_build(struct nv40_context *nv40, int unit)
 {
        struct nv40_sampler_state *ps = nv40->tex_sampler[unit];
        struct nv40_miptree *nv40mt = nv40->tex_miptree[unit];
+       struct nouveau_bo *bo = nouveau_bo(nv40mt->buffer);
        struct pipe_texture *pt = &nv40mt->base;
        struct nv40_texture_format *tf;
        struct nouveau_stateobj *so;
@@ -108,9 +109,9 @@ nv40_fragtex_build(struct nv40_context *nv40, int unit)
 
        so = so_new(16, 2);
        so_method(so, nv40->screen->curie, NV40TCL_TEX_OFFSET(unit), 8);
-       so_reloc (so, nv40mt->buffer, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0);
-       so_reloc (so, nv40mt->buffer, txf, tex_flags | NOUVEAU_BO_OR,
-                 NV40TCL_TEX_FORMAT_DMA0, NV40TCL_TEX_FORMAT_DMA1);
+       so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0);
+       so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,
+                     NV40TCL_TEX_FORMAT_DMA0, NV40TCL_TEX_FORMAT_DMA1);
        so_data  (so, ps->wrap);
        so_data  (so, NV40TCL_TEX_ENABLE_ENABLE | ps->en);
        so_data  (so, txs);
index 9b9a43f49dffa5aec0b0d45eaba41b0d1c206ee0..7874aedd428ae61e79c47107a3f9b33b865d5a22 100644 (file)
@@ -29,11 +29,10 @@ nv40_query_create(struct pipe_context *pipe, unsigned query_type)
 static void
 nv40_query_destroy(struct pipe_context *pipe, struct pipe_query *pq)
 {
-       struct nv40_context *nv40 = nv40_context(pipe);
        struct nv40_query *q = nv40_query(pq);
 
        if (q->object)
-               nv40->nvws->res_free(&q->object);
+               nouveau_resource_free(&q->object);
        FREE(q);
 }
 
@@ -54,9 +53,9 @@ nv40_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
                pipe->get_query_result(pipe, pq, 1, &tmp);
        }
 
-       if (nv40->nvws->res_alloc(nv40->screen->query_heap, 1, NULL, &q->object))
+       if (nouveau_resource_alloc(nv40->screen->query_heap, 1, NULL, &q->object))
                assert(0);
-       nv40->nvws->notifier_reset(nv40->screen->query, q->object->start);
+       nouveau_notifier_reset(nv40->screen->query, q->object->start);
 
        BEGIN_RING(curie, NV40TCL_QUERY_RESET, 1);
        OUT_RING  (1);
@@ -84,27 +83,27 @@ nv40_query_result(struct pipe_context *pipe, struct pipe_query *pq,
 {
        struct nv40_context *nv40 = nv40_context(pipe);
        struct nv40_query *q = nv40_query(pq);
-       struct nouveau_winsys *nvws = nv40->nvws;
 
        assert(q->object && q->type == PIPE_QUERY_OCCLUSION_COUNTER);
 
        if (!q->ready) {
                unsigned status;
 
-               status = nvws->notifier_status(nv40->screen->query,
-                                              q->object->start);
+               status = nouveau_notifier_status(nv40->screen->query,
+                                                q->object->start);
                if (status != NV_NOTIFY_STATE_STATUS_COMPLETED) {
                        if (wait == FALSE)
                                return FALSE;
-                       nvws->notifier_wait(nv40->screen->query, q->object->start,
-                                           NV_NOTIFY_STATE_STATUS_COMPLETED,
-                                           0);
+                       nouveau_notifier_wait_status(nv40->screen->query,
+                                             q->object->start,
+                                             NV_NOTIFY_STATE_STATUS_COMPLETED,
+                                             0);
                }
 
-               q->result = nvws->notifier_retval(nv40->screen->query,
-                                                 q->object->start);
+               q->result = nouveau_notifier_return_val(nv40->screen->query,
+                                                       q->object->start);
                q->ready = TRUE;
-               nvws->res_free(&q->object);
+               nouveau_resource_free(&q->object);
        }
 
        *result = q->result;
index 0d4baefaea3dc2194c160aaa51caab00b44094df..b8b2af482a9d84bba101c52062873117480e8dc6 100644 (file)
@@ -1,5 +1,4 @@
 #include "pipe/p_screen.h"
-#include "util/u_simple_screen.h"
 
 #include "nv40_context.h"
 #include "nv40_screen.h"
@@ -8,23 +7,6 @@
 #define NV4X_GRCLASS4497_CHIPSETS 0x00005450
 #define NV6X_GRCLASS4497_CHIPSETS 0x00000088
 
-static const char *
-nv40_screen_get_name(struct pipe_screen *pscreen)
-{
-       struct nv40_screen *screen = nv40_screen(pscreen);
-       struct nouveau_device *dev = screen->nvws->channel->device;
-       static char buffer[128];
-
-       snprintf(buffer, sizeof(buffer), "NV%02X", dev->chipset);
-       return buffer;
-}
-
-static const char *
-nv40_screen_get_vendor(struct pipe_screen *pscreen)
-{
-       return "nouveau";
-}
-
 static int
 nv40_screen_get_param(struct pipe_screen *pscreen, int param)
 {
@@ -148,88 +130,107 @@ static void
 nv40_screen_destroy(struct pipe_screen *pscreen)
 {
        struct nv40_screen *screen = nv40_screen(pscreen);
-       struct nouveau_winsys *nvws = screen->nvws;
 
-       nvws->res_free(&screen->vp_exec_heap);
-       nvws->res_free(&screen->vp_data_heap);
-       nvws->res_free(&screen->query_heap);
-       nvws->notifier_free(&screen->query);
-       nvws->notifier_free(&screen->sync);
-       nvws->grobj_free(&screen->curie);
+       nouveau_resource_free(&screen->vp_exec_heap);
+       nouveau_resource_free(&screen->vp_data_heap);
+       nouveau_resource_free(&screen->query_heap);
+       nouveau_notifier_free(&screen->query);
+       nouveau_notifier_free(&screen->sync);
+       nouveau_grobj_free(&screen->curie);
+
+       nouveau_screen_fini(&screen->base);
 
        FREE(pscreen);
 }
 
 struct pipe_screen *
-nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
+nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
 {
        struct nv40_screen *screen = CALLOC_STRUCT(nv40_screen);
+       struct nouveau_channel *chan;
+       struct pipe_screen *pscreen;
        struct nouveau_stateobj *so;
        unsigned curie_class = 0;
-       unsigned chipset = nvws->channel->device->chipset;
        int ret;
 
        if (!screen)
                return NULL;
-       screen->nvws = nvws;
+       pscreen = &screen->base.base;
 
-       /* 2D engine setup */
-       screen->eng2d = nv04_surface_2d_init(nvws);
-       screen->eng2d->buf = nv40_surface_buffer;
+       ret = nouveau_screen_init(&screen->base, dev);
+       if (ret) {
+               nv40_screen_destroy(pscreen);
+               return NULL;
+       }
+       chan = screen->base.channel;
+
+       pscreen->winsys = ws;
+       pscreen->destroy = nv40_screen_destroy;
+       pscreen->get_param = nv40_screen_get_param;
+       pscreen->get_paramf = nv40_screen_get_paramf;
+       pscreen->is_format_supported = nv40_screen_surface_format_supported;
+
+       nv40_screen_init_miptree_functions(pscreen);
+       nv40_screen_init_transfer_functions(pscreen);
 
        /* 3D object */
-       switch (chipset & 0xf0) {
+       switch (dev->chipset & 0xf0) {
        case 0x40:
-               if (NV4X_GRCLASS4097_CHIPSETS & (1 << (chipset & 0x0f)))
+               if (NV4X_GRCLASS4097_CHIPSETS & (1 << (dev->chipset & 0x0f)))
                        curie_class = NV40TCL;
                else
-               if (NV4X_GRCLASS4497_CHIPSETS & (1 << (chipset & 0x0f)))
+               if (NV4X_GRCLASS4497_CHIPSETS & (1 << (dev->chipset & 0x0f)))
                        curie_class = NV44TCL;
                break;
        case 0x60:
-               if (NV6X_GRCLASS4497_CHIPSETS & (1 << (chipset & 0x0f)))
+               if (NV6X_GRCLASS4497_CHIPSETS & (1 << (dev->chipset & 0x0f)))
                        curie_class = NV44TCL;
                break;
        }
 
        if (!curie_class) {
-               NOUVEAU_ERR("Unknown nv4x chipset: nv%02x\n", chipset);
+               NOUVEAU_ERR("Unknown nv4x chipset: nv%02x\n", dev->chipset);
                return NULL;
        }
 
-       ret = nvws->grobj_alloc(nvws, curie_class, &screen->curie);
+       ret = nouveau_grobj_alloc(chan, 0xbeef3097, curie_class, &screen->curie);
        if (ret) {
                NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
                return FALSE;
        }
+       BIND_RING(chan, screen->curie, 7);
+
+       /* 2D engine setup */
+       screen->eng2d = nv04_surface_2d_init(&screen->base);
+       screen->eng2d->buf = nv40_surface_buffer;
 
        /* Notifier for sync purposes */
-       ret = nvws->notifier_alloc(nvws, 1, &screen->sync);
+       ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync);
        if (ret) {
                NOUVEAU_ERR("Error creating notifier object: %d\n", ret);
-               nv40_screen_destroy(&screen->pipe);
+               nv40_screen_destroy(pscreen);
                return NULL;
        }
 
        /* Query objects */
-       ret = nvws->notifier_alloc(nvws, 32, &screen->query);
+       ret = nouveau_notifier_alloc(chan, 0xbeef0302, 32, &screen->query);
        if (ret) {
                NOUVEAU_ERR("Error initialising query objects: %d\n", ret);
-               nv40_screen_destroy(&screen->pipe);
+               nv40_screen_destroy(pscreen);
                return NULL;
        }
 
-       ret = nvws->res_init(&screen->query_heap, 0, 32);
+       nouveau_resource_init(&screen->query_heap, 0, 32);
        if (ret) {
                NOUVEAU_ERR("Error initialising query object heap: %d\n", ret);
-               nv40_screen_destroy(&screen->pipe);
+               nv40_screen_destroy(pscreen);
                return NULL;
        }
 
        /* Vtxprog resources */
-       if (nvws->res_init(&screen->vp_exec_heap, 0, 512) ||
-           nvws->res_init(&screen->vp_data_heap, 0, 256)) {
-               nv40_screen_destroy(&screen->pipe);
+       if (nouveau_resource_init(&screen->vp_exec_heap, 0, 512) ||
+           nouveau_resource_init(&screen->vp_data_heap, 0, 256)) {
+               nv40_screen_destroy(pscreen);
                return NULL;
        }
 
@@ -238,25 +239,25 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
        so_method(so, screen->curie, NV40TCL_DMA_NOTIFY, 1);
        so_data  (so, screen->sync->handle);
        so_method(so, screen->curie, NV40TCL_DMA_TEXTURE0, 2);
-       so_data  (so, nvws->channel->vram->handle);
-       so_data  (so, nvws->channel->gart->handle);
+       so_data  (so, chan->vram->handle);
+       so_data  (so, chan->gart->handle);
        so_method(so, screen->curie, NV40TCL_DMA_COLOR1, 1);
-       so_data  (so, nvws->channel->vram->handle);
+       so_data  (so, chan->vram->handle);
        so_method(so, screen->curie, NV40TCL_DMA_COLOR0, 2);
-       so_data  (so, nvws->channel->vram->handle);
-       so_data  (so, nvws->channel->vram->handle);
+       so_data  (so, chan->vram->handle);
+       so_data  (so, chan->vram->handle);
        so_method(so, screen->curie, NV40TCL_DMA_VTXBUF0, 2);
-       so_data  (so, nvws->channel->vram->handle);
-       so_data  (so, nvws->channel->gart->handle);
+       so_data  (so, chan->vram->handle);
+       so_data  (so, chan->gart->handle);
        so_method(so, screen->curie, NV40TCL_DMA_FENCE, 2);
        so_data  (so, 0);
        so_data  (so, screen->query->handle);
        so_method(so, screen->curie, NV40TCL_DMA_UNK01AC, 2);
-       so_data  (so, nvws->channel->vram->handle);
-       so_data  (so, nvws->channel->vram->handle);
+       so_data  (so, chan->vram->handle);
+       so_data  (so, chan->vram->handle);
        so_method(so, screen->curie, NV40TCL_DMA_COLOR2, 2);
-       so_data  (so, nvws->channel->vram->handle);
-       so_data  (so, nvws->channel->vram->handle);
+       so_data  (so, chan->vram->handle);
+       so_data  (so, chan->vram->handle);
 
        so_method(so, screen->curie, 0x1ea4, 3);
        so_data  (so, 0x00000010);
@@ -281,24 +282,10 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
        so_method(so, screen->curie, 0x1e94, 1);
        so_data  (so, 0x00000001);
 
-       so_emit(nvws, so);
+       so_emit(chan, so);
        so_ref(NULL, &so);
-       nvws->push_flush(nvws, 0, NULL);
-
-       screen->pipe.winsys = ws;
-       screen->pipe.destroy = nv40_screen_destroy;
-
-       screen->pipe.get_name = nv40_screen_get_name;
-       screen->pipe.get_vendor = nv40_screen_get_vendor;
-       screen->pipe.get_param = nv40_screen_get_param;
-       screen->pipe.get_paramf = nv40_screen_get_paramf;
-
-       screen->pipe.is_format_supported = nv40_screen_surface_format_supported;
-
-       nv40_screen_init_miptree_functions(&screen->pipe);
-       nv40_screen_init_transfer_functions(&screen->pipe);
-       u_simple_screen_init(&screen->pipe);
+       nouveau_pushbuf_flush(chan, 0);
 
-       return &screen->pipe;
+       return pscreen;
 }
 
index 7b503bd207dfda69c7793bbccec3f87396c06986..57b4c8fc46cda9ca7f1be5cd8c798e9efeb2acff 100644 (file)
@@ -1,11 +1,11 @@
 #ifndef __NV40_SCREEN_H__
 #define __NV40_SCREEN_H__
 
-#include "pipe/p_screen.h"
+#include "nouveau/nouveau_screen.h"
 #include "nv04/nv04_surface_2d.h"
 
 struct nv40_screen {
-       struct pipe_screen pipe;
+       struct nouveau_screen base;
 
        struct nouveau_winsys *nvws;
 
index 10aae298328ef48e84b5e81b4637581622bfbd6f..198692965dc4ad3d482c2826161af03c04457524 100644 (file)
@@ -54,6 +54,7 @@ nv40_state_do_validate(struct nv40_context *nv40,
 void
 nv40_state_emit(struct nv40_context *nv40)
 {
+       struct nouveau_channel *chan = nv40->screen->base.channel;
        struct nv40_state *state = &nv40->state;
        struct nv40_screen *screen = nv40->screen;
        unsigned i, samplers;
@@ -73,7 +74,7 @@ nv40_state_emit(struct nv40_context *nv40)
                        continue;
                so_ref (state->hw[i], &nv40->screen->state[i]);
                if (state->hw[i])
-                       so_emit(nv40->nvws, nv40->screen->state[i]);
+                       so_emit(chan, nv40->screen->state[i]);
                states &= ~(1ULL << i);
        }
 
@@ -87,17 +88,17 @@ nv40_state_emit(struct nv40_context *nv40)
 
        state->dirty = 0;
 
-       so_emit_reloc_markers(nv40->nvws, state->hw[NV40_STATE_FB]);
+       so_emit_reloc_markers(chan, state->hw[NV40_STATE_FB]);
        for (i = 0, samplers = state->fp_samplers; i < 16 && samplers; i++) {
                if (!(samplers & (1 << i)))
                        continue;
-               so_emit_reloc_markers(nv40->nvws,
+               so_emit_reloc_markers(chan,
                                      state->hw[NV40_STATE_FRAGTEX0+i]);
                samplers &= ~(1ULL << i);
        }
-       so_emit_reloc_markers(nv40->nvws, state->hw[NV40_STATE_FRAGPROG]);
+       so_emit_reloc_markers(chan, state->hw[NV40_STATE_FRAGPROG]);
        if (state->hw[NV40_STATE_VTXBUF] && nv40->render_mode == HW)
-               so_emit_reloc_markers(nv40->nvws, state->hw[NV40_STATE_VTXBUF]);
+               so_emit_reloc_markers(chan, state->hw[NV40_STATE_VTXBUF]);
 }
 
 boolean
index be618a306bf739d49e7546687c9818f04e4b5dee..273142f9e0fdf5bb7358955379d839a541bf8456 100644 (file)
@@ -2,15 +2,19 @@
 #include "nouveau/nouveau_util.h"
 
 static struct pipe_buffer *
-nv40_surface_buffer(struct pipe_surface *surface)
+nv40_do_surface_buffer(struct pipe_surface *surface)
 {
        struct nv40_miptree *mt = (struct nv40_miptree *)surface->texture;
        return mt->buffer;
 }
 
+#define nv40_surface_buffer(ps) nouveau_bo(nv40_do_surface_buffer(ps))
+
 static boolean
 nv40_state_framebuffer_validate(struct nv40_context *nv40)
 {
+       struct nouveau_channel *chan = nv40->screen->base.channel;
+       struct nouveau_grobj *curie = nv40->screen->curie;
        struct pipe_framebuffer_state *fb = &nv40->framebuffer;
        struct nv04_surface *rt[4], *zeta;
        uint32_t rt_enable, rt_format;
@@ -77,76 +81,80 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
        }
 
        if (rt_enable & NV40TCL_RT_ENABLE_COLOR0) {
-               so_method(so, nv40->screen->curie, NV40TCL_DMA_COLOR0, 1);
-               so_reloc (so, nv40_surface_buffer(&rt[0]->base), 0, rt_flags | NOUVEAU_BO_OR,
-                         nv40->nvws->channel->vram->handle,
-                         nv40->nvws->channel->gart->handle);
-               so_method(so, nv40->screen->curie, NV40TCL_COLOR0_PITCH, 2);
+               so_method(so, curie, NV40TCL_DMA_COLOR0, 1);
+               so_reloc (so, nv40_surface_buffer(&rt[0]->base), 0,
+                             rt_flags | NOUVEAU_BO_OR,
+                             chan->vram->handle, chan->gart->handle);
+               so_method(so, curie, NV40TCL_COLOR0_PITCH, 2);
                so_data  (so, rt[0]->pitch);
-               so_reloc (so, nv40_surface_buffer(&rt[0]->base), rt[0]->base.offset, rt_flags |
-                         NOUVEAU_BO_LOW, 0, 0);
+               so_reloc (so, nv40_surface_buffer(&rt[0]->base),
+                             rt[0]->base.offset, rt_flags | NOUVEAU_BO_LOW,
+                             0, 0);
        }
 
        if (rt_enable & NV40TCL_RT_ENABLE_COLOR1) {
-               so_method(so, nv40->screen->curie, NV40TCL_DMA_COLOR1, 1);
-               so_reloc (so, nv40_surface_buffer(&rt[1]->base), 0, rt_flags | NOUVEAU_BO_OR,
-                         nv40->nvws->channel->vram->handle,
-                         nv40->nvws->channel->gart->handle);
-               so_method(so, nv40->screen->curie, NV40TCL_COLOR1_OFFSET, 2);
-               so_reloc (so, nv40_surface_buffer(&rt[1]->base), rt[1]->base.offset, rt_flags |
-                         NOUVEAU_BO_LOW, 0, 0);
+               so_method(so, curie, NV40TCL_DMA_COLOR1, 1);
+               so_reloc (so, nv40_surface_buffer(&rt[1]->base), 0,
+                             rt_flags | NOUVEAU_BO_OR,
+                             chan->vram->handle, chan->gart->handle);
+               so_method(so, curie, NV40TCL_COLOR1_OFFSET, 2);
+               so_reloc (so, nv40_surface_buffer(&rt[1]->base),
+                             rt[1]->base.offset, rt_flags | NOUVEAU_BO_LOW,
+                             0, 0);
                so_data  (so, rt[1]->pitch);
        }
 
        if (rt_enable & NV40TCL_RT_ENABLE_COLOR2) {
-               so_method(so, nv40->screen->curie, NV40TCL_DMA_COLOR2, 1);
-               so_reloc (so, nv40_surface_buffer(&rt[2]->base), 0, rt_flags | NOUVEAU_BO_OR,
-                         nv40->nvws->channel->vram->handle,
-                         nv40->nvws->channel->gart->handle);
-               so_method(so, nv40->screen->curie, NV40TCL_COLOR2_OFFSET, 1);
-               so_reloc (so, nv40_surface_buffer(&rt[2]->base), rt[2]->base.offset, rt_flags |
-                         NOUVEAU_BO_LOW, 0, 0);
-               so_method(so, nv40->screen->curie, NV40TCL_COLOR2_PITCH, 1);
+               so_method(so, curie, NV40TCL_DMA_COLOR2, 1);
+               so_reloc (so, nv40_surface_buffer(&rt[2]->base), 0,
+                             rt_flags | NOUVEAU_BO_OR,
+                             chan->vram->handle, chan->gart->handle);
+               so_method(so, curie, NV40TCL_COLOR2_OFFSET, 1);
+               so_reloc (so, nv40_surface_buffer(&rt[2]->base),
+                             rt[2]->base.offset, rt_flags | NOUVEAU_BO_LOW,
+                             0, 0);
+               so_method(so, curie, NV40TCL_COLOR2_PITCH, 1);
                so_data  (so, rt[2]->pitch);
        }
 
        if (rt_enable & NV40TCL_RT_ENABLE_COLOR3) {
-               so_method(so, nv40->screen->curie, NV40TCL_DMA_COLOR3, 1);
-               so_reloc (so, nv40_surface_buffer(&rt[3]->base), 0, rt_flags | NOUVEAU_BO_OR,
-                         nv40->nvws->channel->vram->handle,
-                         nv40->nvws->channel->gart->handle);
-               so_method(so, nv40->screen->curie, NV40TCL_COLOR3_OFFSET, 1);
-               so_reloc (so, nv40_surface_buffer(&rt[3]->base), rt[3]->base.offset, rt_flags |
-                         NOUVEAU_BO_LOW, 0, 0);
-               so_method(so, nv40->screen->curie, NV40TCL_COLOR3_PITCH, 1);
+               so_method(so, curie, NV40TCL_DMA_COLOR3, 1);
+               so_reloc (so, nv40_surface_buffer(&rt[3]->base), 0,
+                             rt_flags | NOUVEAU_BO_OR,
+                             chan->vram->handle, chan->gart->handle);
+               so_method(so, curie, NV40TCL_COLOR3_OFFSET, 1);
+               so_reloc (so, nv40_surface_buffer(&rt[3]->base),
+                             rt[3]->base.offset, rt_flags | NOUVEAU_BO_LOW,
+                             0, 0);
+               so_method(so, curie, NV40TCL_COLOR3_PITCH, 1);
                so_data  (so, rt[3]->pitch);
        }
 
        if (zeta_format) {
-               so_method(so, nv40->screen->curie, NV40TCL_DMA_ZETA, 1);
-               so_reloc (so, nv40_surface_buffer(&zeta->base), 0, rt_flags | NOUVEAU_BO_OR,
-                         nv40->nvws->channel->vram->handle,
-                         nv40->nvws->channel->gart->handle);
-               so_method(so, nv40->screen->curie, NV40TCL_ZETA_OFFSET, 1);
-               so_reloc (so, nv40_surface_buffer(&zeta->base), zeta->base.offset, rt_flags |
-                         NOUVEAU_BO_LOW, 0, 0);
-               so_method(so, nv40->screen->curie, NV40TCL_ZETA_PITCH, 1);
+               so_method(so, curie, NV40TCL_DMA_ZETA, 1);
+               so_reloc (so, nv40_surface_buffer(&zeta->base), 0,
+                             rt_flags | NOUVEAU_BO_OR,
+                             chan->vram->handle, chan->gart->handle);
+               so_method(so, curie, NV40TCL_ZETA_OFFSET, 1);
+               so_reloc (so, nv40_surface_buffer(&zeta->base),
+                             zeta->base.offset, rt_flags | NOUVEAU_BO_LOW, 0, 0);
+               so_method(so, curie, NV40TCL_ZETA_PITCH, 1);
                so_data  (so, zeta->pitch);
        }
 
-       so_method(so, nv40->screen->curie, NV40TCL_RT_ENABLE, 1);
+       so_method(so, curie, NV40TCL_RT_ENABLE, 1);
        so_data  (so, rt_enable);
-       so_method(so, nv40->screen->curie, NV40TCL_RT_HORIZ, 3);
+       so_method(so, curie, NV40TCL_RT_HORIZ, 3);
        so_data  (so, (w << 16) | 0);
        so_data  (so, (h << 16) | 0);
        so_data  (so, rt_format);
-       so_method(so, nv40->screen->curie, NV40TCL_VIEWPORT_HORIZ, 2);
+       so_method(so, curie, NV40TCL_VIEWPORT_HORIZ, 2);
        so_data  (so, (w << 16) | 0);
        so_data  (so, (h << 16) | 0);
-       so_method(so, nv40->screen->curie, NV40TCL_VIEWPORT_CLIP_HORIZ(0), 2);
+       so_method(so, curie, NV40TCL_VIEWPORT_CLIP_HORIZ(0), 2);
        so_data  (so, ((w - 1) << 16) | 0);
        so_data  (so, ((h - 1) << 16) | 0);
-       so_method(so, nv40->screen->curie, 0x1d88, 1);
+       so_method(so, curie, 0x1d88, 1);
        so_data  (so, (1 << 12) | h);
 
        so_ref(so, &nv40->state.hw[NV40_STATE_FB]);
index 1a849da32d71aadd3737c5b46edc35ca0a799bcb..a596547974ab27a21fb1c278f54cae45d99bee51 100644 (file)
  * 
  **************************************************************************/
 
-#include "nv40_context.h"
 #include "pipe/p_defines.h"
-#include "pipe/internal/p_winsys_screen.h"
 #include "pipe/p_inlines.h"
+
 #include "util/u_tile.h"
 
+#include "nv40_context.h"
+
 static void
 nv40_surface_copy(struct pipe_context *pipe,
                  struct pipe_surface *dest, unsigned destx, unsigned desty,
index f3518b2e4fe31323df6008b82a5f5b0cca482485..b2753b8e2e052a655a7f89c28e5d3243ec5c84ed 100644 (file)
@@ -1,5 +1,6 @@
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
+#include "pipe/p_inlines.h"
 
 #include "nv40_context.h"
 #include "nv40_state.h"
@@ -70,7 +71,7 @@ static boolean
 nv40_vbo_set_idxbuf(struct nv40_context *nv40, struct pipe_buffer *ib,
                    unsigned ib_size)
 {
-       struct pipe_screen *pscreen = &nv40->screen->pipe;
+       struct pipe_screen *pscreen = &nv40->screen->base.base;
        unsigned type;
 
        if (!ib) {
@@ -108,7 +109,7 @@ nv40_vbo_static_attrib(struct nv40_context *nv40, struct nouveau_stateobj *so,
                       int attrib, struct pipe_vertex_element *ve,
                       struct pipe_vertex_buffer *vb)
 {
-       struct pipe_winsys *ws = nv40->pipe.winsys;
+       struct pipe_screen *pscreen = nv40->pipe.screen;
        struct nouveau_grobj *curie = nv40->screen->curie;
        unsigned type, ncomp;
        void *map;
@@ -116,7 +117,7 @@ nv40_vbo_static_attrib(struct nv40_context *nv40, struct nouveau_stateobj *so,
        if (nv40_vbo_format_to_hw(ve->src_format, &type, &ncomp))
                return FALSE;
 
-       map  = ws->buffer_map(ws, vb->buffer, PIPE_BUFFER_USAGE_CPU_READ);
+       map  = pipe_buffer_map(pscreen, vb->buffer, PIPE_BUFFER_USAGE_CPU_READ);
        map += vb->buffer_offset + ve->src_offset;
 
        switch (type) {
@@ -148,17 +149,17 @@ nv40_vbo_static_attrib(struct nv40_context *nv40, struct nouveau_stateobj *so,
                        so_data  (so, fui(v[0]));
                        break;
                default:
-                       ws->buffer_unmap(ws, vb->buffer);
+                       pipe_buffer_unmap(pscreen, vb->buffer);
                        return FALSE;
                }
        }
                break;
        default:
-               ws->buffer_unmap(ws, vb->buffer);
+               pipe_buffer_unmap(pscreen, vb->buffer);
                return FALSE;
        }
 
-       ws->buffer_unmap(ws, vb->buffer);
+       pipe_buffer_unmap(pscreen, vb->buffer);
 
        return TRUE;
 }
@@ -168,7 +169,7 @@ nv40_draw_arrays(struct pipe_context *pipe,
                 unsigned mode, unsigned start, unsigned count)
 {
        struct nv40_context *nv40 = nv40_context(pipe);
-       struct nouveau_channel *chan = nv40->nvws->channel;
+       struct nouveau_channel *chan = nv40->screen->base.channel;
        unsigned restart;
 
        nv40_vbo_set_idxbuf(nv40, NULL, 0);
@@ -227,7 +228,7 @@ static INLINE void
 nv40_draw_elements_u08(struct nv40_context *nv40, void *ib,
                       unsigned mode, unsigned start, unsigned count)
 {
-       struct nouveau_channel *chan = nv40->nvws->channel;
+       struct nouveau_channel *chan = nv40->screen->base.channel;
 
        while (count) {
                uint8_t *elts = (uint8_t *)ib + start;
@@ -276,7 +277,7 @@ static INLINE void
 nv40_draw_elements_u16(struct nv40_context *nv40, void *ib,
                       unsigned mode, unsigned start, unsigned count)
 {
-       struct nouveau_channel *chan = nv40->nvws->channel;
+       struct nouveau_channel *chan = nv40->screen->base.channel;
 
        while (count) {
                uint16_t *elts = (uint16_t *)ib + start;
@@ -325,7 +326,7 @@ static INLINE void
 nv40_draw_elements_u32(struct nv40_context *nv40, void *ib,
                       unsigned mode, unsigned start, unsigned count)
 {
-       struct nouveau_channel *chan = nv40->nvws->channel;
+       struct nouveau_channel *chan = nv40->screen->base.channel;
 
        while (count) {
                uint32_t *elts = (uint32_t *)ib + start;
@@ -367,10 +368,10 @@ nv40_draw_elements_inline(struct pipe_context *pipe,
                          unsigned mode, unsigned start, unsigned count)
 {
        struct nv40_context *nv40 = nv40_context(pipe);
-       struct pipe_winsys *ws = pipe->winsys;
+       struct pipe_screen *pscreen = pipe->screen;
        void *map;
 
-       map = ws->buffer_map(ws, ib, PIPE_BUFFER_USAGE_CPU_READ);
+       map = pipe_buffer_map(pscreen, ib, PIPE_BUFFER_USAGE_CPU_READ);
        if (!ib) {
                NOUVEAU_ERR("failed mapping ib\n");
                return FALSE;
@@ -391,7 +392,7 @@ nv40_draw_elements_inline(struct pipe_context *pipe,
                break;
        }
 
-       ws->buffer_unmap(ws, ib);
+       pipe_buffer_unmap(pscreen, ib);
        return TRUE;
 }
 
@@ -400,7 +401,7 @@ nv40_draw_elements_vbo(struct pipe_context *pipe,
                       unsigned mode, unsigned start, unsigned count)
 {
        struct nv40_context *nv40 = nv40_context(pipe);
-       struct nouveau_channel *chan = nv40->nvws->channel;
+       struct nouveau_channel *chan = nv40->screen->base.channel;
        unsigned restart;
 
        while (count) {
@@ -519,17 +520,20 @@ nv40_vbo_validate(struct nv40_context *nv40)
                        return FALSE;
                }
 
-               so_reloc(vtxbuf, vb->buffer, vb->buffer_offset + ve->src_offset,
-                        vb_flags | NOUVEAU_BO_LOW | NOUVEAU_BO_OR,
-                        0, NV40TCL_VTXBUF_ADDRESS_DMA1);
+               so_reloc(vtxbuf, nouveau_bo(vb->buffer),
+                                vb->buffer_offset + ve->src_offset,
+                                vb_flags | NOUVEAU_BO_LOW | NOUVEAU_BO_OR,
+                                0, NV40TCL_VTXBUF_ADDRESS_DMA1);
                so_data (vtxfmt, ((vb->stride << NV40TCL_VTXFMT_STRIDE_SHIFT) |
                                  (ncomp << NV40TCL_VTXFMT_SIZE_SHIFT) | type));
        }
 
        if (ib) {
+               struct nouveau_bo *bo = nouveau_bo(ib);
+
                so_method(vtxbuf, curie, NV40TCL_IDXBUF_ADDRESS, 2);
-               so_reloc (vtxbuf, ib, 0, vb_flags | NOUVEAU_BO_LOW, 0, 0);
-               so_reloc (vtxbuf, ib, ib_format, vb_flags | NOUVEAU_BO_OR,
+               so_reloc (vtxbuf, bo, 0, vb_flags | NOUVEAU_BO_LOW, 0, 0);
+               so_reloc (vtxbuf, bo, ib_format, vb_flags | NOUVEAU_BO_OR,
                          0, NV40TCL_IDXBUF_FORMAT_DMA1);
        }
 
index 7df9a4d3264a9d14e8613d13ba6fcea44faebaf7..e75e8d3f4243a2fe0ba619a1056ae1a4e8665f70 100644 (file)
@@ -1,6 +1,7 @@
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_state.h"
+#include "pipe/p_inlines.h"
 
 #include "pipe/p_shader_tokens.h"
 #include "tgsi/tgsi_parse.h"
@@ -855,8 +856,7 @@ out_err:
 static boolean
 nv40_vertprog_validate(struct nv40_context *nv40)
 { 
-       struct nouveau_winsys *nvws = nv40->nvws;
-       struct pipe_winsys *ws = nv40->pipe.winsys;
+       struct pipe_screen *pscreen = nv40->pipe.screen;
        struct nouveau_grobj *curie = nv40->screen->curie;
        struct nv40_vertex_program *vp;
        struct pipe_buffer *constbuf;
@@ -895,15 +895,15 @@ check_gpu_resources:
                struct nouveau_stateobj *so;
                uint vplen = vp->nr_insns;
 
-               if (nvws->res_alloc(heap, vplen, vp, &vp->exec)) {
+               if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec)) {
                        while (heap->next && heap->size < vplen) {
                                struct nv40_vertex_program *evict;
                                
                                evict = heap->next->priv;
-                               nvws->res_free(&evict->exec);
+                               nouveau_resource_free(&evict->exec);
                        }
 
-                       if (nvws->res_alloc(heap, vplen, vp, &vp->exec))
+                       if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec))
                                assert(0);
                }
 
@@ -925,15 +925,15 @@ check_gpu_resources:
        if (vp->nr_consts && !vp->data) {
                struct nouveau_resource *heap = nv40->screen->vp_data_heap;
 
-               if (nvws->res_alloc(heap, vp->nr_consts, vp, &vp->data)) {
+               if (nouveau_resource_alloc(heap, vp->nr_consts, vp, &vp->data)) {
                        while (heap->next && heap->size < vp->nr_consts) {
                                struct nv40_vertex_program *evict;
                                
                                evict = heap->next->priv;
-                               nvws->res_free(&evict->data);
+                               nouveau_resource_free(&evict->data);
                        }
 
-                       if (nvws->res_alloc(heap, vp->nr_consts, vp, &vp->data))
+                       if (nouveau_resource_alloc(heap, vp->nr_consts, vp, &vp->data))
                                assert(0);
                }
 
@@ -981,8 +981,8 @@ check_gpu_resources:
                float *map = NULL;
 
                if (constbuf) {
-                       map = ws->buffer_map(ws, constbuf,
-                                            PIPE_BUFFER_USAGE_CPU_READ);
+                       map = pipe_buffer_map(pscreen, constbuf,
+                                             PIPE_BUFFER_USAGE_CPU_READ);
                }
 
                for (i = 0; i < vp->nr_consts; i++) {
@@ -1003,7 +1003,7 @@ check_gpu_resources:
                }
 
                if (constbuf)
-                       ws->buffer_unmap(ws, constbuf);
+                       pscreen->buffer_unmap(pscreen, constbuf);
        }
 
        /* Upload vtxprog */
@@ -1035,8 +1035,6 @@ check_gpu_resources:
 void
 nv40_vertprog_destroy(struct nv40_context *nv40, struct nv40_vertex_program *vp)
 {
-       struct nouveau_winsys *nvws = nv40->screen->nvws;
-
        vp->translated = FALSE;
 
        if (vp->nr_insns) {
@@ -1051,9 +1049,9 @@ nv40_vertprog_destroy(struct nv40_context *nv40, struct nv40_vertex_program *vp)
                vp->nr_consts = 0;
        }
 
-       nvws->res_free(&vp->exec);
+       nouveau_resource_free(&vp->exec);
        vp->exec_start = 0;
-       nvws->res_free(&vp->data);
+       nouveau_resource_free(&vp->data);
        vp->data_start = 0;
        vp->data_start_min = 0;
 
index 33427a15a566eed9c8360be1373d7c4f7dfb21ff..e0b2d2880b00b1e42bfe7d02a3ba121ea06c208b 100644 (file)
@@ -31,7 +31,7 @@ nv50_clear(struct pipe_context *pipe, unsigned buffers,
           const float *rgba, double depth, unsigned stencil)
 {
        struct nv50_context *nv50 = nv50_context(pipe);
-       struct nouveau_channel *chan = nv50->screen->nvws->channel;
+       struct nouveau_channel *chan = nv50->screen->base.channel;
        struct nouveau_grobj *tesla = nv50->screen->tesla;
        struct pipe_framebuffer_state *fb = &nv50->framebuffer;
        unsigned mode = 0, i;
index a511f655c19e1c4c0e27fc846c5bc5a93446f182..e02afc4be9901c48b36ab5aaab9f7877174624d2 100644 (file)
@@ -33,7 +33,7 @@ nv50_flush(struct pipe_context *pipe, unsigned flags,
 {
        struct nv50_context *nv50 = (struct nv50_context *)pipe;
        
-       FIRE_RING(nv50->screen->nvws->channel);
+       FIRE_RING(nv50->screen->base.channel);
 }
 
 static void
index 7b67a7543978e643bc39e4fa7c39e960e45ced6f..9b8cc4d37d03397087b175bea37e17ebb055b608 100644 (file)
@@ -63,6 +63,11 @@ struct nv50_rasterizer_stateobj {
        struct nouveau_stateobj *so;
 };
 
+struct nv50_sampler_stateobj {
+       bool normalized;
+       unsigned tsc[8];
+};
+
 struct nv50_miptree_level {
        int *image_offset;
        unsigned pitch;
@@ -70,7 +75,8 @@ struct nv50_miptree_level {
 
 struct nv50_miptree {
        struct pipe_texture base;
-       struct pipe_buffer *buffer;
+
+       struct nouveau_bo *bo;
 
        struct nv50_miptree_level level[PIPE_MAX_TEXTURE_LEVELS];
        int image_nr;
@@ -93,13 +99,6 @@ nv50_surface(struct pipe_surface *pt)
        return (struct nv50_surface *)pt;
 }
 
-static INLINE struct pipe_buffer *
-nv50_surface_buffer(struct pipe_surface *surface)
-{
-       struct nv50_miptree *mt = (struct nv50_miptree *)surface->texture;
-       return mt->buffer;
-}
-
 struct nv50_state {
        unsigned dirty;
 
@@ -115,6 +114,7 @@ struct nv50_state {
        unsigned viewport_bypass;
        struct nouveau_stateobj *tsc_upload;
        struct nouveau_stateobj *tic_upload;
+       unsigned miptree_nr;
        struct nouveau_stateobj *vertprog;
        struct nouveau_stateobj *fragprog;
        struct nouveau_stateobj *vtxfmt;
@@ -147,7 +147,7 @@ struct nv50_context {
        unsigned vtxbuf_nr;
        struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS];
        unsigned vtxelt_nr;
-       unsigned *sampler[PIPE_MAX_SAMPLERS];
+       struct nv50_sampler_stateobj *sampler[PIPE_MAX_SAMPLERS];
        unsigned sampler_nr;
        struct nv50_miptree *miptree[PIPE_MAX_SAMPLERS];
        unsigned miptree_nr;
index f79a7ca86c9d96a85c07e9bea7ef12e6a1e541b8..6b605ba416caa12dd18349fc84cbbe9b1df45b90 100644 (file)
 static struct pipe_texture *
 nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
 {
+       struct nouveau_device *dev = nouveau_screen(pscreen)->device;
        struct nv50_miptree *mt = CALLOC_STRUCT(nv50_miptree);
        struct pipe_texture *pt = &mt->base;
-       unsigned usage, width = tmp->width[0], height = tmp->height[0];
+       unsigned width = tmp->width[0], height = tmp->height[0];
        unsigned depth = tmp->depth[0];
-       int i, l;
+       uint32_t tile_mode, tile_flags, tile_h;
+       int ret, i, l;
 
        mt->base = *tmp;
        pipe_reference_init(&mt->base.reference, 1);
        mt->base.screen = pscreen;
 
-       usage = PIPE_BUFFER_USAGE_PIXEL;
        switch (pt->format) {
        case PIPE_FORMAT_Z24S8_UNORM:
        case PIPE_FORMAT_Z16_UNORM:
-               usage |= NOUVEAU_BUFFER_USAGE_ZETA;
+               tile_flags = 0x2800;
                break;
        default:
+               tile_flags = 0x7000;
                break;
        }
 
+       if      (pt->height[0] > 32) tile_mode = 4;
+       else if (pt->height[0] > 16) tile_mode = 3;
+       else if (pt->height[0] >  8) tile_mode = 2;
+       else if (pt->height[0] >  4) tile_mode = 1;
+       else                         tile_mode = 0;
+       tile_h = 1 << (tile_mode + 2);
+
        switch (pt->target) {
        case PIPE_TEXTURE_3D:
                mt->image_nr = pt->depth[0];
@@ -85,7 +94,7 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
 
                        size  = align(pt->width[l], 8) * pt->block.size;
                        size  = align(size, 64);
-                       size *= align(pt->height[l], 8) * pt->block.size;
+                       size *= align(pt->height[l], tile_h) * pt->block.size;
 
                        lvl->image_offset[i] = mt->total_size;
 
@@ -93,12 +102,13 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
                }
        }
 
-       mt->buffer = pscreen->buffer_create(pscreen, 256, usage, mt->total_size);
-       if (!mt->buffer) {
+       ret = nouveau_bo_new_tile(dev, NOUVEAU_BO_VRAM, 256, mt->total_size,
+                                 tile_mode, tile_flags, &mt->bo);
+       if (ret) {
                FREE(mt);
                return NULL;
        }
-
+                            
        return &mt->base;
 }
 
@@ -106,6 +116,7 @@ static struct pipe_texture *
 nv50_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
                     const unsigned *stride, struct pipe_buffer *pb)
 {
+       struct nouveau_bo *bo = nouveau_bo(pb);
        struct nv50_miptree *mt;
 
        /* Only supports 2D, non-mipmapped textures for the moment */
@@ -124,7 +135,7 @@ nv50_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
        mt->level[0].pitch = *stride;
        mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
 
-       pipe_buffer_reference(&mt->buffer, pb);
+       nouveau_bo_ref(bo, &mt->bo);
        return &mt->base;
 }
 
@@ -133,7 +144,7 @@ nv50_miptree_destroy(struct pipe_texture *pt)
 {
        struct nv50_miptree *mt = nv50_miptree(pt);
 
-        pipe_buffer_reference(&mt->buffer, NULL);
+       nouveau_bo_ref(NULL, &mt->bo);
         FREE(mt);
 }
 
index 2d15868ae8439f4abcf2f178acd9b3c69a9813f5..5f7d06dbecbf6479aa522444da28c2281f74d8fc 100644 (file)
@@ -85,6 +85,9 @@ struct nv50_reg {
 
        int hw;
        int neg;
+
+       int rhw; /* result hw for FP outputs, or interpolant index */
+       int acc; /* instruction where this reg is last read (first insn == 1) */
 };
 
 struct nv50_pc {
@@ -108,12 +111,23 @@ struct nv50_pc {
 
        struct nv50_reg *temp_temp[16];
        unsigned temp_temp_nr;
+
+       unsigned interp_mode[32];
+       /* perspective interpolation registers */
+       struct nv50_reg *iv_p;
+       struct nv50_reg *iv_c;
+
+       /* current instruction and total number of insns */
+       unsigned insn_cur;
+       unsigned insn_nr;
+
+       boolean allow32;
 };
 
 static void
 alloc_reg(struct nv50_pc *pc, struct nv50_reg *reg)
 {
-       int i;
+       int i = 0;
 
        if (reg->type == P_RESULT) {
                if (pc->p->cfg.high_result < (reg->hw + 1))
@@ -131,7 +145,22 @@ alloc_reg(struct nv50_pc *pc, struct nv50_reg *reg)
                return;
        }
 
-       for (i = 0; i < NV50_SU_MAX_TEMP; i++) {
+       if (reg->rhw != -1) {
+               /* try to allocate temporary with index rhw first */
+               if (!(pc->r_temp[reg->rhw])) {
+                       pc->r_temp[reg->rhw] = reg;
+                       reg->hw = reg->rhw;
+                       if (pc->p->cfg.high_temp < (reg->rhw + 1))
+                               pc->p->cfg.high_temp = reg->rhw + 1;
+                       return;
+               }
+               /* make sure we don't get things like $r0 needs to go
+                * in $r1 and $r1 in $r0
+                */
+               i = pc->result_nr * 4;
+       }
+
+       for (; i < NV50_SU_MAX_TEMP; i++) {
                if (!(pc->r_temp[i])) {
                        pc->r_temp[i] = reg;
                        reg->hw = i;
@@ -159,6 +188,7 @@ alloc_temp(struct nv50_pc *pc, struct nv50_reg *dst)
                        r->type = P_TEMP;
                        r->index = -1;
                        r->hw = i;
+                       r->rhw = -1;
                        pc->r_temp[i] = r;
                        return r;
                }
@@ -168,6 +198,38 @@ alloc_temp(struct nv50_pc *pc, struct nv50_reg *dst)
        return NULL;
 }
 
+/* Assign the hw of the discarded temporary register src
+ * to the tgsi register dst and free src.
+ */
+static void
+assimilate_temp(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
+{
+       assert(src->index == -1 && src->hw != -1);
+
+       if (dst->hw != -1)
+               pc->r_temp[dst->hw] = NULL;
+       pc->r_temp[src->hw] = dst;
+       dst->hw = src->hw;
+
+       FREE(src);
+}
+
+/* release the hardware resource held by r */
+static void
+release_hw(struct nv50_pc *pc, struct nv50_reg *r)
+{
+       assert(r->type == P_TEMP);
+       if (r->hw == -1)
+               return;
+
+       assert(pc->r_temp[r->hw] == r);
+       pc->r_temp[r->hw] = NULL;
+
+       r->acc = 0;
+       if (r->index == -1)
+               FREE(r);
+}
+
 static void
 free_temp(struct nv50_pc *pc, struct nv50_reg *r)
 {
@@ -250,7 +312,13 @@ alloc_immd(struct nv50_pc *pc, float f)
        struct nv50_reg *r = CALLOC_STRUCT(nv50_reg);
        unsigned hw;
 
-       hw = ctor_immd(pc, f, 0, 0, 0) * 4;
+       for (hw = 0; hw < pc->immd_nr * 4; hw++)
+               if (pc->immd_buf[hw] == f)
+                       break;
+
+       if (hw == pc->immd_nr * 4)
+               hw = ctor_immd(pc, f, -f, 0.5 * f, 0) * 4;
+
        r->type = P_IMMD;
        r->hw = hw;
        r->index = -1;
@@ -341,7 +409,8 @@ set_dst(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_program_exec *e)
 static INLINE void
 set_immd(struct nv50_pc *pc, struct nv50_reg *imm, struct nv50_program_exec *e)
 {
-       unsigned val = fui(pc->immd_buf[imm->hw]); /* XXX */
+       float f = pc->immd_buf[imm->hw];
+       unsigned val = fui(imm->neg ? -f : f);
 
        set_long(pc, e);
        /*XXX: can't be predicated - bits overlap.. catch cases where both
@@ -354,20 +423,35 @@ set_immd(struct nv50_pc *pc, struct nv50_reg *imm, struct nv50_program_exec *e)
        e->inst[1] |= (val >> 6) << 2;
 }
 
+
+#define INTERP_LINEAR          0
+#define INTERP_FLAT                    1
+#define INTERP_PERSPECTIVE     2
+#define INTERP_CENTROID                4
+
+/* interpolant index has been stored in dst->rhw */
 static void
-emit_interp(struct nv50_pc *pc, struct nv50_reg *dst,
-           struct nv50_reg *src, struct nv50_reg *iv)
+emit_interp(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *iv,
+               unsigned mode)
 {
+       assert(dst->rhw != -1);
        struct nv50_program_exec *e = exec(pc);
 
        e->inst[0] |= 0x80000000;
        set_dst(pc, dst, e);
-       alloc_reg(pc, src);
-       e->inst[0] |= (src->hw << 16);
-       if (iv) {
-               e->inst[0] |= (1 << 25);
-               alloc_reg(pc, iv);
-               e->inst[0] |= (iv->hw << 9);
+       e->inst[0] |= (dst->rhw << 16);
+
+       if (mode & INTERP_FLAT) {
+               e->inst[0] |= (1 << 8);
+       } else {
+               if (mode & INTERP_PERSPECTIVE) {
+                       e->inst[0] |= (1 << 25);
+                       alloc_reg(pc, iv);
+                       e->inst[0] |= (iv->hw << 9);
+               }
+
+               if (mode & INTERP_CENTROID)
+                       e->inst[0] |= (1 << 24);
        }
 
        emit(pc, e);
@@ -378,22 +462,12 @@ set_data(struct nv50_pc *pc, struct nv50_reg *src, unsigned m, unsigned s,
         struct nv50_program_exec *e)
 {
        set_long(pc, e);
-#if 1
-       e->inst[1] |= (1 << 22);
-#else
-       if (src->type == P_IMMD) {
-               e->inst[1] |= (NV50_CB_PMISC << 22);
-       } else {
-               if (pc->p->type == PIPE_SHADER_VERTEX)
-                       e->inst[1] |= (NV50_CB_PVP << 22);
-               else
-                       e->inst[1] |= (NV50_CB_PFP << 22);
-       }
-#endif
 
        e->param.index = src->hw;
        e->param.shift = s;
        e->param.mask = m << (s % 32);
+
+       e->inst[1] |= (((src->type == P_IMMD) ? 0 : 1) << 22);
 }
 
 static void
@@ -405,12 +479,11 @@ emit_mov(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
 
        set_dst(pc, dst, e);
 
-       if (0 && dst->type != P_RESULT && src->type == P_IMMD) {
+       if (pc->allow32 && dst->type != P_RESULT && src->type == P_IMMD) {
                set_immd(pc, src, e);
                /*XXX: 32-bit, but steals part of "half" reg space - need to
                 *     catch and handle this case if/when we do half-regs
                 */
-               e->inst[0] |= 0x00008000;
        } else
        if (src->type == P_IMMD || src->type == P_CONST) {
                set_long(pc, e);
@@ -426,18 +499,25 @@ emit_mov(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
                e->inst[0] |= (src->hw << 9);
        }
 
-       /* We really should support "half" instructions here at some point,
-        * but I don't feel confident enough about them yet.
-        */
-       set_long(pc, e);
        if (is_long(e) && !is_immd(e)) {
                e->inst[1] |= 0x04000000; /* 32-bit */
-               e->inst[1] |= 0x0003c000; /* "subsubop" 0xf == mov */
-       }
+               e->inst[1] |= 0x0000c000; /* "subsubop" 0x3 */
+               if (!(e->inst[1] & 0x20000000))
+                       e->inst[1] |= 0x00030000; /* "subsubop" 0xf */
+       } else
+               e->inst[0] |= 0x00008000;
 
        emit(pc, e);
 }
 
+static INLINE void
+emit_mov_immdval(struct nv50_pc *pc, struct nv50_reg *dst, float f)
+{
+       struct nv50_reg *imm = alloc_immd(pc, f);
+       emit_mov(pc, dst, imm);
+       FREE(imm);
+}
+
 static boolean
 check_swap_src_0_1(struct nv50_pc *pc,
                   struct nv50_reg **s0, struct nv50_reg **s1)
@@ -541,12 +621,26 @@ emit_mul(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src0,
        struct nv50_program_exec *e = exec(pc);
 
        e->inst[0] |= 0xc0000000;
-       set_long(pc, e);
+
+       if (!pc->allow32)
+               set_long(pc, e);
 
        check_swap_src_0_1(pc, &src0, &src1);
        set_dst(pc, dst, e);
        set_src_0(pc, src0, e);
-       set_src_1(pc, src1, e);
+       if (src1->type == P_IMMD && !is_long(e)) {
+               if (src0->neg)
+                       e->inst[0] |= 0x00008000;
+               set_immd(pc, src1, e);
+       } else {
+               set_src_1(pc, src1, e);
+               if (src0->neg ^ src1->neg) {
+                       if (is_long(e))
+                               e->inst[1] |= 0x08000000;
+                       else
+                               e->inst[0] |= 0x00008000;
+               }
+       }
 
        emit(pc, e);
 }
@@ -560,10 +654,19 @@ emit_add(struct nv50_pc *pc, struct nv50_reg *dst,
        e->inst[0] |= 0xb0000000;
 
        check_swap_src_0_1(pc, &src0, &src1);
+
+       if (!pc->allow32 || src0->neg || src1->neg) {
+               set_long(pc, e);
+               e->inst[1] |= (src0->neg << 26) | (src1->neg << 27);
+       }
+
        set_dst(pc, dst, e);
        set_src_0(pc, src0, e);
-       if (is_long(e))
+       if (src1->type == P_CONST || src1->type == P_ATTR || is_long(e))
                set_src_2(pc, src1, e);
+       else
+       if (src1->type == P_IMMD)
+               set_immd(pc, src1, e);
        else
                set_src_1(pc, src1, e);
 
@@ -588,25 +691,13 @@ emit_minmax(struct nv50_pc *pc, unsigned sub, struct nv50_reg *dst,
        emit(pc, e);
 }
 
-static void
+static INLINE void
 emit_sub(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src0,
         struct nv50_reg *src1)
 {
-       struct nv50_program_exec *e = exec(pc);
-
-       e->inst[0] |= 0xb0000000;
-
-       set_long(pc, e);
-       if (check_swap_src_0_1(pc, &src0, &src1))
-               e->inst[1] |= 0x04000000;
-       else
-               e->inst[1] |= 0x08000000;
-
-       set_dst(pc, dst, e);
-       set_src_0(pc, src0, e);
-       set_src_2(pc, src1, e);
-
-       emit(pc, e);
+       src1->neg ^= 1;
+       emit_add(pc, dst, src0, src1);
+       src1->neg ^= 1;
 }
 
 static void
@@ -623,26 +714,21 @@ emit_mad(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src0,
        set_src_1(pc, src1, e);
        set_src_2(pc, src2, e);
 
+       if (src0->neg ^ src1->neg)
+               e->inst[1] |= 0x04000000;
+       if (src2->neg)
+               e->inst[1] |= 0x08000000;
+
        emit(pc, e);
 }
 
-static void
+static INLINE void
 emit_msb(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src0,
         struct nv50_reg *src1, struct nv50_reg *src2)
 {
-       struct nv50_program_exec *e = exec(pc);
-
-       e->inst[0] |= 0xe0000000;
-       set_long(pc, e);
-       e->inst[1] |= 0x08000000; /* src0 * src1 - src2 */
-
-       check_swap_src_0_1(pc, &src0, &src1);
-       set_dst(pc, dst, e);
-       set_src_0(pc, src0, e);
-       set_src_1(pc, src1, e);
-       set_src_2(pc, src2, e);
-
-       emit(pc, e);
+       src2->neg ^= 1;
+       emit_mad(pc, dst, src0, src1, src2);
+       src2->neg ^= 1;
 }
 
 static void
@@ -693,6 +779,48 @@ emit_precossin(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
        emit(pc, e);
 }
 
+#define CVTOP_RN       0x01
+#define CVTOP_FLOOR    0x03
+#define CVTOP_CEIL     0x05
+#define CVTOP_TRUNC    0x07
+#define CVTOP_SAT      0x08
+#define CVTOP_ABS      0x10
+
+#define CVT_F32_F32 0xc4
+#define CVT_F32_S32 0x44
+#define CVT_F32_U32 0x64
+#define CVT_S32_F32 0x8c
+#define CVT_S32_S32 0x0c
+#define CVT_F32_F32_ROP 0xcc
+
+static void
+emit_cvt(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src,
+        int wp, unsigned cop, unsigned fmt)
+{
+       struct nv50_program_exec *e;
+
+       e = exec(pc);
+       set_long(pc, e);
+
+       e->inst[0] |= 0xa0000000;
+       e->inst[1] |= 0x00004000;
+       e->inst[1] |= (cop << 16);
+       e->inst[1] |= (fmt << 24);
+       set_src_0(pc, src, e);
+
+       if (wp >= 0)
+               set_pred_wr(pc, 1, wp, e);
+
+       if (dst)
+               set_dst(pc, dst, e);
+       else {
+               e->inst[0] |= 0x000001fc;
+               e->inst[1] |= 0x00000008;
+       }
+
+       emit(pc, e);
+}
+
 static void
 emit_set(struct nv50_pc *pc, unsigned c_op, struct nv50_reg *dst,
         struct nv50_reg *src0, struct nv50_reg *src1)
@@ -736,22 +864,10 @@ emit_set(struct nv50_pc *pc, unsigned c_op, struct nv50_reg *dst,
                free_temp(pc, dst);
 }
 
-static void
+static INLINE void
 emit_flr(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
 {
-       struct nv50_program_exec *e = exec(pc);
-
-       e->inst[0] = 0xa0000000; /* cvt */
-       set_long(pc, e);
-       e->inst[1] |= (6 << 29); /* cvt */
-       e->inst[1] |= 0x08000000; /* integer mode */
-       e->inst[1] |= 0x04000000; /* 32 bit */
-       e->inst[1] |= ((0x1 << 3)) << 14; /* .rn */
-       e->inst[1] |= (1 << 14); /* src .f32 */
-       set_dst(pc, dst, e);
-       set_src_0(pc, src, e);
-
-       emit(pc, e);
+       emit_cvt(pc, dst, src, -1, CVTOP_FLOOR, CVT_F32_F32_ROP);
 }
 
 static void
@@ -768,21 +884,10 @@ emit_pow(struct nv50_pc *pc, struct nv50_reg *dst,
        free_temp(pc, temp);
 }
 
-static void
+static INLINE void
 emit_abs(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
 {
-       struct nv50_program_exec *e = exec(pc);
-
-       e->inst[0] = 0xa0000000; /* cvt */
-       set_long(pc, e);
-       e->inst[1] |= (6 << 29); /* cvt */
-       e->inst[1] |= 0x04000000; /* 32 bit */
-       e->inst[1] |= (1 << 14); /* src .f32 */
-       e->inst[1] |= ((1 << 6) << 14); /* .abs */
-       set_dst(pc, dst, e);
-       set_src_0(pc, src, e);
-
-       emit(pc, e);
+       emit_cvt(pc, dst, src, -1, CVTOP_ABS, CVT_F32_F32);
 }
 
 static void
@@ -794,18 +899,12 @@ emit_lit(struct nv50_pc *pc, struct nv50_reg **dst, unsigned mask,
        struct nv50_reg *neg128 = alloc_immd(pc, -127.999999);
        struct nv50_reg *pos128 = alloc_immd(pc,  127.999999);
        struct nv50_reg *tmp[4];
+       boolean allow32 = pc->allow32;
 
-       if (mask & (1 << 0))
-               emit_mov(pc, dst[0], one);
-
-       if (mask & (1 << 3))
-               emit_mov(pc, dst[3], one);
+       pc->allow32 = FALSE;
 
        if (mask & (3 << 1)) {
-               if (mask & (1 << 1))
-                       tmp[0] = dst[1];
-               else
-                       tmp[0] = temp_temp(pc);
+               tmp[0] = alloc_temp(pc, NULL);
                emit_minmax(pc, 4, tmp[0], src[0], zero);
        }
 
@@ -823,6 +922,26 @@ emit_lit(struct nv50_pc *pc, struct nv50_reg **dst, unsigned mask,
                emit_mov(pc, dst[2], zero);
                set_pred(pc, 3, 0, pc->p->exec_tail);
        }
+
+       if (mask & (1 << 1))
+               assimilate_temp(pc, dst[1], tmp[0]);
+       else
+       if (mask & (1 << 2))
+               free_temp(pc, tmp[0]);
+
+       pc->allow32 = allow32;
+
+       /* do this last, in case src[i,j] == dst[0,3] */
+       if (mask & (1 << 0))
+               emit_mov(pc, dst[0], one);
+
+       if (mask & (1 << 3))
+               emit_mov(pc, dst[3], one);
+
+       FREE(pos128);
+       FREE(neg128);
+       FREE(zero);
+       FREE(one);
 }
 
 static void
@@ -853,6 +972,8 @@ emit_kil(struct nv50_pc *pc, struct nv50_reg *src)
        e->inst[1] = 0xc4014788;
        set_src_0(pc, src, e);
        set_pred_wr(pc, 1, r_pred, e);
+       if (src->neg)
+               e->inst[1] |= 0x20000000;
        emit(pc, e);
 
        /* This is probably KILP */
@@ -863,6 +984,180 @@ emit_kil(struct nv50_pc *pc, struct nv50_reg *src)
        emit(pc, e);
 }
 
+static void
+emit_tex(struct nv50_pc *pc, struct nv50_reg **dst, unsigned mask,
+        struct nv50_reg **src, unsigned unit, unsigned type, boolean proj)
+{
+       struct nv50_reg *temp, *t[4];
+       struct nv50_program_exec *e;
+
+       unsigned c, mode, dim;
+
+       switch (type) {
+       case TGSI_TEXTURE_1D:
+               dim = 1;
+               break;
+       case TGSI_TEXTURE_UNKNOWN:
+       case TGSI_TEXTURE_2D:
+       case TGSI_TEXTURE_SHADOW1D: /* XXX: x, z */
+       case TGSI_TEXTURE_RECT:
+               dim = 2;
+               break;
+       case TGSI_TEXTURE_3D:
+       case TGSI_TEXTURE_CUBE:
+       case TGSI_TEXTURE_SHADOW2D:
+       case TGSI_TEXTURE_SHADOWRECT: /* XXX */
+               dim = 3;
+               break;
+       default:
+               assert(0);
+               break;
+       }
+
+       alloc_temp4(pc, t, 0);
+
+       if (proj) {
+               if (src[0]->type == P_TEMP && src[0]->rhw != -1) {
+                       mode = pc->interp_mode[src[0]->index];
+
+                       t[3]->rhw = src[3]->rhw;
+                       emit_interp(pc, t[3], NULL, (mode & INTERP_CENTROID));
+                       emit_flop(pc, 0, t[3], t[3]);
+
+                       for (c = 0; c < dim; c++) {
+                               t[c]->rhw = src[c]->rhw;
+                               emit_interp(pc, t[c], t[3],
+                                           (mode | INTERP_PERSPECTIVE));
+                       }
+               } else {
+                       emit_flop(pc, 0, t[3], src[3]);
+                       for (c = 0; c < dim; c++)
+                               emit_mul(pc, t[c], src[c], t[3]);
+
+                       /* XXX: for some reason the blob sometimes uses MAD:
+                        * emit_mad(pc, t[c], src[0][c], t[3], t[3])
+                        * pc->p->exec_tail->inst[1] |= 0x080fc000;
+                        */
+               }
+       } else {
+               if (type == TGSI_TEXTURE_CUBE) {
+                       temp = temp_temp(pc);
+                       emit_minmax(pc, 4, temp, src[0], src[1]);
+                       emit_minmax(pc, 4, temp, temp, src[2]);
+                       emit_flop(pc, 0, temp, temp);
+                       for (c = 0; c < 3; c++)
+                               emit_mul(pc, t[c], src[c], temp);
+               } else {
+                       for (c = 0; c < dim; c++)
+                               emit_mov(pc, t[c], src[c]);
+               }
+       }
+
+       e = exec(pc);
+       set_long(pc, e);
+       e->inst[0] |= 0xf0000000;
+       e->inst[1] |= 0x00000004;
+       set_dst(pc, t[0], e);
+       e->inst[0] |= (unit << 9);
+
+       if (dim == 2)
+               e->inst[0] |= 0x00400000;
+       else
+       if (dim == 3)
+               e->inst[0] |= 0x00800000;
+
+       e->inst[0] |= (mask & 0x3) << 25;
+       e->inst[1] |= (mask & 0xc) << 12;
+
+       emit(pc, e);
+
+#if 1
+       if (mask & 1) emit_mov(pc, dst[0], t[0]);
+       if (mask & 2) emit_mov(pc, dst[1], t[1]);
+       if (mask & 4) emit_mov(pc, dst[2], t[2]);
+       if (mask & 8) emit_mov(pc, dst[3], t[3]);
+
+       free_temp4(pc, t);
+#else
+       /* XXX: if p.e. MUL is used directly after TEX, it would still use
+        * the texture coordinates, not the fetched values: latency ? */
+
+       for (c = 0; c < 4; c++) {
+               if (mask & (1 << c))
+                       assimilate_temp(pc, dst[c], t[c]);
+               else
+                       free_temp(pc, t[c]);
+       }
+#endif
+}
+
+static void
+convert_to_long(struct nv50_pc *pc, struct nv50_program_exec *e)
+{
+       unsigned q = 0, m = ~0;
+
+       assert(!is_long(e));
+
+       switch (e->inst[0] >> 28) {
+       case 0x1:
+               /* MOV */
+               q = 0x0403c000;
+               m = 0xffff7fff;
+               break;
+       case 0x8:
+               /* INTERP */
+               m = ~0x02000000;
+               if (e->inst[0] & 0x02000000)
+                       q = 0x00020000;
+               break;
+       case 0x9:
+               /* RCP */
+               break;
+       case 0xB:
+               /* ADD */
+               m = ~(127 << 16);
+               q = ((e->inst[0] & (~m)) >> 2);
+               break;
+       case 0xC:
+               /* MUL */
+               m = ~0x00008000;
+               q = ((e->inst[0] & (~m)) << 12);
+               break;
+       case 0xE:
+               /* MAD (if src2 == dst) */
+               q = ((e->inst[0] & 0x1fc) << 12);
+               break;
+       default:
+               assert(0);
+               break;
+       }
+
+       set_long(pc, e);
+       pc->p->exec_size++;
+
+       e->inst[0] &= m;
+       e->inst[1] |= q;
+}
+
+static boolean
+negate_supported(const struct tgsi_full_instruction *insn, int i)
+{
+       switch (insn->Instruction.Opcode) {
+       case TGSI_OPCODE_DP3:
+       case TGSI_OPCODE_DP4:
+       case TGSI_OPCODE_MUL:
+       case TGSI_OPCODE_KIL:
+       case TGSI_OPCODE_ADD:
+       case TGSI_OPCODE_SUB:
+       case TGSI_OPCODE_MAD:
+               return TRUE;
+       case TGSI_OPCODE_POW:
+               return (i == 1) ? TRUE : FALSE;
+       default:
+               return FALSE;
+       }
+}
+
 static struct nv50_reg *
 tgsi_dst(struct nv50_pc *pc, int c, const struct tgsi_full_dst_register *dst)
 {
@@ -881,11 +1176,14 @@ tgsi_dst(struct nv50_pc *pc, int c, const struct tgsi_full_dst_register *dst)
 }
 
 static struct nv50_reg *
-tgsi_src(struct nv50_pc *pc, int chan, const struct tgsi_full_src_register *src)
+tgsi_src(struct nv50_pc *pc, int chan, const struct tgsi_full_src_register *src,
+        boolean neg)
 {
        struct nv50_reg *r = NULL;
        struct nv50_reg *temp;
-       unsigned c;
+       unsigned sgn, c;
+
+       sgn = tgsi_util_get_full_src_register_sign_mode(src, chan);
 
        c = tgsi_util_get_full_src_register_extswizzle(src, chan);
        switch (c) {
@@ -915,16 +1213,17 @@ tgsi_src(struct nv50_pc *pc, int chan, const struct tgsi_full_src_register *src)
                break;
        case TGSI_EXTSWIZZLE_ZERO:
                r = alloc_immd(pc, 0.0);
-               break;
+               return r;
        case TGSI_EXTSWIZZLE_ONE:
-               r = alloc_immd(pc, 1.0);
-               break;
+               if (sgn == TGSI_UTIL_SIGN_TOGGLE || sgn == TGSI_UTIL_SIGN_SET)
+                       return alloc_immd(pc, -1.0);
+               return alloc_immd(pc, 1.0);
        default:
                assert(0);
                break;
        }
 
-       switch (tgsi_util_get_full_src_register_sign_mode(src, chan)) {
+       switch (sgn) {
        case TGSI_UTIL_SIGN_KEEP:
                break;
        case TGSI_UTIL_SIGN_CLEAR:
@@ -933,14 +1232,21 @@ tgsi_src(struct nv50_pc *pc, int chan, const struct tgsi_full_src_register *src)
                r = temp;
                break;
        case TGSI_UTIL_SIGN_TOGGLE:
-               temp = temp_temp(pc);
-               emit_neg(pc, temp, r);
-               r = temp;
+               if (neg)
+                       r->neg = 1;
+               else {
+                       temp = temp_temp(pc);
+                       emit_neg(pc, temp, r);
+                       r = temp;
+               }
                break;
        case TGSI_UTIL_SIGN_SET:
                temp = temp_temp(pc);
                emit_abs(pc, temp, r);
-               emit_neg(pc, temp, r);
+               if (neg)
+                       temp->neg = 1;
+               else
+                       emit_neg(pc, temp, temp);
                r = temp;
                break;
        default:
@@ -951,12 +1257,40 @@ tgsi_src(struct nv50_pc *pc, int chan, const struct tgsi_full_src_register *src)
        return r;
 }
 
+/* returns TRUE if instruction can overwrite sources before they're read */
+static boolean
+direct2dest_op(const struct tgsi_full_instruction *insn)
+{
+       if (insn->Instruction.Saturate)
+               return FALSE;
+
+       switch (insn->Instruction.Opcode) {
+       case TGSI_OPCODE_COS:
+       case TGSI_OPCODE_DP3:
+       case TGSI_OPCODE_DP4:
+       case TGSI_OPCODE_DPH:
+       case TGSI_OPCODE_KIL:
+       case TGSI_OPCODE_LIT:
+       case TGSI_OPCODE_POW:
+       case TGSI_OPCODE_RCP:
+       case TGSI_OPCODE_RSQ:
+       case TGSI_OPCODE_SCS:
+       case TGSI_OPCODE_SIN:
+       case TGSI_OPCODE_TEX:
+       case TGSI_OPCODE_TXP:
+               return FALSE;
+       default:
+               return TRUE;
+       }
+}
+
 static boolean
 nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
 {
        const struct tgsi_full_instruction *inst = &tok->FullInstruction;
        struct nv50_reg *rdst[4], *dst[4], *src[3][4], *temp;
        unsigned mask, sat, unit;
+       boolean assimilate = FALSE;
        int i, c;
 
        mask = inst->FullDstRegisters[0].DstRegister.WriteMask;
@@ -967,6 +1301,10 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
                        dst[c] = tgsi_dst(pc, c, &inst->FullDstRegisters[0]);
                else
                        dst[c] = NULL;
+               rdst[c] = NULL;
+               src[0][c] = NULL;
+               src[1][c] = NULL;
+               src[2][c] = NULL;
        }
 
        for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
@@ -976,7 +1314,8 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
                        unit = fs->SrcRegister.Index;
 
                for (c = 0; c < 4; c++)
-                       src[i][c] = tgsi_src(pc, c, fs);
+                       src[i][c] = tgsi_src(pc, c, fs,
+                                            negate_supported(inst, i));
        }
 
        if (sat) {
@@ -984,6 +1323,25 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
                        rdst[c] = dst[c];
                        dst[c] = temp_temp(pc);
                }
+       } else
+       if (direct2dest_op(inst)) {
+               for (c = 0; c < 4; c++) {
+                       if (!dst[c] || dst[c]->type != P_TEMP)
+                               continue;
+
+                       for (i = c + 1; i < 4; i++) {
+                               if (dst[c] == src[0][i] ||
+                                   dst[c] == src[1][i] ||
+                                   dst[c] == src[2][i])
+                                       break;
+                       }
+                       if (i == 4)
+                               continue;
+
+                       assimilate = TRUE;
+                       rdst[c] = dst[c];
+                       dst[c] = alloc_temp(pc, NULL);
+               }
        }
 
        switch (inst->Instruction.Opcode) {
@@ -1002,7 +1360,7 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
                }
                break;
        case TGSI_OPCODE_COS:
-               temp = alloc_temp(pc, NULL);
+               temp = temp_temp(pc);
                emit_precossin(pc, temp, src[0][0]);
                emit_flop(pc, 5, temp, temp);
                for (c = 0; c < 4; c++) {
@@ -1012,7 +1370,7 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
                }
                break;
        case TGSI_OPCODE_DP3:
-               temp = alloc_temp(pc, NULL);
+               temp = temp_temp(pc);
                emit_mul(pc, temp, src[0][0], src[1][0]);
                emit_mad(pc, temp, src[0][1], src[1][1], temp);
                emit_mad(pc, temp, src[0][2], src[1][2], temp);
@@ -1021,10 +1379,9 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
                                continue;
                        emit_mov(pc, dst[c], temp);
                }
-               free_temp(pc, temp);
                break;
        case TGSI_OPCODE_DP4:
-               temp = alloc_temp(pc, NULL);
+               temp = temp_temp(pc);
                emit_mul(pc, temp, src[0][0], src[1][0]);
                emit_mad(pc, temp, src[0][1], src[1][1], temp);
                emit_mad(pc, temp, src[0][2], src[1][2], temp);
@@ -1034,10 +1391,9 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
                                continue;
                        emit_mov(pc, dst[c], temp);
                }
-               free_temp(pc, temp);
                break;
        case TGSI_OPCODE_DPH:
-               temp = alloc_temp(pc, NULL);
+               temp = temp_temp(pc);
                emit_mul(pc, temp, src[0][0], src[1][0]);
                emit_mad(pc, temp, src[0][1], src[1][1], temp);
                emit_mad(pc, temp, src[0][2], src[1][2], temp);
@@ -1047,7 +1403,6 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
                                continue;
                        emit_mov(pc, dst[c], temp);
                }
-               free_temp(pc, temp);
                break;
        case TGSI_OPCODE_DST:
        {
@@ -1064,7 +1419,7 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
        }
                break;
        case TGSI_OPCODE_EX2:
-               temp = alloc_temp(pc, NULL);
+               temp = temp_temp(pc);
                emit_preex2(pc, temp, src[0][0]);
                emit_flop(pc, 6, temp, temp);
                for (c = 0; c < 4; c++) {
@@ -1072,7 +1427,6 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
                                continue;
                        emit_mov(pc, dst[c], temp);
                }
-               free_temp(pc, temp);
                break;
        case TGSI_OPCODE_FLR:
                for (c = 0; c < 4; c++) {
@@ -1082,26 +1436,26 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
                }
                break;
        case TGSI_OPCODE_FRC:
-               temp = alloc_temp(pc, NULL);
+               temp = temp_temp(pc);
                for (c = 0; c < 4; c++) {
                        if (!(mask & (1 << c)))
                                continue;
                        emit_flr(pc, temp, src[0][c]);
                        emit_sub(pc, dst[c], src[0][c], temp);
                }
-               free_temp(pc, temp);
                break;
        case TGSI_OPCODE_KIL:
                emit_kil(pc, src[0][0]);
                emit_kil(pc, src[0][1]);
                emit_kil(pc, src[0][2]);
                emit_kil(pc, src[0][3]);
+               pc->p->cfg.fp.regs[2] |= 0x00100000;
                break;
        case TGSI_OPCODE_LIT:
                emit_lit(pc, &dst[0], mask, &src[0][0]);
                break;
        case TGSI_OPCODE_LG2:
-               temp = alloc_temp(pc, NULL);
+               temp = temp_temp(pc);
                emit_flop(pc, 3, temp, src[0][0]);
                for (c = 0; c < 4; c++) {
                        if (!(mask & (1 << c)))
@@ -1110,15 +1464,12 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
                }
                break;
        case TGSI_OPCODE_LRP:
+               temp = temp_temp(pc);
                for (c = 0; c < 4; c++) {
                        if (!(mask & (1 << c)))
                                continue;
-                       /*XXX: we can do better than this */
-                       temp = alloc_temp(pc, NULL);
-                       emit_neg(pc, temp, src[0][c]);
-                       emit_mad(pc, temp, temp, src[2][c], src[2][c]);
-                       emit_mad(pc, dst[c], src[0][c], src[1][c], temp);
-                       free_temp(pc, temp);
+                       emit_sub(pc, temp, src[1][c], src[2][c]);
+                       emit_mad(pc, dst[c], temp, src[0][c], src[2][c]);
                }
                break;
        case TGSI_OPCODE_MAD:
@@ -1157,36 +1508,39 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
                }
                break;
        case TGSI_OPCODE_POW:
-               temp = alloc_temp(pc, NULL);
+               temp = temp_temp(pc);
                emit_pow(pc, temp, src[0][0], src[1][0]);
                for (c = 0; c < 4; c++) {
                        if (!(mask & (1 << c)))
                                continue;
                        emit_mov(pc, dst[c], temp);
                }
-               free_temp(pc, temp);
                break;
        case TGSI_OPCODE_RCP:
-               for (c = 0; c < 4; c++) {
+               for (c = 3; c >= 0; c--) {
                        if (!(mask & (1 << c)))
                                continue;
                        emit_flop(pc, 0, dst[c], src[0][0]);
                }
                break;
        case TGSI_OPCODE_RSQ:
-               for (c = 0; c < 4; c++) {
+               for (c = 3; c >= 0; c--) {
                        if (!(mask & (1 << c)))
                                continue;
                        emit_flop(pc, 2, dst[c], src[0][0]);
                }
                break;
        case TGSI_OPCODE_SCS:
-               temp = alloc_temp(pc, NULL);
+               temp = temp_temp(pc);
                emit_precossin(pc, temp, src[0][0]);
                if (mask & (1 << 0))
                        emit_flop(pc, 5, dst[0], temp);
                if (mask & (1 << 1))
                        emit_flop(pc, 4, dst[1], temp);
+               if (mask & (1 << 2))
+                       emit_mov_immdval(pc, dst[2], 0.0);
+               if (mask & (1 << 3))
+                       emit_mov_immdval(pc, dst[3], 1.0);
                break;
        case TGSI_OPCODE_SGE:
                for (c = 0; c < 4; c++) {
@@ -1196,7 +1550,7 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
                }
                break;
        case TGSI_OPCODE_SIN:
-               temp = alloc_temp(pc, NULL);
+               temp = temp_temp(pc);
                emit_precossin(pc, temp, src[0][0]);
                emit_flop(pc, 4, temp, temp);
                for (c = 0; c < 4; c++) {
@@ -1220,33 +1574,15 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
                }
                break;
        case TGSI_OPCODE_TEX:
+               emit_tex(pc, dst, mask, src[0], unit,
+                        inst->InstructionExtTexture.Texture, FALSE);
+               break;
        case TGSI_OPCODE_TXP:
-       {
-               struct nv50_reg *t[4];
-               struct nv50_program_exec *e;
-
-               alloc_temp4(pc, t, 0);
-               emit_mov(pc, t[0], src[0][0]);
-               emit_mov(pc, t[1], src[0][1]);
-
-               e = exec(pc);
-               e->inst[0] = 0xf6400000;
-               e->inst[0] |= (unit << 9);
-               set_long(pc, e);
-               e->inst[1] |= 0x0000c004;
-               set_dst(pc, t[0], e);
-               emit(pc, e);
-
-               if (mask & (1 << 0)) emit_mov(pc, dst[0], t[0]);
-               if (mask & (1 << 1)) emit_mov(pc, dst[1], t[1]);
-               if (mask & (1 << 2)) emit_mov(pc, dst[2], t[2]);
-               if (mask & (1 << 3)) emit_mov(pc, dst[3], t[3]);
-
-               free_temp4(pc, t);
-       }
+               emit_tex(pc, dst, mask, src[0], unit,
+                        inst->InstructionExtTexture.Texture, TRUE);
                break;
        case TGSI_OPCODE_XPD:
-               temp = alloc_temp(pc, NULL);
+               temp = temp_temp(pc);
                if (mask & (1 << 0)) {
                        emit_mul(pc, temp, src[0][2], src[1][1]);
                        emit_msb(pc, dst[0], src[0][1], src[1][2], temp);
@@ -1259,7 +1595,8 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
                        emit_mul(pc, temp, src[0][1], src[1][0]);
                        emit_msb(pc, dst[2], src[0][0], src[1][1], temp);
                }
-               free_temp(pc, temp);
+               if (mask & (1 << 3))
+                       emit_mov_immdval(pc, dst[3], 1.0);
                break;
        case TGSI_OPCODE_END:
                break;
@@ -1270,21 +1607,26 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
 
        if (sat) {
                for (c = 0; c < 4; c++) {
-                       struct nv50_program_exec *e;
-
                        if (!(mask & (1 << c)))
                                continue;
-                       e = exec(pc);
+                       emit_cvt(pc, rdst[c], dst[c], -1, CVTOP_SAT,
+                                CVT_F32_F32);
+               }
+       } else if (assimilate) {
+               for (c = 0; c < 4; c++)
+                       if (rdst[c])
+                               assimilate_temp(pc, rdst[c], dst[c]);
+       }
 
-                       e->inst[0] = 0xa0000000; /* cvt */
-                       set_long(pc, e);
-                       e->inst[1] |= (6 << 29); /* cvt */
-                       e->inst[1] |= 0x04000000; /* 32 bit */
-                       e->inst[1] |= (1 << 14); /* src .f32 */
-                       e->inst[1] |= ((1 << 5) << 14); /* .sat */
-                       set_dst(pc, rdst[c], e);
-                       set_src_0(pc, dst[c], e);
-                       emit(pc, e);
+       for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
+               for (c = 0; c < 4; c++) {
+                       if (!src[i][c])
+                               continue;
+                       if (src[i][c]->index == -1 && src[i][c]->type == P_IMMD)
+                               FREE(src[i][c]);
+                       else
+                       if (src[i][c]->acc == pc->insn_cur)
+                               release_hw(pc, src[i][c]);
                }
        }
 
@@ -1292,12 +1634,169 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
        return TRUE;
 }
 
+/* Adjust a bitmask that indicates what components of a source are used,
+ * we use this in tx_prep so we only load interpolants that are needed.
+ */
+static void
+insn_adjust_mask(const struct tgsi_full_instruction *insn, unsigned *mask)
+{
+       const struct tgsi_instruction_ext_texture *tex;
+
+       switch (insn->Instruction.Opcode) {
+       case TGSI_OPCODE_DP3:
+               *mask = 0x7;
+               break;
+       case TGSI_OPCODE_DP4:
+       case TGSI_OPCODE_DPH:
+               *mask = 0xF;
+               break;
+       case TGSI_OPCODE_LIT:
+               *mask = 0xB;
+               break;
+       case TGSI_OPCODE_RCP:
+       case TGSI_OPCODE_RSQ:
+               *mask = 0x1;
+               break;
+       case TGSI_OPCODE_TEX:
+       case TGSI_OPCODE_TXP:
+               assert(insn->Instruction.Extended);
+               tex = &insn->InstructionExtTexture;
+
+               *mask = 0x7;
+               if (tex->Texture == TGSI_TEXTURE_1D)
+                       *mask = 0x1;
+               else
+               if (tex->Texture == TGSI_TEXTURE_2D)
+                       *mask = 0x3;
+
+               if (insn->Instruction.Opcode == TGSI_OPCODE_TXP)
+                       *mask |= 0x8;
+               break;
+       default:
+               break;
+       }
+}
+
+static void
+prep_inspect_insn(struct nv50_pc *pc, const union tgsi_full_token *tok,
+                 unsigned *r_usage[2])
+{
+       const struct tgsi_full_instruction *insn;
+       const struct tgsi_full_src_register *src;
+       const struct tgsi_dst_register *dst;
+
+       unsigned i, c, k, n, mask, *acc_p;
+
+       insn = &tok->FullInstruction;
+       dst = &insn->FullDstRegisters[0].DstRegister;
+       mask = dst->WriteMask;
+
+       if (!r_usage[0])
+               r_usage[0] = CALLOC(pc->temp_nr * 4, sizeof(unsigned));
+       if (!r_usage[1])
+               r_usage[1] = CALLOC(pc->attr_nr * 4, sizeof(unsigned));
+
+       if (dst->File == TGSI_FILE_TEMPORARY) {
+               for (c = 0; c < 4; c++) {
+                       if (!(mask & (1 << c)))
+                               continue;
+                       r_usage[0][dst->Index * 4 + c] = pc->insn_nr;
+               }
+       }
+
+       for (i = 0; i < insn->Instruction.NumSrcRegs; i++) {
+               src = &insn->FullSrcRegisters[i];
+
+               switch (src->SrcRegister.File) {
+               case TGSI_FILE_TEMPORARY:
+                       acc_p = r_usage[0];
+                       break;
+               case TGSI_FILE_INPUT:
+                       acc_p = r_usage[1];
+                       break;
+               default:
+                       continue;
+               }
+
+               insn_adjust_mask(insn, &mask);
+
+               for (c = 0; c < 4; c++) {
+                       if (!(mask & (1 << c)))
+                               continue;
+
+                       k = tgsi_util_get_full_src_register_extswizzle(src, c);
+                       switch (k) {
+                       case TGSI_EXTSWIZZLE_X:
+                       case TGSI_EXTSWIZZLE_Y:
+                       case TGSI_EXTSWIZZLE_Z:
+                       case TGSI_EXTSWIZZLE_W:
+                               n = src->SrcRegister.Index * 4 + k;
+                               acc_p[n] = pc->insn_nr;
+                               break;
+                       default:
+                               break;
+                       }
+               }
+       }
+}
+
+static unsigned
+load_fp_attrib(struct nv50_pc *pc, int i, unsigned *acc, int *mid,
+              int *aid, int *p_oid)
+{
+       struct nv50_reg *iv;
+       int oid, c, n;
+       unsigned mask = 0;
+
+       iv = (pc->interp_mode[i] & INTERP_CENTROID) ? pc->iv_c : pc->iv_p;
+
+       for (c = 0, n = i * 4; c < 4; c++, n++) {
+               oid = (*p_oid)++;
+               pc->attr[n].type = P_TEMP;
+               pc->attr[n].index = i;
+
+               if (pc->attr[n].acc == acc[n])
+                       continue;
+               mask |= (1 << c);
+
+               pc->attr[n].acc = acc[n];
+               pc->attr[n].rhw = pc->attr[n].hw = -1;
+               alloc_reg(pc, &pc->attr[n]);
+
+               pc->attr[n].rhw = (*aid)++;
+               emit_interp(pc, &pc->attr[n], iv, pc->interp_mode[i]);
+
+               pc->p->cfg.fp.map[(*mid) / 4] |= oid << (8 * ((*mid) % 4));
+               (*mid)++;
+               pc->p->cfg.fp.regs[1] += 0x00010001;
+       }
+
+       return mask;
+}
+
 static boolean
 nv50_program_tx_prep(struct nv50_pc *pc)
 {
        struct tgsi_parse_context p;
        boolean ret = FALSE;
        unsigned i, c;
+       unsigned fcol, bcol, fcrd, depr;
+
+       /* count (centroid) perspective interpolations */
+       unsigned centroid_loads = 0;
+       unsigned perspect_loads = 0;
+
+       /* track register access for temps and attrs */
+       unsigned *r_usage[2];
+       r_usage[0] = NULL;
+       r_usage[1] = NULL;
+
+       depr = fcol = bcol = fcrd = 0xffff;
+
+       if (pc->p->type == PIPE_SHADER_FRAGMENT) {
+               pc->p->cfg.fp.regs[0] = 0x01000404;
+               pc->p->cfg.fp.regs[1] = 0x00000400;
+       }
 
        tgsi_parse_init(&p, pc->p->pipe.tokens);
        while (!tgsi_parse_end_of_tokens(&p)) {
@@ -1319,9 +1818,10 @@ nv50_program_tx_prep(struct nv50_pc *pc)
                case TGSI_TOKEN_TYPE_DECLARATION:
                {
                        const struct tgsi_full_declaration *d;
-                       unsigned last;
+                       unsigned last, first, mode;
 
                        d = &p.FullToken.FullDeclaration;
+                       first = d->DeclarationRange.First;
                        last = d->DeclarationRange.Last;
 
                        switch (d->Declaration.File) {
@@ -1332,10 +1832,69 @@ nv50_program_tx_prep(struct nv50_pc *pc)
                        case TGSI_FILE_OUTPUT:
                                if (pc->result_nr < (last + 1))
                                        pc->result_nr = last + 1;
+
+                               if (!d->Declaration.Semantic)
+                                       break;
+
+                               switch (d->Semantic.SemanticName) {
+                               case TGSI_SEMANTIC_POSITION:
+                                       depr = first;
+                                       pc->p->cfg.fp.regs[2] |= 0x00000100;
+                                       pc->p->cfg.fp.regs[3] |= 0x00000011;
+                                       break;
+                               default:
+                                       break;
+                               }
+
                                break;
                        case TGSI_FILE_INPUT:
+                       {
                                if (pc->attr_nr < (last + 1))
                                        pc->attr_nr = last + 1;
+
+                               if (pc->p->type != PIPE_SHADER_FRAGMENT)
+                                       break;
+
+                               switch (d->Declaration.Interpolate) {
+                               case TGSI_INTERPOLATE_CONSTANT:
+                                       mode = INTERP_FLAT;
+                                       break;
+                               case TGSI_INTERPOLATE_PERSPECTIVE:
+                                       mode = INTERP_PERSPECTIVE;
+                                       break;
+                               default:
+                                       mode = INTERP_LINEAR;
+                                       break;
+                               }
+
+                               if (d->Declaration.Semantic) {
+                                       switch (d->Semantic.SemanticName) {
+                                       case TGSI_SEMANTIC_POSITION:
+                                               fcrd = first;
+                                               break;
+                                       case TGSI_SEMANTIC_COLOR:
+                                               fcol = first;
+                                               mode = INTERP_PERSPECTIVE;
+                                               break;
+                                       case TGSI_SEMANTIC_BCOLOR:
+                                               bcol = first;
+                                               mode = INTERP_PERSPECTIVE;
+                                               break;
+                                       }
+                               }
+
+                               if (d->Declaration.Centroid) {
+                                       mode |= INTERP_CENTROID;
+                                       if (mode & INTERP_PERSPECTIVE)
+                                               centroid_loads++;
+                               } else
+                               if (mode & INTERP_PERSPECTIVE)
+                                       perspect_loads++;
+
+                               assert(last < 32);
+                               for (i = first; i <= last; i++)
+                                       pc->interp_mode[i] = mode;
+                       }
                                break;
                        case TGSI_FILE_CONSTANT:
                                if (pc->param_nr < (last + 1))
@@ -1351,6 +1910,8 @@ nv50_program_tx_prep(struct nv50_pc *pc)
                }
                        break;
                case TGSI_TOKEN_TYPE_INSTRUCTION:
+                       pc->insn_nr++;
+                       prep_inspect_insn(pc, tok, r_usage);
                        break;
                default:
                        break;
@@ -1366,56 +1927,95 @@ nv50_program_tx_prep(struct nv50_pc *pc)
                        for (c = 0; c < 4; c++) {
                                pc->temp[i*4+c].type = P_TEMP;
                                pc->temp[i*4+c].hw = -1;
+                               pc->temp[i*4+c].rhw = -1;
                                pc->temp[i*4+c].index = i;
+                               pc->temp[i*4+c].acc = r_usage[0][i*4+c];
                        }
                }
        }
 
        if (pc->attr_nr) {
-               struct nv50_reg *iv = NULL;
-               int aid = 0;
+               int oid = 4, mid = 4, aid = 0;
+               /* oid = VP output id
+                * aid = FP attribute/interpolant id
+                * mid = VP output mapping field ID
+                */
 
                pc->attr = CALLOC(pc->attr_nr * 4, sizeof(struct nv50_reg));
                if (!pc->attr)
                        goto out_err;
 
                if (pc->p->type == PIPE_SHADER_FRAGMENT) {
-                       iv = alloc_temp(pc, NULL);
-                       emit_interp(pc, iv, iv, NULL);
-                       emit_flop(pc, 0, iv, iv);
-                       aid++;
-               }
+                       /* position should be loaded first */
+                       if (fcrd != 0xffff) {
+                               unsigned mask;
+                               mid = 0;
+                               mask = load_fp_attrib(pc, fcrd, r_usage[1],
+                                                     &mid, &aid, &oid);
+                               oid = 0;
+                               pc->p->cfg.fp.regs[1] |= (mask << 24);
+                               pc->p->cfg.fp.map[0] = 0x04040404 * fcrd;
+                       }
+                       pc->p->cfg.fp.map[0] += 0x03020100;
 
-               for (i = 0; i < pc->attr_nr; i++) {
-                       struct nv50_reg *a = &pc->attr[i*4];
+                       /* should do MAD fcrd.xy, fcrd, SOME_CONST, fcrd */
 
-                       for (c = 0; c < 4; c++) {
-                               if (pc->p->type == PIPE_SHADER_FRAGMENT) {
-                                       struct nv50_reg *at =
-                                               alloc_temp(pc, NULL);
-                                       pc->attr[i*4+c].type = at->type;
-                                       pc->attr[i*4+c].hw = at->hw;
-                                       pc->attr[i*4+c].index = at->index;
+                       if (perspect_loads) {
+                               pc->iv_p = alloc_temp(pc, NULL);
+
+                               if (!(pc->p->cfg.fp.regs[1] & 0x08000000)) {
+                                       pc->p->cfg.fp.regs[1] |= 0x08000000;
+                                       pc->iv_p->rhw = aid++;
+                                       emit_interp(pc, pc->iv_p, NULL,
+                                                   INTERP_LINEAR);
+                                       emit_flop(pc, 0, pc->iv_p, pc->iv_p);
                                } else {
-                                       pc->p->cfg.vp.attr[aid/32] |=
-                                               (1 << (aid % 32));
-                                       pc->attr[i*4+c].type = P_ATTR;
-                                       pc->attr[i*4+c].hw = aid++;
-                                       pc->attr[i*4+c].index = i;
+                                       pc->iv_p->rhw = aid - 1;
+                                       emit_flop(pc, 0, pc->iv_p,
+                                                 &pc->attr[fcrd * 4 + 3]);
                                }
                        }
 
-                       if (pc->p->type != PIPE_SHADER_FRAGMENT)
-                               continue;
+                       if (centroid_loads) {
+                               pc->iv_c = alloc_temp(pc, NULL);
+                               pc->iv_c->rhw = pc->iv_p ? aid - 1 : aid++;
+                               emit_interp(pc, pc->iv_c, NULL,
+                                           INTERP_CENTROID);
+                               emit_flop(pc, 0, pc->iv_c, pc->iv_c);
+                               pc->p->cfg.fp.regs[1] |= 0x08000000;
+                       }
 
-                       emit_interp(pc, &a[0], &a[0], iv);
-                       emit_interp(pc, &a[1], &a[1], iv);
-                       emit_interp(pc, &a[2], &a[2], iv);
-                       emit_interp(pc, &a[3], &a[3], iv);
-               }
+                       for (c = 0; c < 4; c++) {
+                               /* I don't know what these values do, but
+                                * let's set them like the blob does:
+                                */
+                               if (fcol != 0xffff && r_usage[1][fcol * 4 + c])
+                                       pc->p->cfg.fp.regs[0] += 0x00010000;
+                               if (bcol != 0xffff && r_usage[1][bcol * 4 + c])
+                                       pc->p->cfg.fp.regs[0] += 0x00010000;
+                       }
 
-               if (iv)
-                       free_temp(pc, iv);
+                       for (i = 0; i < pc->attr_nr; i++)
+                               load_fp_attrib(pc, i, r_usage[1],
+                                              &mid, &aid, &oid);
+
+                       if (pc->iv_p)
+                               free_temp(pc, pc->iv_p);
+                       if (pc->iv_c)
+                               free_temp(pc, pc->iv_c);
+
+                       pc->p->cfg.fp.high_map = (mid / 4);
+                       pc->p->cfg.fp.high_map += ((mid % 4) ? 1 : 0);
+               } else {
+                       /* vertex program */
+                       for (i = 0; i < pc->attr_nr * 4; i++) {
+                               pc->p->cfg.vp.attr[aid / 32] |=
+                                       (1 << (aid % 32));
+                               pc->attr[i].type = P_ATTR;
+                               pc->attr[i].hw = aid++;
+                               pc->attr[i].index = i / 4;
+                       }
+               }
        }
 
        if (pc->result_nr) {
@@ -1430,12 +2030,20 @@ nv50_program_tx_prep(struct nv50_pc *pc)
                                if (pc->p->type == PIPE_SHADER_FRAGMENT) {
                                        pc->result[i*4+c].type = P_TEMP;
                                        pc->result[i*4+c].hw = -1;
+                                       pc->result[i*4+c].rhw = (i == depr) ?
+                                               -1 : rid++;
                                } else {
                                        pc->result[i*4+c].type = P_RESULT;
                                        pc->result[i*4+c].hw = rid++;
                                }
                                pc->result[i*4+c].index = i;
                        }
+
+                       if (pc->p->type == PIPE_SHADER_FRAGMENT &&
+                           depr != 0xffff) {
+                               pc->result[depr * 4 + 2].rhw =
+                                       (pc->result_nr - 1) * 4;
+                       }
                }
        }
 
@@ -1456,7 +2064,7 @@ nv50_program_tx_prep(struct nv50_pc *pc)
        }
 
        if (pc->immd_nr) {
-               int rid = pc->param_nr * 4;
+               int rid = 0;
 
                pc->immd = CALLOC(pc->immd_nr * 4, sizeof(struct nv50_reg));
                if (!pc->immd)
@@ -1473,15 +2081,38 @@ nv50_program_tx_prep(struct nv50_pc *pc)
 
        ret = TRUE;
 out_err:
+       if (r_usage[0])
+               FREE(r_usage[0]);
+       if (r_usage[1])
+               FREE(r_usage[1]);
+
        tgsi_parse_free(&p);
        return ret;
 }
 
+static void
+free_nv50_pc(struct nv50_pc *pc)
+{
+       if (pc->immd)
+               FREE(pc->immd);
+       if (pc->param)
+               FREE(pc->param);
+       if (pc->result)
+               FREE(pc->result);
+       if (pc->attr)
+               FREE(pc->attr);
+       if (pc->temp)
+               FREE(pc->temp);
+
+       FREE(pc);
+}
+
 static boolean
 nv50_program_tx(struct nv50_program *p)
 {
        struct tgsi_parse_context parse;
        struct nv50_pc *pc;
+       unsigned k;
        boolean ret;
 
        pc = CALLOC_STRUCT(nv50_pc);
@@ -1498,10 +2129,16 @@ nv50_program_tx(struct nv50_program *p)
        while (!tgsi_parse_end_of_tokens(&parse)) {
                const union tgsi_full_token *tok = &parse.FullToken;
 
+               /* don't allow half insn/immd on first and last instruction */
+               pc->allow32 = TRUE;
+               if (pc->insn_cur == 0 || pc->insn_cur + 2 == pc->insn_nr)
+                       pc->allow32 = FALSE;
+
                tgsi_parse_token(&parse);
 
                switch (tok->Token.Type) {
                case TGSI_TOKEN_TYPE_INSTRUCTION:
+                       ++pc->insn_cur;
                        ret = nv50_program_tx_insn(pc, tok);
                        if (ret == FALSE)
                                goto out_err;
@@ -1515,8 +2152,40 @@ nv50_program_tx(struct nv50_program *p)
                struct nv50_reg out;
 
                out.type = P_TEMP;
-               for (out.hw = 0; out.hw < pc->result_nr * 4; out.hw++)
-                       emit_mov(pc, &out, &pc->result[out.hw]);
+               for (k = 0; k < pc->result_nr * 4; k++) {
+                       if (pc->result[k].rhw == -1)
+                               continue;
+                       if (pc->result[k].hw != pc->result[k].rhw) {
+                               out.hw = pc->result[k].rhw;
+                               emit_mov(pc, &out, &pc->result[k]);
+                       }
+                       if (pc->p->cfg.high_result < (pc->result[k].rhw + 1))
+                               pc->p->cfg.high_result = pc->result[k].rhw + 1;
+               }
+       }
+
+       /* look for single half instructions and make them long */
+       struct nv50_program_exec *e, *e_prev;
+
+       for (k = 0, e = pc->p->exec_head, e_prev = NULL; e; e = e->next) {
+               if (!is_long(e))
+                       k++;
+
+               if (!e->next || is_long(e->next)) {
+                       if (k & 1)
+                               convert_to_long(pc, e);
+                       k = 0;
+               }
+
+               if (e->next)
+                       e_prev = e;
+       }
+
+       if (!is_long(pc->p->exec_tail)) {
+               /* this may occur if moving FP results */
+               assert(e_prev && !is_long(e_prev));
+               convert_to_long(pc, e_prev);
+               convert_to_long(pc, pc->p->exec_tail);
        }
 
        assert(is_long(pc->p->exec_tail) && !is_immd(pc->p->exec_head));
@@ -1530,6 +2199,7 @@ out_err:
        tgsi_parse_free(&parse);
 
 out_cleanup:
+       free_nv50_pc(pc);
        return ret;
 }
 
@@ -1543,16 +2213,16 @@ nv50_program_validate(struct nv50_context *nv50, struct nv50_program *p)
 
 static void
 nv50_program_upload_data(struct nv50_context *nv50, float *map,
-                        unsigned start, unsigned count)
+                       unsigned start, unsigned count, unsigned cbuf)
 {
-       struct nouveau_channel *chan = nv50->screen->nvws->channel;
+       struct nouveau_channel *chan = nv50->screen->base.channel;
        struct nouveau_grobj *tesla = nv50->screen->tesla;
 
        while (count) {
                unsigned nr = count > 2047 ? 2047 : count;
 
                BEGIN_RING(chan, tesla, 0x00000f00, 1);
-               OUT_RING  (chan, (NV50_CB_PMISC << 0) | (start << 8));
+               OUT_RING  (chan, (cbuf << 0) | (start << 8));
                BEGIN_RING(chan, tesla, 0x40000f04, nr);
                OUT_RINGp (chan, map, nr);
 
@@ -1565,70 +2235,93 @@ nv50_program_upload_data(struct nv50_context *nv50, float *map,
 static void
 nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p)
 {
-       struct nouveau_winsys *nvws = nv50->screen->nvws;
-       struct pipe_winsys *ws = nv50->pipe.winsys;
-       unsigned nr = p->param_nr + p->immd_nr;
+       struct pipe_screen *pscreen = nv50->pipe.screen;
 
-       if (!p->data && nr) {
-               struct nouveau_resource *heap = nv50->screen->vp_data_heap;
+       if (!p->data[0] && p->immd_nr) {
+               struct nouveau_resource *heap = nv50->screen->immd_heap[0];
 
-               if (nvws->res_alloc(heap, nr, p, &p->data)) {
-                       while (heap->next && heap->size < nr) {
+               if (nouveau_resource_alloc(heap, p->immd_nr, p, &p->data[0])) {
+                       while (heap->next && heap->size < p->immd_nr) {
                                struct nv50_program *evict = heap->next->priv;
-                               nvws->res_free(&evict->data);
+                               nouveau_resource_free(&evict->data[0]);
                        }
 
-                       if (nvws->res_alloc(heap, nr, p, &p->data))
+                       if (nouveau_resource_alloc(heap, p->immd_nr, p,
+                                                  &p->data[0]))
                                assert(0);
                }
+
+               /* immediates only need to be uploaded again when freed */
+               nv50_program_upload_data(nv50, p->immd, p->data[0]->start,
+                                        p->immd_nr, NV50_CB_PMISC);
        }
 
-       if (p->param_nr) {
-               float *map = ws->buffer_map(ws, nv50->constbuf[p->type],
-                                           PIPE_BUFFER_USAGE_CPU_READ);
-               nv50_program_upload_data(nv50, map, p->data->start,
-                                        p->param_nr);
-               ws->buffer_unmap(ws, nv50->constbuf[p->type]);
+       if (!p->data[1] && p->param_nr) {
+               struct nouveau_resource *heap =
+                       nv50->screen->parm_heap[p->type];
+
+               if (nouveau_resource_alloc(heap, p->param_nr, p, &p->data[1])) {
+                       while (heap->next && heap->size < p->param_nr) {
+                               struct nv50_program *evict = heap->next->priv;
+                               nouveau_resource_free(&evict->data[1]);
+                       }
+
+                       if (nouveau_resource_alloc(heap, p->param_nr, p,
+                                                  &p->data[1]))
+                               assert(0);
+               }
        }
 
-       if (p->immd_nr) {
-               nv50_program_upload_data(nv50, p->immd,
-                                        p->data->start + p->param_nr,
-                                        p->immd_nr);
+       if (p->param_nr) {
+               unsigned cbuf = NV50_CB_PVP;
+               float *map = pipe_buffer_map(pscreen, nv50->constbuf[p->type],
+                                            PIPE_BUFFER_USAGE_CPU_READ);
+               if (p->type == PIPE_SHADER_FRAGMENT)
+                       cbuf = NV50_CB_PFP;
+               nv50_program_upload_data(nv50, map, p->data[1]->start,
+                                        p->param_nr, cbuf);
+               pipe_buffer_unmap(pscreen, nv50->constbuf[p->type]);
        }
 }
 
 static void
 nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p)
 {
-       struct nouveau_channel *chan = nv50->screen->nvws->channel;
+       struct nouveau_channel *chan = nv50->screen->base.channel;
        struct nouveau_grobj *tesla = nv50->screen->tesla;
-       struct pipe_screen *screen = nv50->pipe.screen;
        struct nv50_program_exec *e;
        struct nouveau_stateobj *so;
        const unsigned flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_WR;
        unsigned start, count, *up, *ptr;
        boolean upload = FALSE;
 
-       if (!p->buffer) {
-               p->buffer = screen->buffer_create(screen, 0x100, 0, p->exec_size * 4);
+       if (!p->bo) {
+               nouveau_bo_new(chan->device, NOUVEAU_BO_VRAM, 0x100,
+                              p->exec_size * 4, &p->bo);
                upload = TRUE;
        }
 
-       if (p->data && p->data->start != p->data_start) {
+       if ((p->data[0] && p->data[0]->start != p->data_start[0]) ||
+               (p->data[1] && p->data[1]->start != p->data_start[1])) {
                for (e = p->exec_head; e; e = e->next) {
-                       unsigned ei, ci;
+                       unsigned ei, ci, bs;
 
                        if (e->param.index < 0)
                                continue;
+                       bs = (e->inst[1] >> 22) & 0x07;
+                       assert(bs < 2);
                        ei = e->param.shift >> 5;
-                       ci = e->param.index + p->data->start;
+                       ci = e->param.index + p->data[bs]->start;
 
                        e->inst[ei] &= ~e->param.mask;
                        e->inst[ei] |= (ci << e->param.shift);
                }
 
-               p->data_start = p->data->start;
+               if (p->data[0])
+                       p->data_start[0] = p->data[0]->start;
+               if (p->data[1])
+                       p->data_start[1] = p->data[1]->start;
+
                upload = TRUE;
        }
 
@@ -1637,13 +2330,11 @@ nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p)
 
 #ifdef NV50_PROGRAM_DUMP
        NOUVEAU_ERR("-------\n");
-       up = ptr = MALLOC(p->exec_size * 4);
        for (e = p->exec_head; e; e = e->next) {
                NOUVEAU_ERR("0x%08x\n", e->inst[0]);
                if (is_long(e))
                        NOUVEAU_ERR("0x%08x\n", e->inst[1]);
        }
-
 #endif
 
        up = ptr = MALLOC(p->exec_size * 4);
@@ -1655,20 +2346,20 @@ nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p)
 
        so = so_new(4,2);
        so_method(so, nv50->screen->tesla, 0x1280, 3);
-       so_reloc (so, p->buffer, 0, flags | NOUVEAU_BO_HIGH, 0, 0);
-       so_reloc (so, p->buffer, 0, flags | NOUVEAU_BO_LOW, 0, 0);
+       so_reloc (so, p->bo, 0, flags | NOUVEAU_BO_HIGH, 0, 0);
+       so_reloc (so, p->bo, 0, flags | NOUVEAU_BO_LOW, 0, 0);
        so_data  (so, (NV50_CB_PUPLOAD << 16) | 0x0800); //(p->exec_size * 4));
 
        start = 0; count = p->exec_size;
        while (count) {
-               struct nouveau_winsys *nvws = nv50->screen->nvws;
+               struct nouveau_channel *chan = nv50->screen->base.channel;
                unsigned nr;
 
-               so_emit(nvws, so);
+               so_emit(chan, so);
 
                nr = MIN2(count, 2047);
-               nr = MIN2(nvws->channel->pushbuf->remaining, nr);
-               if (nvws->channel->pushbuf->remaining < (nr + 3)) {
+               nr = MIN2(chan->pushbuf->remaining, nr);
+               if (chan->pushbuf->remaining < (nr + 3)) {
                        FIRE_RING(chan);
                        continue;
                }
@@ -1704,10 +2395,10 @@ nv50_vertprog_validate(struct nv50_context *nv50)
 
        so = so_new(13, 2);
        so_method(so, tesla, NV50TCL_VP_ADDRESS_HIGH, 2);
-       so_reloc (so, p->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD |
-                 NOUVEAU_BO_HIGH, 0, 0);
-       so_reloc (so, p->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD |
-                 NOUVEAU_BO_LOW, 0, 0);
+       so_reloc (so, p->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD |
+                     NOUVEAU_BO_HIGH, 0, 0);
+       so_reloc (so, p->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD |
+                     NOUVEAU_BO_LOW, 0, 0);
        so_method(so, tesla, 0x1650, 2);
        so_data  (so, p->cfg.vp.attr[0]);
        so_data  (so, p->cfg.vp.attr[1]);
@@ -1728,6 +2419,7 @@ nv50_fragprog_validate(struct nv50_context *nv50)
        struct nouveau_grobj *tesla = nv50->screen->tesla;
        struct nv50_program *p = nv50->fragprog;
        struct nouveau_stateobj *so;
+       unsigned i;
 
        if (!p->translated) {
                nv50_program_validate(nv50, p);
@@ -1740,22 +2432,27 @@ nv50_fragprog_validate(struct nv50_context *nv50)
 
        so = so_new(64, 2);
        so_method(so, tesla, NV50TCL_FP_ADDRESS_HIGH, 2);
-       so_reloc (so, p->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD |
-                 NOUVEAU_BO_HIGH, 0, 0);
-       so_reloc (so, p->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD |
-                 NOUVEAU_BO_LOW, 0, 0);
+       so_reloc (so, p->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD |
+                     NOUVEAU_BO_HIGH, 0, 0);
+       so_reloc (so, p->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD |
+                     NOUVEAU_BO_LOW, 0, 0);
        so_method(so, tesla, 0x1904, 4);
-       so_data  (so, 0x00040404); /* p: 0x01000404 */
+       so_data  (so, p->cfg.fp.regs[0]); /* 0x01000404 / 0x00040404 */
        so_data  (so, 0x00000004);
        so_data  (so, 0x00000000);
        so_data  (so, 0x00000000);
-       so_method(so, tesla, 0x16bc, 3); /*XXX: fixme */
-       so_data  (so, 0x03020100);
-       so_data  (so, 0x07060504);
-       so_data  (so, 0x0b0a0908);
+       so_method(so, tesla, 0x16bc, p->cfg.fp.high_map);
+       for (i = 0; i < p->cfg.fp.high_map; i++)
+               so_data(so, p->cfg.fp.map[i]);
        so_method(so, tesla, 0x1988, 2);
-       so_data  (so, 0x08080408); //0x08040404); /* p: 0x0f000401 */
+       so_data  (so, p->cfg.fp.regs[1]); /* 0x08040404 / 0x0f000401 */
        so_data  (so, p->cfg.high_temp);
+       so_method(so, tesla, 0x1298, 1);
+       so_data  (so, p->cfg.high_result);
+       so_method(so, tesla, 0x19a8, 1);
+       so_data  (so, p->cfg.fp.regs[2]);
+       so_method(so, tesla, 0x196c, 1);
+       so_data  (so, p->cfg.fp.regs[3]);
        so_method(so, tesla, 0x1414, 1);
        so_data  (so, 0); /* program start offset */
        so_ref(so, &nv50->state.fragprog);
@@ -1765,8 +2462,6 @@ nv50_fragprog_validate(struct nv50_context *nv50)
 void
 nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p)
 {
-       struct pipe_screen *pscreen = nv50->pipe.screen;
-
        while (p->exec_head) {
                struct nv50_program_exec *e = p->exec_head;
 
@@ -1776,10 +2471,10 @@ nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p)
        p->exec_tail = NULL;
        p->exec_size = 0;
 
-       if (p->buffer)
-               pipe_buffer_reference(&p->buffer, NULL);
+       nouveau_bo_ref(NULL, &p->bo);
 
-       nv50->screen->nvws->res_free(&p->data);
+       nouveau_resource_free(&p->data[0]);
+       nouveau_resource_free(&p->data[1]);
 
        p->translated = 0;
 }
index 78deed6a3843f2eaf06ada5ef6d440157b4ae149..096e0476aab64a32bbcb53d8854fc9324eaeb623 100644 (file)
@@ -24,10 +24,10 @@ struct nv50_program {
        struct nv50_program_exec *exec_head;
        struct nv50_program_exec *exec_tail;
        unsigned exec_size;
-       struct nouveau_resource *data;
-       unsigned data_start;
+       struct nouveau_resource *data[2];
+       unsigned data_start[2];
 
-       struct pipe_buffer *buffer;
+       struct nouveau_bo *bo;
 
        float *immd;
        unsigned immd_nr;
@@ -39,6 +39,11 @@ struct nv50_program {
                struct {
                        unsigned attr[2];
                } vp;
+               struct {
+                       unsigned regs[4];
+                       unsigned map[5];
+                       unsigned high_map;
+               } fp;
        } cfg;
 };
 
index 35cebdbdc32c1481eb3a621846fff552708d826b..940e04365f255498fc278632aac719e3e984faf5 100644 (file)
@@ -26,7 +26,7 @@
 #include "nv50_context.h"
 
 struct nv50_query {
-       struct pipe_buffer *buffer;
+       struct nouveau_bo *bo;
        unsigned type;
        boolean ready;
        uint64_t result;
@@ -41,14 +41,16 @@ nv50_query(struct pipe_query *pipe)
 static struct pipe_query *
 nv50_query_create(struct pipe_context *pipe, unsigned type)
 {
-       struct pipe_screen *screen = pipe->screen;
+       struct nouveau_device *dev = nouveau_screen(pipe->screen)->device;
        struct nv50_query *q = CALLOC_STRUCT(nv50_query);
+       int ret;
 
        assert (q->type == PIPE_QUERY_OCCLUSION_COUNTER);
        q->type = type;
 
-       q->buffer = screen->buffer_create(screen, 256, 0, 16);
-       if (!q->buffer) {
+       ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM | NOUVEAU_BO_MAP, 256,
+                            16, &q->bo);
+       if (ret) {
                FREE(q);
                return NULL;
        }
@@ -62,7 +64,7 @@ nv50_query_destroy(struct pipe_context *pipe, struct pipe_query *pq)
        struct nv50_query *q = nv50_query(pq);
 
        if (q) {
-               pipe_buffer_reference(&q->buffer, NULL);
+               nouveau_bo_ref(NULL, &q->bo);
                FREE(q);
        }
 }
@@ -71,7 +73,7 @@ static void
 nv50_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
 {
        struct nv50_context *nv50 = nv50_context(pipe);
-       struct nouveau_channel *chan = nv50->screen->nvws->channel;
+       struct nouveau_channel *chan = nv50->screen->base.channel;
        struct nouveau_grobj *tesla = nv50->screen->tesla;
        struct nv50_query *q = nv50_query(pq);
 
@@ -87,15 +89,14 @@ static void
 nv50_query_end(struct pipe_context *pipe, struct pipe_query *pq)
 {
        struct nv50_context *nv50 = nv50_context(pipe);
-       struct nouveau_channel *chan = nv50->screen->nvws->channel;
+       struct nouveau_channel *chan = nv50->screen->base.channel;
        struct nouveau_grobj *tesla = nv50->screen->tesla;
        struct nv50_query *q = nv50_query(pq);
-       struct nouveau_bo *bo = nv50->screen->nvws->get_bo(q->buffer);
 
        WAIT_RING (chan, 5);
        BEGIN_RING(chan, tesla, 0x1b00, 4);
-       OUT_RELOCh(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
-       OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+       OUT_RELOCh(chan, q->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+       OUT_RELOCl(chan, q->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
        OUT_RING  (chan, 0x00000000);
        OUT_RING  (chan, 0x0100f002);
        FIRE_RING (chan);
@@ -105,7 +106,6 @@ static boolean
 nv50_query_result(struct pipe_context *pipe, struct pipe_query *pq,
                  boolean wait, uint64_t *result)
 {
-       struct pipe_winsys *ws = pipe->winsys;
        struct nv50_query *q = nv50_query(pq);
 
        /*XXX: Want to be able to return FALSE here instead of blocking
@@ -113,11 +113,10 @@ nv50_query_result(struct pipe_context *pipe, struct pipe_query *pq,
         */
 
        if (!q->ready) {
-               uint32_t *map = ws->buffer_map(ws, q->buffer,
-                                              PIPE_BUFFER_USAGE_CPU_READ);
-               q->result = map[1];
+               nouveau_bo_map(q->bo, NOUVEAU_BO_RD);
+               q->result = ((uint32_t *)q->bo->map)[1];
                q->ready = TRUE;
-               ws->buffer_unmap(ws, q->buffer);
+               nouveau_bo_unmap(q->bo);
        }
 
        *result = q->result;
index 298056459489c4dbc895b5f6c3f96f6c82e1c16c..fd39fa738b71957df70f538a0f5ba9ab810796df 100644 (file)
@@ -22,8 +22,6 @@
 
 #include "pipe/p_screen.h"
 
-#include "util/u_simple_screen.h"
-
 #include "nv50_context.h"
 #include "nv50_screen.h"
 
@@ -68,23 +66,6 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen,
        return FALSE;
 }
 
-static const char *
-nv50_screen_get_name(struct pipe_screen *pscreen)
-{
-       struct nv50_screen *screen = nv50_screen(pscreen);
-       struct nouveau_device *dev = screen->nvws->channel->device;
-       static char buffer[128];
-
-       snprintf(buffer, sizeof(buffer), "NV%02X", dev->chipset);
-       return buffer;
-}
-
-static const char *
-nv50_screen_get_vendor(struct pipe_screen *pscreen)
-{
-       return "nouveau";
-}
-
 static int
 nv50_screen_get_param(struct pipe_screen *pscreen, int param)
 {
@@ -153,37 +134,64 @@ nv50_screen_get_paramf(struct pipe_screen *pscreen, int param)
 static void
 nv50_screen_destroy(struct pipe_screen *pscreen)
 {
-       FREE(pscreen);
+       struct nv50_screen *screen = nv50_screen(pscreen);
+
+       nouveau_notifier_free(&screen->sync);
+       nouveau_grobj_free(&screen->tesla);
+       nouveau_grobj_free(&screen->eng2d);
+       nouveau_grobj_free(&screen->m2mf);
+       nouveau_screen_fini(&screen->base);
+       FREE(screen);
 }
 
 struct pipe_screen *
-nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
+nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
 {
        struct nv50_screen *screen = CALLOC_STRUCT(nv50_screen);
+       struct nouveau_channel *chan;
+       struct pipe_screen *pscreen;
        struct nouveau_stateobj *so;
-       unsigned tesla_class = 0, ret;
-       unsigned chipset = nvws->channel->device->chipset;
-       int i;
+       unsigned chipset = dev->chipset;
+       unsigned tesla_class = 0;
+       int ret, i;
 
        if (!screen)
                return NULL;
-       screen->nvws = nvws;
+       pscreen = &screen->base.base;
+
+       ret = nouveau_screen_init(&screen->base, dev);
+       if (ret) {
+               nv50_screen_destroy(pscreen);
+               return NULL;
+       }
+       chan = screen->base.channel;
+
+       pscreen->winsys = ws;
+       pscreen->destroy = nv50_screen_destroy;
+       pscreen->get_param = nv50_screen_get_param;
+       pscreen->get_paramf = nv50_screen_get_paramf;
+       pscreen->is_format_supported = nv50_screen_is_format_supported;
+
+       nv50_screen_init_miptree_functions(pscreen);
+       nv50_transfer_init_screen_functions(pscreen);
 
        /* DMA engine object */
-       ret = nvws->grobj_alloc(nvws, 0x5039, &screen->m2mf);
+       ret = nouveau_grobj_alloc(chan, 0xbeef5039, 0x5039, &screen->m2mf);
        if (ret) {
                NOUVEAU_ERR("Error creating M2MF object: %d\n", ret);
-               nv50_screen_destroy(&screen->pipe);
+               nv50_screen_destroy(pscreen);
                return NULL;
        }
+       BIND_RING(chan, screen->m2mf, 1);
 
        /* 2D object */
-       ret = nvws->grobj_alloc(nvws, NV50_2D, &screen->eng2d);
+       ret = nouveau_grobj_alloc(chan, 0xbeef502d, 0x502d, &screen->eng2d);
        if (ret) {
                NOUVEAU_ERR("Error creating 2D object: %d\n", ret);
-               nv50_screen_destroy(&screen->pipe);
+               nv50_screen_destroy(pscreen);
                return NULL;
        }
+       BIND_RING(chan, screen->eng2d, 2);
 
        /* 3D object */
        switch (chipset & 0xf0) {
@@ -199,70 +207,55 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
                break;
        default:
                NOUVEAU_ERR("Not a known NV50 chipset: NV%02x\n", chipset);
-               nv50_screen_destroy(&screen->pipe);
+               nv50_screen_destroy(pscreen);
                return NULL;
        }
 
        if (tesla_class == 0) {
                NOUVEAU_ERR("Unknown G8x chipset: NV%02x\n", chipset);
-               nv50_screen_destroy(&screen->pipe);
+               nv50_screen_destroy(pscreen);
                return NULL;
        }
 
-       ret = nvws->grobj_alloc(nvws, tesla_class, &screen->tesla);
+       ret = nouveau_grobj_alloc(chan, 0xbeef5097, tesla_class, &screen->tesla);
        if (ret) {
                NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
-               nv50_screen_destroy(&screen->pipe);
+               nv50_screen_destroy(pscreen);
                return NULL;
        }
+       BIND_RING(chan, screen->tesla, 3);
 
        /* Sync notifier */
-       ret = nvws->notifier_alloc(nvws, 1, &screen->sync);
+       ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync);
        if (ret) {
                NOUVEAU_ERR("Error creating notifier object: %d\n", ret);
-               nv50_screen_destroy(&screen->pipe);
+               nv50_screen_destroy(pscreen);
                return NULL;
        }
 
-        /* Setup the pipe */
-       screen->pipe.winsys = ws;
-
-       screen->pipe.destroy = nv50_screen_destroy;
-
-       screen->pipe.get_name = nv50_screen_get_name;
-       screen->pipe.get_vendor = nv50_screen_get_vendor;
-       screen->pipe.get_param = nv50_screen_get_param;
-       screen->pipe.get_paramf = nv50_screen_get_paramf;
-
-       screen->pipe.is_format_supported = nv50_screen_is_format_supported;
-
-       nv50_screen_init_miptree_functions(&screen->pipe);
-       nv50_transfer_init_screen_functions(&screen->pipe);
-       u_simple_screen_init(&screen->pipe);
-
        /* Static M2MF init */
        so = so_new(32, 0);
        so_method(so, screen->m2mf, 0x0180, 3);
        so_data  (so, screen->sync->handle);
-       so_data  (so, screen->nvws->channel->vram->handle);
-       so_data  (so, screen->nvws->channel->vram->handle);
-       so_emit(nvws, so);
+       so_data  (so, chan->vram->handle);
+       so_data  (so, chan->vram->handle);
+       so_emit(chan, so);
        so_ref (NULL, &so);
 
        /* Static 2D init */
        so = so_new(64, 0);
        so_method(so, screen->eng2d, NV50_2D_DMA_NOTIFY, 4);
        so_data  (so, screen->sync->handle);
-       so_data  (so, screen->nvws->channel->vram->handle);
-       so_data  (so, screen->nvws->channel->vram->handle);
-       so_data  (so, screen->nvws->channel->vram->handle);
+       so_data  (so, chan->vram->handle);
+       so_data  (so, chan->vram->handle);
+       so_data  (so, chan->vram->handle);
        so_method(so, screen->eng2d, NV50_2D_OPERATION, 1);
        so_data  (so, NV50_2D_OPERATION_SRCCOPY);
        so_method(so, screen->eng2d, 0x0290, 1);
        so_data  (so, 0);
        so_method(so, screen->eng2d, 0x0888, 1);
        so_data  (so, 1);
-       so_emit(nvws, so);
+       so_emit(chan, so);
        so_ref(NULL, &so);
 
        /* Static tesla init */
@@ -275,11 +268,11 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
        so_method(so, screen->tesla, NV50TCL_DMA_UNK0(0),
                                     NV50TCL_DMA_UNK0__SIZE);
        for (i = 0; i < NV50TCL_DMA_UNK0__SIZE; i++)
-               so_data(so, nvws->channel->vram->handle);
+               so_data(so, chan->vram->handle);
        so_method(so, screen->tesla, NV50TCL_DMA_UNK1(0),
                                     NV50TCL_DMA_UNK1__SIZE);
        for (i = 0; i < NV50TCL_DMA_UNK1__SIZE; i++)
-               so_data(so, nvws->channel->vram->handle);
+               so_data(so, chan->vram->handle);
        so_method(so, screen->tesla, 0x121c, 1);
        so_data  (so, 1);
 
@@ -290,27 +283,81 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
        so_method(so, screen->tesla, 0x16b8, 1);
        so_data  (so, 8);
 
-       /* Shared constant buffer */
-       screen->constbuf = screen->pipe.buffer_create(&screen->pipe, 0, 0, 128 * 4 * 4);
-       if (nvws->res_init(&screen->vp_data_heap, 0, 128)) {
-               NOUVEAU_ERR("Error initialising constant buffer\n");
-               nv50_screen_destroy(&screen->pipe);
+       /* constant buffers for immediates and VP/FP parameters */
+       ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 128*4*4,
+                            &screen->constbuf_misc[0]);
+       if (ret) {
+               nv50_screen_destroy(pscreen);
                return NULL;
        }
 
+       for (i = 0; i < 2; i++) {
+               ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 128*4*4,
+                                    &screen->constbuf_parm[i]);
+               if (ret) {
+                       nv50_screen_destroy(pscreen);
+                       return NULL;
+               }
+       }
+
+       if (nouveau_resource_init(&screen->immd_heap[0], 0, 128) ||
+               nouveau_resource_init(&screen->parm_heap[0], 0, 128) ||
+               nouveau_resource_init(&screen->parm_heap[1], 0, 128))
+       {
+               NOUVEAU_ERR("Error initialising constant buffers.\n");
+               nv50_screen_destroy(pscreen);
+               return NULL;
+       }
+
+       /*
+       // map constant buffers:
+       //  B = buffer ID (maybe more than 1 byte)
+       //  N = CB index used in shader instruction
+       //  P = program type (0 = VP, 2 = GP, 3 = FP)
+       so_method(so, screen->tesla, 0x1694, 1);
+       so_data  (so, 0x000BBNP1);
+       */
+
        so_method(so, screen->tesla, 0x1280, 3);
-       so_reloc (so, screen->constbuf, 0, NOUVEAU_BO_VRAM |
+       so_reloc (so, screen->constbuf_misc[0], 0, NOUVEAU_BO_VRAM |
                  NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
-       so_reloc (so, screen->constbuf, 0, NOUVEAU_BO_VRAM |
+       so_reloc (so, screen->constbuf_misc[0], 0, NOUVEAU_BO_VRAM |
                  NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
-       so_data  (so, (NV50_CB_PMISC << 16) | 0x00001000);
+       so_data  (so, (NV50_CB_PMISC << 16) | 0x00000800);
+       so_method(so, screen->tesla, 0x1694, 1);
+       so_data  (so, 0x00000001 | (NV50_CB_PMISC << 12));
+       so_method(so, screen->tesla, 0x1694, 1);
+       so_data  (so, 0x00000031 | (NV50_CB_PMISC << 12));
+
+       so_method(so, screen->tesla, 0x1280, 3);
+       so_reloc (so, screen->constbuf_parm[0], 0, NOUVEAU_BO_VRAM |
+                 NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
+       so_reloc (so, screen->constbuf_parm[0], 0, NOUVEAU_BO_VRAM |
+                 NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
+       so_data  (so, (NV50_CB_PVP << 16) | 0x00000800);
+       so_method(so, screen->tesla, 0x1694, 1);
+       so_data  (so, 0x00000101 | (NV50_CB_PVP << 12));
+
+       so_method(so, screen->tesla, 0x1280, 3);
+       so_reloc (so, screen->constbuf_parm[1], 0, NOUVEAU_BO_VRAM |
+                 NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
+       so_reloc (so, screen->constbuf_parm[1], 0, NOUVEAU_BO_VRAM |
+                 NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
+       so_data  (so, (NV50_CB_PFP << 16) | 0x00000800);
+       so_method(so, screen->tesla, 0x1694, 1);
+       so_data  (so, 0x00000131 | (NV50_CB_PFP << 12));
 
        /* Texture sampler/image unit setup - we abuse the constant buffer
         * upload mechanism for the moment to upload data to the tex config
         * blocks.  At some point we *may* want to go the NVIDIA way of doing
         * things?
         */
-       screen->tic = screen->pipe.buffer_create(&screen->pipe, 0, 0, 32 * 8 * 4);
+       ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 32*8*4, &screen->tic);
+       if (ret) {
+               nv50_screen_destroy(pscreen);
+               return NULL;
+       }
+
        so_method(so, screen->tesla, 0x1280, 3);
        so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM |
                  NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
@@ -324,7 +371,12 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
                  NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
        so_data  (so, 0x00000800);
 
-       screen->tsc = screen->pipe.buffer_create(&screen->pipe, 0, 0, 32 * 8 * 4);
+       ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 32*8*4, &screen->tsc);
+       if (ret) {
+               nv50_screen_destroy(pscreen);
+               return NULL;
+       }
+
        so_method(so, screen->tesla, 0x1280, 3);
        so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM |
                  NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
@@ -352,14 +404,12 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
 
        so_method(so, screen->tesla, 0x1234, 1);
        so_data  (so, 1);
-       so_method(so, screen->tesla, 0x1458, 1);
-       so_data  (so, 1);
 
-       so_emit(nvws, so);
+       so_emit(chan, so);
        so_ref (so, &screen->static_init);
        so_ref (NULL, &so);
-       nvws->push_flush(nvws, 0, NULL);
+       nouveau_pushbuf_flush(chan, 0);
 
-       return &screen->pipe;
+       return pscreen;
 }
 
index db567aaac892060f28849dbfe416456b8409e256..61e24a5b571746e3b5b9c2af0fb76ff4398b2a2e 100644 (file)
@@ -1,10 +1,10 @@
 #ifndef __NV50_SCREEN_H__
 #define __NV50_SCREEN_H__
 
-#include "pipe/p_screen.h"
+#include "nouveau/nouveau_screen.h"
 
 struct nv50_screen {
-       struct pipe_screen pipe;
+       struct nouveau_screen base;
 
        struct nouveau_winsys *nvws;
 
@@ -15,11 +15,14 @@ struct nv50_screen {
        struct nouveau_grobj *m2mf;
        struct nouveau_notifier *sync;
 
-       struct pipe_buffer *constbuf;
-       struct nouveau_resource *vp_data_heap;
+       struct nouveau_bo *constbuf_misc[1];
+       struct nouveau_bo *constbuf_parm[2];
 
-       struct pipe_buffer *tic;
-       struct pipe_buffer *tsc;
+       struct nouveau_resource *immd_heap[1];
+       struct nouveau_resource *parm_heap[2];
+
+       struct nouveau_bo *tic;
+       struct nouveau_bo *tsc;
 
        struct nouveau_stateobj *static_init;
 };
index ba852194cddde7f6e5b417d566a722c27e1a2f59..116866a8e781cb223331c5552ac8f1de8db68e18 100644 (file)
@@ -136,9 +136,11 @@ static void *
 nv50_sampler_state_create(struct pipe_context *pipe,
                          const struct pipe_sampler_state *cso)
 {
-       unsigned *tsc = CALLOC(8, sizeof(unsigned));
+       struct nv50_sampler_stateobj *sso = CALLOC(1, sizeof(*sso));
+       unsigned *tsc = sso->tsc;
+       float limit;
 
-       tsc[0] = (0x00024000 |
+       tsc[0] = (0x00026000 |
                  (wrap_mode(cso->wrap_s) << 0) |
                  (wrap_mode(cso->wrap_t) << 3) |
                  (wrap_mode(cso->wrap_r) << 6));
@@ -202,7 +204,14 @@ nv50_sampler_state_create(struct pipe_context *pipe,
                tsc[0] |= (nvgl_comparison_op(cso->compare_func) & 0x7);
        }
 
-       return (void *)tsc;
+       limit = CLAMP(cso->lod_bias, -16.0, 15.0);
+       tsc[1] |= ((int)(limit * 256.0) & 0x1fff) << 11;
+
+       tsc[2] |= ((int)CLAMP(cso->max_lod, 0.0, 15.0) << 20) |
+                 ((int)CLAMP(cso->min_lod, 0.0, 15.0) << 8);
+
+       sso->normalized = cso->normalized_coords;
+       return (void *)sso;
 }
 
 static void
index c13d3de1cb9ab9ca0c1fdf251b4bee1176aa44f1..0caf4b4e914dc901af7853c0aab1ba9ba725b346 100644 (file)
@@ -32,6 +32,9 @@ nv50_state_validate_fb(struct nv50_context *nv50)
        unsigned i, w, h, gw = 0;
 
        for (i = 0; i < fb->nr_cbufs; i++) {
+               struct pipe_texture *pt = fb->cbufs[i]->texture;
+               struct nouveau_bo *bo = nv50_miptree(pt)->bo;
+
                if (!gw) {
                        w = fb->cbufs[i]->width;
                        h = fb->cbufs[i]->height;
@@ -46,12 +49,10 @@ nv50_state_validate_fb(struct nv50_context *nv50)
                so_data  (so, fb->cbufs[i]->height);
 
                so_method(so, tesla, NV50TCL_RT_ADDRESS_HIGH(i), 5);
-               so_reloc (so, nv50_surface_buffer(fb->cbufs[i]), fb->cbufs[i]->offset,
-                         NOUVEAU_BO_VRAM | NOUVEAU_BO_HIGH |
-                         NOUVEAU_BO_RDWR, 0, 0);
-               so_reloc (so, nv50_surface_buffer(fb->cbufs[i]), fb->cbufs[i]->offset,
-                         NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW |
-                         NOUVEAU_BO_RDWR, 0, 0);
+               so_reloc (so, bo, fb->cbufs[i]->offset, NOUVEAU_BO_VRAM |
+                             NOUVEAU_BO_HIGH | NOUVEAU_BO_RDWR, 0, 0);
+               so_reloc (so, bo, fb->cbufs[i]->offset, NOUVEAU_BO_VRAM |
+                             NOUVEAU_BO_LOW | NOUVEAU_BO_RDWR, 0, 0);
                switch (fb->cbufs[i]->format) {
                case PIPE_FORMAT_A8R8G8B8_UNORM:
                        so_data(so, 0xcf);
@@ -65,7 +66,7 @@ nv50_state_validate_fb(struct nv50_context *nv50)
                        so_data(so, 0xe6);
                        break;
                }
-               so_data(so, 0x00000000);
+               so_data(so, bo->tile_mode << 4);
                so_data(so, 0x00000000);
 
                so_method(so, tesla, 0x1224, 1);
@@ -73,6 +74,9 @@ nv50_state_validate_fb(struct nv50_context *nv50)
        }
 
        if (fb->zsbuf) {
+               struct pipe_texture *pt = fb->zsbuf->texture;
+               struct nouveau_bo *bo = nv50_miptree(pt)->bo;
+
                if (!gw) {
                        w = fb->zsbuf->width;
                        h = fb->zsbuf->height;
@@ -83,12 +87,10 @@ nv50_state_validate_fb(struct nv50_context *nv50)
                }
 
                so_method(so, tesla, NV50TCL_ZETA_ADDRESS_HIGH, 5);
-               so_reloc (so, nv50_surface_buffer(fb->zsbuf), fb->zsbuf->offset,
-                         NOUVEAU_BO_VRAM | NOUVEAU_BO_HIGH |
-                         NOUVEAU_BO_RDWR, 0, 0);
-               so_reloc (so, nv50_surface_buffer(fb->zsbuf), fb->zsbuf->offset,
-                         NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW |
-                         NOUVEAU_BO_RDWR, 0, 0);
+               so_reloc (so, bo, fb->zsbuf->offset, NOUVEAU_BO_VRAM |
+                             NOUVEAU_BO_HIGH | NOUVEAU_BO_RDWR, 0, 0);
+               so_reloc (so, bo, fb->zsbuf->offset, NOUVEAU_BO_VRAM |
+                             NOUVEAU_BO_LOW | NOUVEAU_BO_RDWR, 0, 0);
                switch (fb->zsbuf->format) {
                case PIPE_FORMAT_Z24S8_UNORM:
                        so_data(so, 0x16);
@@ -102,7 +104,7 @@ nv50_state_validate_fb(struct nv50_context *nv50)
                        so_data(so, 0x16);
                        break;
                }
-               so_data(so, 0x00000000);
+               so_data(so, bo->tile_mode << 4);
                so_data(so, 0x00000000);
 
                so_method(so, tesla, 0x1538, 1);
@@ -131,7 +133,7 @@ static void
 nv50_state_emit(struct nv50_context *nv50)
 {
        struct nv50_screen *screen = nv50->screen;
-       struct nouveau_winsys *nvws = screen->nvws;
+       struct nouveau_channel *chan = screen->base.channel;
 
        if (nv50->pctx_id != screen->cur_pctx) {
                nv50->state.dirty |= 0xffffffff;
@@ -139,40 +141,40 @@ nv50_state_emit(struct nv50_context *nv50)
        }
 
        if (nv50->state.dirty & NV50_NEW_FRAMEBUFFER)
-               so_emit(nvws, nv50->state.fb);
+               so_emit(chan, nv50->state.fb);
        if (nv50->state.dirty & NV50_NEW_BLEND)
-               so_emit(nvws, nv50->state.blend);
+               so_emit(chan, nv50->state.blend);
        if (nv50->state.dirty & NV50_NEW_ZSA)
-               so_emit(nvws, nv50->state.zsa);
+               so_emit(chan, nv50->state.zsa);
        if (nv50->state.dirty & NV50_NEW_VERTPROG)
-               so_emit(nvws, nv50->state.vertprog);
+               so_emit(chan, nv50->state.vertprog);
        if (nv50->state.dirty & NV50_NEW_FRAGPROG)
-               so_emit(nvws, nv50->state.fragprog);
+               so_emit(chan, nv50->state.fragprog);
        if (nv50->state.dirty & NV50_NEW_RASTERIZER)
-               so_emit(nvws, nv50->state.rast);
+               so_emit(chan, nv50->state.rast);
        if (nv50->state.dirty & NV50_NEW_BLEND_COLOUR)
-               so_emit(nvws, nv50->state.blend_colour);
+               so_emit(chan, nv50->state.blend_colour);
        if (nv50->state.dirty & NV50_NEW_STIPPLE)
-               so_emit(nvws, nv50->state.stipple);
+               so_emit(chan, nv50->state.stipple);
        if (nv50->state.dirty & NV50_NEW_SCISSOR)
-               so_emit(nvws, nv50->state.scissor);
+               so_emit(chan, nv50->state.scissor);
        if (nv50->state.dirty & NV50_NEW_VIEWPORT)
-               so_emit(nvws, nv50->state.viewport);
+               so_emit(chan, nv50->state.viewport);
        if (nv50->state.dirty & NV50_NEW_SAMPLER)
-               so_emit(nvws, nv50->state.tsc_upload);
+               so_emit(chan, nv50->state.tsc_upload);
        if (nv50->state.dirty & NV50_NEW_TEXTURE)
-               so_emit(nvws, nv50->state.tic_upload);
+               so_emit(chan, nv50->state.tic_upload);
        if (nv50->state.dirty & NV50_NEW_ARRAYS) {
-               so_emit(nvws, nv50->state.vtxfmt);
-               so_emit(nvws, nv50->state.vtxbuf);
+               so_emit(chan, nv50->state.vtxfmt);
+               so_emit(chan, nv50->state.vtxbuf);
        }
        nv50->state.dirty = 0;
 
-       so_emit_reloc_markers(nvws, nv50->state.fb);
-       so_emit_reloc_markers(nvws, nv50->state.vertprog);
-       so_emit_reloc_markers(nvws, nv50->state.fragprog);
-       so_emit_reloc_markers(nvws, nv50->state.vtxbuf);
-       so_emit_reloc_markers(nvws, nv50->screen->static_init);
+       so_emit_reloc_markers(chan, nv50->state.fb);
+       so_emit_reloc_markers(chan, nv50->state.vertprog);
+       so_emit_reloc_markers(chan, nv50->state.fragprog);
+       so_emit_reloc_markers(chan, nv50->state.vtxbuf);
+       so_emit_reloc_markers(chan, nv50->screen->static_init);
 }
 
 boolean
@@ -293,12 +295,12 @@ viewport_uptodate:
                so_data  (so, NV50_CB_TSC);
                so_method(so, tesla, 0x40000f04, nv50->sampler_nr * 8);
                for (i = 0; i < nv50->sampler_nr; i++)
-                       so_datap (so, nv50->sampler[i], 8);
+                       so_datap (so, nv50->sampler[i]->tsc, 8);
                so_ref(so, &nv50->state.tsc_upload);
                so_ref(NULL, &so);
        }
 
-       if (nv50->dirty & NV50_NEW_TEXTURE)
+       if (nv50->dirty & (NV50_NEW_TEXTURE | NV50_NEW_SAMPLER))
                nv50_tex_validate(nv50);
 
        if (nv50->dirty & NV50_NEW_ARRAYS)
index 0cc5168144d644923ed6e3da7978e5e7135206ab..8db3b6d344dd804ba0ff73926b3b0fd7cb4a6e24 100644 (file)
@@ -52,21 +52,17 @@ static int
 nv50_surface_set(struct nv50_screen *screen, struct pipe_surface *ps, int dst)
 {
        struct nv50_miptree *mt = nv50_miptree(ps->texture);
-       struct nouveau_channel *chan = screen->nvws->channel;
+       struct nouveau_channel *chan = screen->eng2d->channel;
        struct nouveau_grobj *eng2d = screen->eng2d;
-       struct nouveau_bo *bo;
+       struct nouveau_bo *bo = nv50_miptree(ps->texture)->bo;
        int format, mthd = dst ? NV50_2D_DST_FORMAT : NV50_2D_SRC_FORMAT;
        int flags = NOUVEAU_BO_VRAM | (dst ? NOUVEAU_BO_WR : NOUVEAU_BO_RD);
-       bo = screen->nvws->get_bo(nv50_miptree(ps->texture)->buffer);
-       if (!bo)
-               return 1;
 
        format = nv50_format(ps->format);
        if (format < 0)
                return 1;
   
-       if (!bo->tiled) {
+       if (!bo->tile_flags) {
                BEGIN_RING(chan, eng2d, mthd, 2);
                OUT_RING  (chan, format);
                OUT_RING  (chan, 1);
@@ -80,7 +76,7 @@ nv50_surface_set(struct nv50_screen *screen, struct pipe_surface *ps, int dst)
                BEGIN_RING(chan, eng2d, mthd, 5);
                OUT_RING  (chan, format);
                OUT_RING  (chan, 0);
-               OUT_RING  (chan, 0);
+               OUT_RING  (chan, bo->tile_mode << 4);
                OUT_RING  (chan, 1);
                OUT_RING  (chan, 0);
                BEGIN_RING(chan, eng2d, mthd + 0x18, 4);
@@ -108,7 +104,7 @@ nv50_surface_do_copy(struct nv50_screen *screen, struct pipe_surface *dst,
                     int dx, int dy, struct pipe_surface *src, int sx, int sy,
                     int w, int h)
 {
-       struct nouveau_channel *chan = screen->nvws->channel;
+       struct nouveau_channel *chan = screen->eng2d->channel;
        struct nouveau_grobj *eng2d = screen->eng2d;
        int ret;
 
@@ -165,7 +161,7 @@ nv50_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
 {
        struct nv50_context *nv50 = (struct nv50_context *)pipe;
        struct nv50_screen *screen = nv50->screen;
-       struct nouveau_channel *chan = screen->nvws->channel;
+       struct nouveau_channel *chan = screen->eng2d->channel;
        struct nouveau_grobj *eng2d = screen->eng2d;
        int format, ret;
 
index 223c8a3a456197bf04931e817c6ba0b1470456e2..ff40c2ad81bc30dd17ce6ccd773edbaced668493 100644 (file)
@@ -26,7 +26,8 @@
 #include "nouveau/nouveau_stateobj.h"
 
 static int
-nv50_tex_construct(struct nouveau_stateobj *so, struct nv50_miptree *mt)
+nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so,
+                  struct nv50_miptree *mt, int unit)
 {
        switch (mt->base.format) {
        case PIPE_FORMAT_A8R8G8B8_UNORM:
@@ -117,15 +118,18 @@ nv50_tex_construct(struct nouveau_stateobj *so, struct nv50_miptree *mt)
                return 1;
        }
 
-       so_reloc(so, mt->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW |
+       so_reloc(so, mt->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW |
                     NOUVEAU_BO_RD, 0, 0);
-       so_data (so, 0xd0005000);
+       if (nv50->sampler[unit]->normalized)
+               so_data (so, 0xd0005000 | mt->bo->tile_mode << 22);
+       else
+               so_data (so, 0x5001d000 | mt->bo->tile_mode << 22);
        so_data (so, 0x00300000);
        so_data (so, mt->base.width[0]);
-       so_data (so, (mt->base.depth[0] << 16) | mt->base.height[0]);
+       so_data (so, (mt->base.last_level << 28) |
+                    (mt->base.depth[0] << 16) | mt->base.height[0]);
        so_data (so, 0x03000000);
-       so_reloc(so, mt->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_HIGH |
-                    NOUVEAU_BO_RD, 0, 0);
+       so_data (so, mt->base.last_level << 4);
 
        return 0;
 }
@@ -135,23 +139,35 @@ nv50_tex_validate(struct nv50_context *nv50)
 {
        struct nouveau_grobj *tesla = nv50->screen->tesla;
        struct nouveau_stateobj *so;
-       int unit;
+       int unit, push;
+
+       push  = nv50->miptree_nr * 9 + 2;
+       push += MAX2(nv50->miptree_nr, nv50->state.miptree_nr) * 2;
 
-       so = so_new(nv50->miptree_nr * 8 + 3, nv50->miptree_nr * 2);
+       so = so_new(push, nv50->miptree_nr * 2);
        so_method(so, tesla, 0x0f00, 1);
        so_data  (so, NV50_CB_TIC);
-       so_method(so, tesla, 0x40000f04, nv50->miptree_nr * 8);
        for (unit = 0; unit < nv50->miptree_nr; unit++) {
                struct nv50_miptree *mt = nv50->miptree[unit];
 
-               if (nv50_tex_construct(so, mt)) {
+               so_method(so, tesla, 0x40000f04, 8);
+               if (nv50_tex_construct(nv50, so, mt, unit)) {
                        NOUVEAU_ERR("failed tex validate\n");
                        so_ref(NULL, &so);
                        return;
                }
+
+               so_method(so, tesla, 0x1458, 1);
+               so_data  (so, (unit << 9) | (unit << 1) | 1);
+       }
+
+       for (; unit < nv50->state.miptree_nr; unit++) {
+               so_method(so, tesla, 0x1458, 1);
+               so_data  (so, (unit << 1) | 0);
        }
 
        so_ref(so, &nv50->state.tic_upload);
        so_ref(NULL, &so);
+       nv50->state.miptree_nr = nv50->miptree_nr;
 }
 
index 747195b4f6370555c6cecafee36b8c63e4c5f8f9..d0b7f0bef43900cce8f4126703b4bd05604764ce 100644 (file)
@@ -6,8 +6,8 @@
 
 struct nv50_transfer {
        struct pipe_transfer base;
-       struct pipe_buffer *buffer;
-       struct nv50_miptree_level *level;
+       struct nouveau_bo *bo;
+       unsigned level_offset;
        int level_pitch;
        int level_width;
        int level_height;
@@ -16,51 +16,48 @@ struct nv50_transfer {
 };
 
 static void
-nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct pipe_buffer *src,
-                       int src_pitch, int sx, int sy, int sw, int sh,
-                       struct pipe_buffer *dst, int dst_pitch, int dx, int dy,
+nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct nouveau_bo *src_bo,
+                       unsigned src_offset, int src_pitch, int sx, int sy,
+                       int sw, int sh, struct nouveau_bo *dst_bo,
+                       unsigned dst_offset, int dst_pitch, int dx, int dy,
                        int dw, int dh, int cpp, int width, int height,
                        unsigned src_reloc, unsigned dst_reloc)
 {
        struct nv50_screen *screen = nv50_screen(pscreen);
-       struct nouveau_winsys *nvws = screen->nvws;
-       struct nouveau_channel *chan = nvws->channel;
+       struct nouveau_channel *chan = screen->m2mf->channel;
        struct nouveau_grobj *m2mf = screen->m2mf;
-       struct nouveau_bo *src_bo = nvws->get_bo(src);
-       struct nouveau_bo *dst_bo = nvws->get_bo(dst);
-       unsigned src_offset = 0, dst_offset = 0;
 
        src_reloc |= NOUVEAU_BO_RD;
        dst_reloc |= NOUVEAU_BO_WR;
 
        WAIT_RING (chan, 14);
 
-       if (!src_bo->tiled) {
+       if (!src_bo->tile_flags) {
                BEGIN_RING(chan, m2mf, 0x0200, 1);
                OUT_RING  (chan, 1);
                BEGIN_RING(chan, m2mf, 0x0314, 1);
                OUT_RING  (chan, src_pitch);
-               src_offset = (sy * src_pitch) + (sx * cpp);
+               src_offset += (sy * src_pitch) + (sx * cpp);
        } else {
                BEGIN_RING(chan, m2mf, 0x0200, 6);
                OUT_RING  (chan, 0);
-               OUT_RING  (chan, 0);
+               OUT_RING  (chan, src_bo->tile_mode << 4);
                OUT_RING  (chan, sw * cpp);
                OUT_RING  (chan, sh);
                OUT_RING  (chan, 1);
                OUT_RING  (chan, 0);
        }
 
-       if (!dst_bo->tiled) {
+       if (!dst_bo->tile_flags) {
                BEGIN_RING(chan, m2mf, 0x021c, 1);
                OUT_RING  (chan, 1);
                BEGIN_RING(chan, m2mf, 0x0318, 1);
                OUT_RING  (chan, dst_pitch);
-               dst_offset = (dy * dst_pitch) + (dx * cpp);
+               dst_offset += (dy * dst_pitch) + (dx * cpp);
        } else {
                BEGIN_RING(chan, m2mf, 0x021c, 6);
                OUT_RING  (chan, 0);
-               OUT_RING  (chan, 0);
+               OUT_RING  (chan, dst_bo->tile_mode << 4);
                OUT_RING  (chan, dw * cpp);
                OUT_RING  (chan, dh);
                OUT_RING  (chan, 1);
@@ -77,13 +74,13 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct pipe_buffer *src,
                BEGIN_RING(chan, m2mf, 0x030c, 2);
                OUT_RELOCl(chan, src_bo, src_offset, src_reloc);
                OUT_RELOCl(chan, dst_bo, dst_offset, dst_reloc);
-               if (src_bo->tiled) {
+               if (src_bo->tile_flags) {
                        BEGIN_RING(chan, m2mf, 0x0218, 1);
                        OUT_RING  (chan, (dy << 16) | sx);
                } else {
                        src_offset += (line_count * src_pitch);
                }
-               if (dst_bo->tiled) {
+               if (dst_bo->tile_flags) {
                        BEGIN_RING(chan, m2mf, 0x0234, 1);
                        OUT_RING  (chan, (sy << 16) | dx);
                } else {
@@ -108,10 +105,12 @@ nv50_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                  enum pipe_transfer_usage usage,
                  unsigned x, unsigned y, unsigned w, unsigned h)
 {
+       struct nouveau_device *dev = nouveau_screen(pscreen)->device;
        struct nv50_miptree *mt = nv50_miptree(pt);
        struct nv50_miptree_level *lvl = &mt->level[level];
        struct nv50_transfer *tx;
        unsigned image = 0;
+       int ret;
 
        if (pt->target == PIPE_TEXTURE_CUBE)
                image = face;
@@ -133,20 +132,24 @@ nv50_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
        tx->base.stride = (w * pt->block.size);
        tx->base.usage = usage;
 
-       tx->level = lvl;
        tx->level_pitch = lvl->pitch;
        tx->level_width = mt->base.width[level];
        tx->level_height = mt->base.height[level];
+       tx->level_offset = lvl->image_offset[image];
        tx->level_x = x;
        tx->level_y = y;
-       tx->buffer =
-               pipe_buffer_create(pscreen, 0, NOUVEAU_BUFFER_USAGE_TRANSFER,
-                                  w * tx->base.block.size * h);
+       ret = nouveau_bo_new(dev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0,
+                            w * pt->block.size * h, &tx->bo);
+       if (ret) {
+               FREE(tx);
+               return NULL;
+       }
 
        if (usage != PIPE_TRANSFER_WRITE) {
-               nv50_transfer_rect_m2mf(pscreen, mt->buffer, tx->level_pitch,
-                                       x, y, tx->level_width, tx->level_height,
-                                       tx->buffer, tx->base.stride, 0, 0,
+               nv50_transfer_rect_m2mf(pscreen, mt->bo, tx->level_offset,
+                                       tx->level_pitch, x, y, tx->level_width,
+                                       tx->level_height, tx->bo, 0,
+                                       tx->base.stride, 0, 0,
                                        tx->base.width, tx->base.height,
                                        tx->base.block.size, w, h,
                                        NOUVEAU_BO_VRAM | NOUVEAU_BO_GART,
@@ -164,17 +167,18 @@ nv50_transfer_del(struct pipe_transfer *ptx)
 
        if (ptx->usage != PIPE_TRANSFER_READ) {
                struct pipe_screen *pscreen = ptx->texture->screen;
-               nv50_transfer_rect_m2mf(pscreen, tx->buffer, tx->base.stride,
+               nv50_transfer_rect_m2mf(pscreen, tx->bo, 0, tx->base.stride,
                                        0, 0, tx->base.width, tx->base.height,
-                                       mt->buffer, tx->level_pitch,
-                                       tx->level_x, tx->level_y,
-                                       tx->level_width, tx->level_height,
-                                       tx->base.block.size, tx->base.width,
-                                       tx->base.height, NOUVEAU_BO_GART,
-                                       NOUVEAU_BO_VRAM | NOUVEAU_BO_GART);
+                                       mt->bo, tx->level_offset,
+                                       tx->level_pitch, tx->level_x,
+                                       tx->level_y, tx->level_width,
+                                       tx->level_height, tx->base.block.size,
+                                       tx->base.width, tx->base.height,
+                                       NOUVEAU_BO_GART, NOUVEAU_BO_VRAM |
+                                       NOUVEAU_BO_GART);
        }
 
-       pipe_buffer_reference(&tx->buffer, NULL);
+       nouveau_bo_ref(NULL, &tx->bo);
        pipe_texture_reference(&ptx->texture, NULL);
        FREE(ptx);
 }
@@ -184,13 +188,17 @@ nv50_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
 {
        struct nv50_transfer *tx = (struct nv50_transfer *)ptx;
        unsigned flags = 0;
+       int ret;
 
        if (ptx->usage & PIPE_TRANSFER_WRITE)
-               flags |= PIPE_BUFFER_USAGE_CPU_WRITE;
+               flags |= NOUVEAU_BO_WR;
        if (ptx->usage & PIPE_TRANSFER_READ)
-               flags |= PIPE_BUFFER_USAGE_CPU_READ;
+               flags |= NOUVEAU_BO_RD;
 
-       return pipe_buffer_map(pscreen, tx->buffer, flags);
+       ret = nouveau_bo_map(tx->bo, flags);
+       if (ret)
+               return NULL;
+       return tx->bo->map;
 }
 
 static void
@@ -198,7 +206,7 @@ nv50_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
 {
        struct nv50_transfer *tx = (struct nv50_transfer *)ptx;
 
-       pipe_buffer_unmap(pscreen, tx->buffer);
+       nouveau_bo_unmap(tx->bo);
 }
 
 void
index 0749c906914859c3c9b01f9e34d91271afc52ce8..f81929f2387f909875dd4a3ae241c0eaa3caf247 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
+#include "pipe/p_inlines.h"
 
 #include "nv50_context.h"
 
@@ -53,7 +54,7 @@ nv50_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start,
                 unsigned count)
 {
        struct nv50_context *nv50 = nv50_context(pipe);
-       struct nouveau_channel *chan = nv50->screen->nvws->channel;
+       struct nouveau_channel *chan = nv50->screen->tesla->channel;
        struct nouveau_grobj *tesla = nv50->screen->tesla;
 
        nv50_state_validate(nv50);
@@ -83,7 +84,7 @@ static INLINE void
 nv50_draw_elements_inline_u08(struct nv50_context *nv50, uint8_t *map,
                              unsigned start, unsigned count)
 {
-       struct nouveau_channel *chan = nv50->screen->nvws->channel;
+       struct nouveau_channel *chan = nv50->screen->tesla->channel;
        struct nouveau_grobj *tesla = nv50->screen->tesla;
 
        map += start;
@@ -112,7 +113,7 @@ static INLINE void
 nv50_draw_elements_inline_u16(struct nv50_context *nv50, uint16_t *map,
                              unsigned start, unsigned count)
 {
-       struct nouveau_channel *chan = nv50->screen->nvws->channel;
+       struct nouveau_channel *chan = nv50->screen->tesla->channel;
        struct nouveau_grobj *tesla = nv50->screen->tesla;
 
        map += start;
@@ -141,7 +142,7 @@ static INLINE void
 nv50_draw_elements_inline_u32(struct nv50_context *nv50, uint8_t *map,
                              unsigned start, unsigned count)
 {
-       struct nouveau_channel *chan = nv50->screen->nvws->channel;
+       struct nouveau_channel *chan = nv50->screen->tesla->channel;
        struct nouveau_grobj *tesla = nv50->screen->tesla;
 
        map += start;
@@ -163,10 +164,12 @@ nv50_draw_elements(struct pipe_context *pipe,
                   unsigned mode, unsigned start, unsigned count)
 {
        struct nv50_context *nv50 = nv50_context(pipe);
-       struct nouveau_channel *chan = nv50->screen->nvws->channel;
+       struct nouveau_channel *chan = nv50->screen->tesla->channel;
        struct nouveau_grobj *tesla = nv50->screen->tesla;
-       struct pipe_winsys *ws = pipe->winsys;
-       void *map = ws->buffer_map(ws, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ);
+       struct pipe_screen *pscreen = pipe->screen;
+       void *map;
+       
+       map = pipe_buffer_map(pscreen, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ);
 
        nv50_state_validate(nv50);
 
@@ -193,6 +196,7 @@ nv50_draw_elements(struct pipe_context *pipe,
        BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1);
        OUT_RING  (chan, 0);
 
+       pipe_buffer_unmap(pscreen, indexBuffer);
        pipe->flush(pipe, 0, NULL);
        return TRUE;
 }
@@ -212,6 +216,7 @@ nv50_vbo_validate(struct nv50_context *nv50)
                struct pipe_vertex_element *ve = &nv50->vtxelt[i];
                struct pipe_vertex_buffer *vb =
                        &nv50->vtxbuf[ve->vertex_buffer_index];
+               struct nouveau_bo *bo = nouveau_bo(vb->buffer);
 
                switch (ve->src_format) {
                case PIPE_FORMAT_R32G32B32A32_FLOAT:
@@ -240,10 +245,10 @@ nv50_vbo_validate(struct nv50_context *nv50)
 
                so_method(vtxbuf, tesla, 0x900 + (i * 16), 3);
                so_data  (vtxbuf, 0x20000000 | vb->stride);
-               so_reloc (vtxbuf, vb->buffer, vb->buffer_offset +
+               so_reloc (vtxbuf, bo, vb->buffer_offset +
                          ve->src_offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART |
                          NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
-               so_reloc (vtxbuf, vb->buffer, vb->buffer_offset +
+               so_reloc (vtxbuf, bo, vb->buffer_offset +
                          ve->src_offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART |
                          NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
        }
index 9d95ad918c2b7c56be983bee7f0e2963f7bb4b7c..00fae8d26f3df80d1efede5f938a2baf314be5a8 100644 (file)
@@ -34,7 +34,6 @@ void r300_parse_chipset(struct r300_capabilities* caps)
     caps->is_r500 = FALSE;
     caps->num_vert_fpus = 4;
 
-
     /* Note: These are not ordered by PCI ID. I leave that task to GCC,
      * which will perform the ordering while collating jump tables. Instead,
      * I've tried to group them according to capabilities and age. */
@@ -150,6 +149,7 @@ void r300_parse_chipset(struct r300_capabilities* caps)
             caps->num_vert_fpus = 6;
             break;
 
+        case 0x4B48:
         case 0x4B49:
         case 0x4B4A:
         case 0x4B4B:
@@ -349,7 +349,4 @@ void r300_parse_chipset(struct r300_capabilities* caps)
                 caps->pci_id);
             break;
     }
-
-    /* XXX SW TCL is broken so no forcing it off right now
-    caps->has_tcl = FALSE; */
 }
index 21eebeae6005c8a6d4b5f2b119b3286c65a4b287..5b2e1f0568817e6bb54c7731ffc098d5da41accf 100644 (file)
@@ -34,8 +34,6 @@ struct r300_capabilities {
     int family;
     /* The number of vertex floating-point units */
     int num_vert_fpus;
-    /* The number of fragment pipes */
-    int num_frag_pipes;
     /* Whether or not TCL is physically present */
     boolean has_tcl;
     /* Whether or not this is an RV515 or newer; R500s have many differences
index 6bdf544a05c4d3c7ad36fd3fb5bcd9b30e871058..233a32b53c5b5c5e34cf6859154a3e1c9ee825e5 100644 (file)
@@ -34,10 +34,6 @@ static boolean r300_draw_range_elements(struct pipe_context* pipe,
     struct r300_context* r300 = r300_context(pipe);
     int i;
 
-    if (r300->dirty_state) {
-        r300_emit_dirty_state(r300);
-    }
-
     for (i = 0; i < r300->vertex_buffer_count; i++) {
         void* buf = pipe_buffer_map(pipe->screen,
                                     r300->vertex_buffers[i].buffer,
@@ -133,7 +129,6 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
     if (!r300)
         return NULL;
 
-    /* XXX this could be refactored now? */
     r300->winsys = r300_winsys;
 
     r300->context.winsys = (struct pipe_winsys*)r300_winsys;
@@ -150,8 +145,15 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
     r300->context.is_texture_referenced = r300_is_texture_referenced;
     r300->context.is_buffer_referenced = r300_is_buffer_referenced;
 
+    /* Create a Draw. This is used for vert collation and SW TCL. */
     r300->draw = draw_create();
+    /* Enable our renderer. */
     draw_set_rasterize_stage(r300->draw, r300_draw_stage(r300));
+    /* Disable Draw's clipping if TCL is present. */
+    draw_set_driver_clipping(r300->draw, r300_screen(screen)->caps->has_tcl);
+    /* Force Draw to never do viewport transform, since (again) we can do
+     * transform in hardware, always. */
+    draw_set_viewport_state(r300->draw, &r300_viewport_identity);
 
     r300->blend_color_state = CALLOC_STRUCT(r300_blend_color_state);
     r300->rs_block = CALLOC_STRUCT(r300_rs_block);
index 6f62998b35d14b12cf16b1e6ac8a8f5dd8a2346e..27bc7fd1a930d80e0f1e0435896c68f845d0877c 100644 (file)
@@ -63,6 +63,11 @@ struct r300_rs_state {
     /* Draw-specific rasterizer state */
     struct pipe_rasterizer_state rs;
 
+    /* Whether or not to enable the VTE. This is referenced at the very
+     * last moment during emission of VTE state, to decide whether or not
+     * the VTE should be used for transformation. */
+    boolean enable_vte;
+
     uint32_t vap_control_status;    /* R300_VAP_CNTL_STATUS: 0x2140 */
     uint32_t point_size;            /* R300_GA_POINT_SIZE: 0x421c */
     uint32_t point_minmax;          /* R300_GA_POINT_MINMAX: 0x4230 */
@@ -112,23 +117,24 @@ struct r300_viewport_state {
     uint32_t vte_control; /* R300_VAP_VTE_CNTL:      0x20b0 */
 };
 
-#define R300_NEW_BLEND           0x0000001
-#define R300_NEW_BLEND_COLOR     0x0000002
-#define R300_NEW_CONSTANTS       0x0000004
-#define R300_NEW_DSA             0x0000008
-#define R300_NEW_FRAMEBUFFERS    0x0000010
-#define R300_NEW_FRAGMENT_SHADER 0x0000020
-#define R300_NEW_RASTERIZER      0x0000040
-#define R300_NEW_RS_BLOCK        0x0000080
-#define R300_NEW_SAMPLER         0x0000100
-#define R300_ANY_NEW_SAMPLERS    0x000ff00
-#define R300_NEW_SCISSOR         0x0010000
-#define R300_NEW_TEXTURE         0x0020000
-#define R300_ANY_NEW_TEXTURES    0x1fe0000
-#define R300_NEW_VERTEX_FORMAT   0x2000000
-#define R300_NEW_VERTEX_SHADER   0x4000000
-#define R300_NEW_VIEWPORT        0x8000000
-#define R300_NEW_KITCHEN_SINK    0xfffffff
+#define R300_NEW_BLEND           0x00000001
+#define R300_NEW_BLEND_COLOR     0x00000002
+#define R300_NEW_CLIP            0x00000004
+#define R300_NEW_CONSTANTS       0x00000008
+#define R300_NEW_DSA             0x00000010
+#define R300_NEW_FRAMEBUFFERS    0x00000020
+#define R300_NEW_FRAGMENT_SHADER 0x00000040
+#define R300_NEW_RASTERIZER      0x00000080
+#define R300_NEW_RS_BLOCK        0x00000100
+#define R300_NEW_SAMPLER         0x00000200
+#define R300_ANY_NEW_SAMPLERS    0x0001fe00
+#define R300_NEW_SCISSOR         0x00020000
+#define R300_NEW_TEXTURE         0x00040000
+#define R300_ANY_NEW_TEXTURES    0x03fc0000
+#define R300_NEW_VERTEX_FORMAT   0x04000000
+#define R300_NEW_VERTEX_SHADER   0x08000000
+#define R300_NEW_VIEWPORT        0x10000000
+#define R300_NEW_KITCHEN_SINK    0x1fffffff
 
 /* The next several objects are not pure Radeon state; they inherit from
  * various Gallium classes. */
@@ -136,11 +142,11 @@ struct r300_viewport_state {
 struct r300_constant_buffer {
     /* Buffer of constants */
     /* XXX first number should be raised */
-    float constants[8][4];
+    float constants[32][4];
     /* Number of user-defined constants */
-    int user_count;
+    unsigned user_count;
     /* Total number of constants */
-    int count;
+    unsigned count;
 };
 
 struct r3xx_fragment_shader {
@@ -153,6 +159,10 @@ struct r3xx_fragment_shader {
 
     /* Pixel stack size */
     int stack_size;
+
+    /* Are there immediates in this shader?
+     * If not, we can heavily optimize recompilation. */
+    boolean uses_imms;
 };
 
 struct r300_fragment_shader {
@@ -243,6 +253,10 @@ struct r300_vertex_shader {
     /* Has this shader been translated yet? */
     boolean translated;
 
+    /* Are there immediates in this shader?
+     * If not, we can heavily optimize recompilation. */
+    boolean uses_imms;
+
     /* Number of used instructions */
     int instruction_count;
 
@@ -255,6 +269,11 @@ struct r300_vertex_shader {
     } instructions[128]; /*< XXX magic number */
 };
 
+static struct pipe_viewport_state r300_viewport_identity = {
+    .scale = {1.0, 1.0, 1.0, 1.0},
+    .translate = {0.0, 0.0, 0.0, 0.0},
+};
+
 struct r300_context {
     /* Parent class */
     struct pipe_context context;
@@ -264,11 +283,18 @@ struct r300_context {
     /* Draw module. Used mostly for SW TCL. */
     struct draw_context* draw;
 
+    /* Vertex buffer for rendering. */
+    struct pipe_buffer* vbo;
+    /* Offset into the VBO. */
+    size_t vbo_offset;
+
     /* Various CSO state objects. */
     /* Blend state. */
     struct r300_blend_state* blend_state;
     /* Blend color state. */
     struct r300_blend_color_state* blend_color_state;
+    /* User clip planes. */
+    struct pipe_clip_state clip_state;
     /* Shader constants. */
     struct r300_constant_buffer shader_constants[PIPE_SHADER_TYPES];
     /* Depth, stencil, and alpha state. */
@@ -289,7 +315,7 @@ struct r300_context {
     /* Texture states. */
     struct r300_texture* textures[8];
     int texture_count;
-    /* Vertex buffers. */
+    /* Vertex buffers for Gallium. */
     struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS];
     int vertex_buffer_count;
     /* Vertex information. */
index 82a3942248efc08cb006f0cbd18f343f30f0ff68..71b142c0dbf10a4c6d86a71bf6339b4e78845bcf 100644 (file)
@@ -34,6 +34,7 @@
 
 #define MAX_CS_SIZE 64 * 1024 / 4
 
+#define VERY_VERBOSE_CS 0
 #define VERY_VERBOSE_REGISTERS 0
 
 /* XXX stolen from radeon_drm.h */
 
 #define BEGIN_CS(size) do { \
     CHECK_CS(size); \
-    debug_printf("r300: BEGIN_CS, count %d, in %s (%s:%d)\n", \
-        size, __FUNCTION__, __FILE__, __LINE__); \
+    if (VERY_VERBOSE_CS) { \
+        debug_printf("r300: BEGIN_CS, count %d, in %s (%s:%d)\n", \
+                size, __FUNCTION__, __FILE__, __LINE__); \
+    } \
     cs_winsys->begin_cs(cs_winsys, (size), \
             __FILE__, __FUNCTION__, __LINE__); \
     cs_count = size; \
@@ -93,8 +96,9 @@
 } while (0)
 
 #define OUT_CS_RELOC(bo, offset, rd, wd, flags) do { \
-    debug_printf("r300: writing relocation for buffer %p, offset %d\n", \
-        bo, offset); \
+    debug_printf("r300: writing relocation for buffer %p, offset %d, " \
+            "domains (%d, %d, %d)\n", \
+        bo, offset, rd, wd, flags); \
     assert(bo); \
     OUT_CS(offset); \
     cs_winsys->write_cs_reloc(cs_winsys, bo, rd, wd, flags); \
 } while (0)
 
 #define END_CS do { \
-    debug_printf("r300: END_CS in %s (%s:%d)\n", __FUNCTION__, __FILE__, \
-        __LINE__); \
+    if (VERY_VERBOSE_CS) { \
+        debug_printf("r300: END_CS in %s (%s:%d)\n", __FUNCTION__, \
+                __FILE__, __LINE__); \
+    } \
     if (cs_count != 0) \
         debug_printf("r300: Warning: cs_count off by %d\n", cs_count); \
     cs_winsys->end_cs(cs_winsys, __FILE__, __FUNCTION__, __LINE__); \
 } while (0)
 
 #define FLUSH_CS do { \
-    debug_printf("r300: FLUSH_CS in %s (%s:%d)\n\n", __FUNCTION__, __FILE__, \
-        __LINE__); \
+    if (VERY_VERBOSE_CS) { \
+        debug_printf("r300: FLUSH_CS in %s (%s:%d)\n\n", __FUNCTION__, \
+                __FILE__, __LINE__); \
+    } \
     cs_winsys->flush_cs(cs_winsys); \
 } while (0)
 
index dd63136c9d62eb4f1b5ed6613e66950bcf3e53c8..678cd2b81210dbae439b4332c794a8080af5f706 100644 (file)
@@ -30,81 +30,6 @@ static void r300_dump_fs(struct r300_fragment_shader* fs)
     }
 }
 
-static char* r500_fs_swiz[] = {
-    " R",
-    " G",
-    " B",
-    " A",
-    " 0",
-    ".5",
-    " 1",
-    " U",
-};
-
-static char* r500_fs_op_rgb[] = {
-    "MAD",
-    "DP3",
-    "DP4",
-    "D2A",
-    "MIN",
-    "MAX",
-    "---",
-    "CND",
-    "CMP",
-    "FRC",
-    "SOP",
-    "MDH",
-    "MDV",
-};
-
-static char* r500_fs_op_alpha[] = {
-    "MAD",
-    " DP",
-    "MIN",
-    "MAX",
-    "---",
-    "CND",
-    "CMP",
-    "FRC",
-    "EX2",
-    "LN2",
-    "RCP",
-    "RSQ",
-    "SIN",
-    "COS",
-    "MDH",
-    "MDV",
-};
-
-static char* r500_fs_mask[] = {
-    "NONE",
-    "R   ",
-    " G  ",
-    "RG  ",
-    "  B ",
-    "R B ",
-    " GB ",
-    "RGB ",
-    "   A",
-    "R  A",
-    " G A",
-    "RG A",
-    "  BA",
-    "R BA",
-    " GBA",
-    "RGBA",
-};
-
-static char* r500_fs_tex[] = {
-    "    NOP",
-    "     LD",
-    "TEXKILL",
-    "   PROJ",
-    "LODBIAS",
-    "    LOD",
-    "   DXDY",
-};
-
 void r500_fs_dump(struct r500_fragment_shader* fs)
 {
     int i;
@@ -225,14 +150,49 @@ void r500_fs_dump(struct r500_fragment_shader* fs)
     }
 }
 
+static void r300_vs_op_dump(uint32_t op)
+{
+    debug_printf(" dst: %d%s op: ",
+            (op >> 13) & 0x7f, r300_vs_dst_debug[(op >> 8) & 0x7]);
+    if (op & 0x80) {
+        if (op & 0x1) {
+            debug_printf("PVS_MACRO_OP_2CLK_M2X_ADD\n");
+        } else {
+            debug_printf("   PVS_MACRO_OP_2CLK_MADD\n");
+        }
+    } else if (op & 0x40) {
+        debug_printf("%s\n", r300_vs_me_ops[op & 0x1f]);
+    } else {
+        debug_printf("%s\n", r300_vs_ve_ops[op & 0x1f]);
+    }
+}
+
+void r300_vs_src_dump(uint32_t src)
+{
+    debug_printf(" reg: %d%s swiz: %s%s/%s%s/%s%s/%s%s\n",
+            (src >> 5) & 0x7f, r300_vs_src_debug[src & 0x3],
+            src & (1 << 25) ? "-" : " ",
+            r300_vs_swiz_debug[(src >> 13) & 0x7],
+            src & (1 << 26) ? "-" : " ",
+            r300_vs_swiz_debug[(src >> 16) & 0x7],
+            src & (1 << 27) ? "-" : " ",
+            r300_vs_swiz_debug[(src >> 19) & 0x7],
+            src & (1 << 28) ? "-" : " ",
+            r300_vs_swiz_debug[(src >> 22) & 0x7]);
+}
+
 void r300_vs_dump(struct r300_vertex_shader* vs)
 {
     int i;
 
     for (i = 0; i < vs->instruction_count; i++) {
-        debug_printf("inst0: 0x%x\n", vs->instructions[i].inst0);
-        debug_printf("inst1: 0x%x\n", vs->instructions[i].inst1);
-        debug_printf("inst2: 0x%x\n", vs->instructions[i].inst2);
-        debug_printf("inst3: 0x%x\n", vs->instructions[i].inst3);
+        debug_printf("%d: op: 0x%08x", i, vs->instructions[i].inst0);
+        r300_vs_op_dump(vs->instructions[i].inst0);
+        debug_printf(" src0: 0x%08x", vs->instructions[i].inst1);
+        r300_vs_src_dump(vs->instructions[i].inst1);
+        debug_printf(" src1: 0x%08x", vs->instructions[i].inst2);
+        r300_vs_src_dump(vs->instructions[i].inst2);
+        debug_printf(" src2: 0x%08x", vs->instructions[i].inst3);
+        r300_vs_src_dump(vs->instructions[i].inst3);
     }
 }
index a1f873656dcab1c0411639c4cad62f86964261d7..c86410ec0a964cb2bc69f90e9b20cedeb1ae4e67 100644 (file)
 #include "r300_state_shader.h"
 #include "r300_state_tcl.h"
 
+static char* r500_fs_swiz[] = {
+    " R",
+    " G",
+    " B",
+    " A",
+    " 0",
+    ".5",
+    " 1",
+    " U",
+};
+
+static char* r500_fs_op_rgb[] = {
+    "MAD",
+    "DP3",
+    "DP4",
+    "D2A",
+    "MIN",
+    "MAX",
+    "---",
+    "CND",
+    "CMP",
+    "FRC",
+    "SOP",
+    "MDH",
+    "MDV",
+};
+
+static char* r500_fs_op_alpha[] = {
+    "MAD",
+    " DP",
+    "MIN",
+    "MAX",
+    "---",
+    "CND",
+    "CMP",
+    "FRC",
+    "EX2",
+    "LN2",
+    "RCP",
+    "RSQ",
+    "SIN",
+    "COS",
+    "MDH",
+    "MDV",
+};
+
+static char* r500_fs_mask[] = {
+    "NONE",
+    "R   ",
+    " G  ",
+    "RG  ",
+    "  B ",
+    "R B ",
+    " GB ",
+    "RGB ",
+    "   A",
+    "R  A",
+    " G A",
+    "RG A",
+    "  BA",
+    "R BA",
+    " GBA",
+    "RGBA",
+};
+
+static char* r500_fs_tex[] = {
+    "    NOP",
+    "     LD",
+    "TEXKILL",
+    "   PROJ",
+    "LODBIAS",
+    "    LOD",
+    "   DXDY",
+};
+
+static char* r300_vs_ve_ops[] = {
+    /* R300 vector ops */
+    "                 VE_NO_OP",
+    "           VE_DOT_PRODUCT",
+    "              VE_MULTIPLY",
+    "                   VE_ADD",
+    "          VE_MULTIPLY_ADD",
+    "       VE_DISTANCE_FACTOR",
+    "              VE_FRACTION",
+    "               VE_MAXIMUM",
+    "               VE_MINIMUM",
+    "VE_SET_GREATER_THAN_EQUAL",
+    "         VE_SET_LESS_THAN",
+    "        VE_MULTIPLYX2_ADD",
+    "        VE_MULTIPLY_CLAMP",
+    "            VE_FLT2FIX_DX",
+    "        VE_FLT2FIX_DX_RND",
+    /* R500 vector ops */
+    "      VE_PRED_SET_EQ_PUSH",
+    "      VE_PRED_SET_GT_PUSH",
+    "     VE_PRED_SET_GTE_PUSH",
+    "     VE_PRED_SET_NEQ_PUSH",
+    "         VE_COND_WRITE_EQ",
+    "         VE_COND_WRITE_GT",
+    "        VE_COND_WRITE_GTE",
+    "        VE_COND_WRITE_NEQ",
+    "      VE_SET_GREATER_THAN",
+    "             VE_SET_EQUAL",
+    "         VE_SET_NOT_EQUAL",
+    "               (reserved)",
+    "               (reserved)",
+    "               (reserved)",
+};
+
+static char* r300_vs_me_ops[] = {
+    /* R300 math ops */
+    "                 ME_NO_OP",
+    "          ME_EXP_BASE2_DX",
+    "          ME_LOG_BASE2_DX",
+    "          ME_EXP_BASEE_FF",
+    "        ME_LIGHT_COEFF_DX",
+    "         ME_POWER_FUNC_FF",
+    "              ME_RECIP_DX",
+    "              ME_RECIP_FF",
+    "         ME_RECIP_SQRT_DX",
+    "         ME_RECIP_SQRT_FF",
+    "              ME_MULTIPLY",
+    "     ME_EXP_BASE2_FULL_DX",
+    "     ME_LOG_BASE2_FULL_DX",
+    " ME_POWER_FUNC_FF_CLAMP_B",
+    "ME_POWER_FUNC_FF_CLAMP_B1",
+    "ME_POWER_FUNC_FF_CLAMP_01",
+    "                   ME_SIN",
+    "                   ME_COS",
+    /* R500 math ops */
+    "        ME_LOG_BASE2_IEEE",
+    "            ME_RECIP_IEEE",
+    "       ME_RECIP_SQRT_IEEE",
+    "           ME_PRED_SET_EQ",
+    "           ME_PRED_SET_GT",
+    "          ME_PRED_SET_GTE",
+    "          ME_PRED_SET_NEQ",
+    "          ME_PRED_SET_CLR",
+    "          ME_PRED_SET_INV",
+    "          ME_PRED_SET_POP",
+    "      ME_PRED_SET_RESTORE",
+    "               (reserved)",
+    "               (reserved)",
+    "               (reserved)",
+};
+
+/* XXX refactor to avoid clashing symbols */
+static char* r300_vs_src_debug[] = {
+    "t",
+    "i",
+    "c",
+    "a",
+};
+
+static char* r300_vs_dst_debug[] = {
+    "t",
+    "a0",
+    "o",
+    "ox",
+    "a",
+    "i",
+    "u",
+    "u",
+};
+
+static char* r300_vs_swiz_debug[] = {
+    "X",
+    "Y",
+    "Z",
+    "W",
+    "0",
+    "1",
+    "U",
+    "U",
+};
+
 void r500_fs_dump(struct r500_fragment_shader* fs);
 
 void r300_vs_dump(struct r300_vertex_shader* vs);
index 01bac5f759cb1c635cf02a5308ff5766b635bca8..93cf6909a33a824dd07774a6892525074f230422 100644 (file)
@@ -56,6 +56,36 @@ void r300_emit_blend_color_state(struct r300_context* r300,
     }
 }
 
+void r300_emit_clip_state(struct r300_context* r300,
+                          struct pipe_clip_state* clip)
+{
+    int i;
+    struct r300_screen* r300screen = r300_screen(r300->context.screen);
+    CS_LOCALS(r300);
+
+    if (r300screen->caps->has_tcl) {
+        BEGIN_CS(5 + (6 * 4));
+        OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG,
+                (r300screen->caps->is_r500 ?
+                 R500_PVS_UCP_START : R300_PVS_UCP_START));
+        OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, 6 * 4);
+        for (i = 0; i < 6; i++) {
+            OUT_CS_32F(clip->ucp[i][0]);
+            OUT_CS_32F(clip->ucp[i][1]);
+            OUT_CS_32F(clip->ucp[i][2]);
+            OUT_CS_32F(clip->ucp[i][3]);
+        }
+        OUT_CS_REG(R300_VAP_CLIP_CNTL, ((1 << clip->nr) - 1) |
+                R300_PS_UCP_MODE_CLIP_AS_TRIFAN);
+        END_CS;
+    } else {
+        BEGIN_CS(2);
+        OUT_CS_REG(R300_VAP_CLIP_CNTL, R300_CLIP_DISABLE);
+        END_CS;
+    }
+
+}
+
 void r300_emit_dsa_state(struct r300_context* r300,
                            struct r300_dsa_state* dsa)
 {
@@ -163,6 +193,7 @@ void r300_emit_fb_state(struct r300_context* r300,
     BEGIN_CS((8 * fb->nr_cbufs) + (fb->zsbuf ? 8 : 0) + 4);
     for (i = 0; i < fb->nr_cbufs; i++) {
         tex = (struct r300_texture*)fb->cbufs[i]->texture;
+        assert(tex && tex->buffer && "cbuf is marked, but NULL!");
         pixpitch = tex->stride / tex->tex.block.size;
 
         OUT_CS_REG_SEQ(R300_RB3D_COLOROFFSET0 + (4 * i), 1);
@@ -177,7 +208,8 @@ void r300_emit_fb_state(struct r300_context* r300,
 
     if (fb->zsbuf) {
         tex = (struct r300_texture*)fb->zsbuf->texture;
-        pixpitch = (tex->stride / tex->tex.block.size);
+        assert(tex && tex->buffer && "zsbuf is marked, but NULL!");
+        pixpitch = tex->stride / tex->tex.block.size;
 
         OUT_CS_REG_SEQ(R300_ZB_DEPTHOFFSET, 1);
         OUT_CS_RELOC(tex->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
@@ -234,7 +266,7 @@ void r300_emit_rs_block_state(struct r300_context* r300,
     }
     for (i = 0; i < 8; i++) {
         OUT_CS(rs->ip[i]);
-        debug_printf("ip %d: 0x%08x\n", i, rs->ip[i]);
+        /* debug_printf("ip %d: 0x%08x\n", i, rs->ip[i]); */
     }
 
     OUT_CS_REG_SEQ(R300_RS_COUNT, 2);
@@ -248,11 +280,11 @@ void r300_emit_rs_block_state(struct r300_context* r300,
     }
     for (i = 0; i < 8; i++) {
         OUT_CS(rs->inst[i]);
-        debug_printf("inst %d: 0x%08x\n", i, rs->inst[i]);
+        /* debug_printf("inst %d: 0x%08x\n", i, rs->inst[i]); */
     }
 
-    debug_printf("count: 0x%08x inst_count: 0x%08x\n", rs->count,
-            rs->inst_count);
+    /* debug_printf("count: 0x%08x inst_count: 0x%08x\n", rs->count,
+     *        rs->inst_count); */
 
     END_CS;
 }
@@ -296,6 +328,30 @@ void r300_emit_texture(struct r300_context* r300,
     END_CS;
 }
 
+void r300_emit_vertex_buffer(struct r300_context* r300)
+{
+    CS_LOCALS(r300);
+
+    debug_printf("r300: Preparing vertex buffer %p for render, "
+            "vertex size %d\n", r300->vbo,
+            r300->vertex_info.vinfo.size);
+    /* Set the pointer to our vertex buffer. The emitted values are this:
+     * PACKET3 [3D_LOAD_VBPNTR]
+     * COUNT   [1]
+     * FORMAT  [size | stride << 8]
+     * OFFSET  [offset into BO]
+     * VBPNTR  [relocated BO]
+     */
+    BEGIN_CS(7);
+    OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR, 3);
+    OUT_CS(1);
+    OUT_CS(r300->vertex_info.vinfo.size |
+            (r300->vertex_info.vinfo.size << 8));
+    OUT_CS(r300->vbo_offset);
+    OUT_CS_RELOC(r300->vbo, 0, RADEON_GEM_DOMAIN_GTT, 0, 0);
+    END_CS;
+}
+
 void r300_emit_vertex_format_state(struct r300_context* r300)
 {
     int i;
@@ -310,22 +366,22 @@ void r300_emit_vertex_format_state(struct r300_context* r300)
     OUT_CS_REG_SEQ(R300_VAP_OUTPUT_VTX_FMT_0, 2);
     OUT_CS(r300->vertex_info.vinfo.hwfmt[2]);
     OUT_CS(r300->vertex_info.vinfo.hwfmt[3]);
-    for (i = 0; i < 4; i++) {
-        debug_printf("hwfmt%d: 0x%08x\n", i,
-                r300->vertex_info.vinfo.hwfmt[i]);
-    }
+    /* for (i = 0; i < 4; i++) {
+        debug_printf("hwfmt%d: 0x%08x\n", i,
+                r300->vertex_info.vinfo.hwfmt[i]);
+     * } */
 
     OUT_CS_REG_SEQ(R300_VAP_PROG_STREAM_CNTL_0, 8);
     for (i = 0; i < 8; i++) {
         OUT_CS(r300->vertex_info.vap_prog_stream_cntl[i]);
-        debug_printf("prog_stream_cntl%d: 0x%08x\n", i,
-                r300->vertex_info.vap_prog_stream_cntl[i]);
+        /* debug_printf("prog_stream_cntl%d: 0x%08x\n", i,
+         *        r300->vertex_info.vap_prog_stream_cntl[i]); */
     }
     OUT_CS_REG_SEQ(R300_VAP_PROG_STREAM_CNTL_EXT_0, 8);
     for (i = 0; i < 8; i++) {
         OUT_CS(r300->vertex_info.vap_prog_stream_cntl_ext[i]);
-        debug_printf("prog_stream_cntl_ext%d: 0x%08x\n", i,
-                r300->vertex_info.vap_prog_stream_cntl_ext[i]);
+        /* debug_printf("prog_stream_cntl_ext%d: 0x%08x\n", i,
+         *        r300->vertex_info.vap_prog_stream_cntl_ext[i]); */
     }
     END_CS;
 }
@@ -346,17 +402,22 @@ void r300_emit_vertex_shader(struct r300_context* r300,
     }
 
     if (constants->count) {
-        BEGIN_CS(16 + (vs->instruction_count * 4) + (constants->count * 4));
+        BEGIN_CS(14 + (vs->instruction_count * 4) + (constants->count * 4));
     } else {
-        BEGIN_CS(13 + (vs->instruction_count * 4) + (constants->count * 4));
+        BEGIN_CS(11 + (vs->instruction_count * 4));
     }
 
-    OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_0, R300_PVS_FIRST_INST(0) |
+    /* R300_VAP_PVS_CODE_CNTL_0
+     * R300_VAP_PVS_CONST_CNTL
+     * R300_VAP_PVS_CODE_CNTL_1
+     * See the r5xx docs for instructions on how to use these.
+     * XXX these could be optimized to select better values... */
+    OUT_CS_REG_SEQ(R300_VAP_PVS_CODE_CNTL_0, 3);
+    OUT_CS(R300_PVS_FIRST_INST(0) |
+            R300_PVS_XYZW_VALID_INST(vs->instruction_count - 1) |
             R300_PVS_LAST_INST(vs->instruction_count - 1));
-    OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_1, vs->instruction_count - 1);
-
-    /* XXX */
-    OUT_CS_REG(R300_VAP_PVS_CONST_CNTL, 0x0);
+    OUT_CS(R300_PVS_MAX_CONST_ADDR(constants->count - 1));
+    OUT_CS(vs->instruction_count - 1);
 
     OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG, 0);
     OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, vs->instruction_count * 4);
@@ -386,7 +447,6 @@ void r300_emit_vertex_shader(struct r300_context* r300,
             R300_PVS_VF_MAX_VTX_NUM(12));
     OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0);
     END_CS;
-
 }
 
 void r300_emit_viewport_state(struct r300_context* r300,
@@ -403,7 +463,11 @@ void r300_emit_viewport_state(struct r300_context* r300,
     OUT_CS_32F(viewport->zscale);
     OUT_CS_32F(viewport->zoffset);
 
-    OUT_CS_REG(R300_VAP_VTE_CNTL, viewport->vte_control);
+    if (r300->rs_state->enable_vte) {
+        OUT_CS_REG(R300_VAP_VTE_CNTL, viewport->vte_control);
+    } else {
+        OUT_CS_REG(R300_VAP_VTE_CNTL, 0);
+    }
     END_CS;
 }
 
@@ -421,23 +485,66 @@ void r300_flush_textures(struct r300_context* r300)
 void r300_emit_dirty_state(struct r300_context* r300)
 {
     struct r300_screen* r300screen = r300_screen(r300->context.screen);
-    int i;
-    int dirty_tex = 0;
+    struct r300_texture* tex;
+    int i, dirty_tex = 0;
+    boolean invalid = FALSE;
 
-    if (!(r300->dirty_hw)) {
+    if (!(r300->dirty_state)) {
         return;
     }
 
     r300_update_derived_state(r300);
 
     /* XXX check size */
-    struct r300_texture* fb_tex =
-        (struct r300_texture*)r300->framebuffer_state.cbufs[0];
-    r300->winsys->add_buffer(r300->winsys, fb_tex->buffer,
-            0, RADEON_GEM_DOMAIN_VRAM);
+validate:
+    /* Color buffers... */
+    for (i = 0; i < r300->framebuffer_state.nr_cbufs; i++) {
+        tex = (struct r300_texture*)r300->framebuffer_state.cbufs[i]->texture;
+        assert(tex && tex->buffer && "cbuf is marked, but NULL!");
+        if (!r300->winsys->add_buffer(r300->winsys, tex->buffer,
+                    0, RADEON_GEM_DOMAIN_VRAM)) {
+            r300->context.flush(&r300->context, 0, NULL);
+            goto validate;
+        }
+    }
+    /* ...depth buffer... */
+    if (r300->framebuffer_state.zsbuf) {
+        tex = (struct r300_texture*)r300->framebuffer_state.zsbuf->texture;
+        assert(tex && tex->buffer && "zsbuf is marked, but NULL!");
+        if (!r300->winsys->add_buffer(r300->winsys, tex->buffer,
+                    0, RADEON_GEM_DOMAIN_VRAM)) {
+            r300->context.flush(&r300->context, 0, NULL);
+            goto validate;
+        }
+    }
+    /* ...textures... */
+    for (i = 0; i < r300->texture_count; i++) {
+        tex = r300->textures[i];
+        assert(tex && tex->buffer && "texture is marked, but NULL!");
+        if (!r300->winsys->add_buffer(r300->winsys, tex->buffer,
+                    RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0)) {
+            r300->context.flush(&r300->context, 0, NULL);
+            goto validate;
+        }
+    }
+    /* ...and vertex buffer. */
+    if (r300->vbo) {
+        if (!r300->winsys->add_buffer(r300->winsys, r300->vbo,
+                    RADEON_GEM_DOMAIN_GTT, 0)) {
+            r300->context.flush(&r300->context, 0, NULL);
+            goto validate;
+        }
+    } else {
+        debug_printf("No VBO while emitting dirty state!\n");
+    }
     if (r300->winsys->validate(r300->winsys)) {
-        /* XXX */
         r300->context.flush(&r300->context, 0, NULL);
+        if (invalid) {
+            /* Well, hell. */
+            exit(1);
+        }
+        invalid = TRUE;
+        goto validate;
     }
 
     if (r300->dirty_state & R300_NEW_BLEND) {
@@ -450,6 +557,11 @@ void r300_emit_dirty_state(struct r300_context* r300)
         r300->dirty_state &= ~R300_NEW_BLEND_COLOR;
     }
 
+    if (r300->dirty_state & R300_NEW_CLIP) {
+        r300_emit_clip_state(r300, &r300->clip_state);
+        r300->dirty_state &= ~R300_NEW_CLIP;
+    }
+
     if (r300->dirty_state & R300_NEW_DSA) {
         r300_emit_dsa_state(r300, r300->dsa_state);
         r300->dirty_state &= ~R300_NEW_DSA;
@@ -519,4 +631,14 @@ void r300_emit_dirty_state(struct r300_context* r300)
         r300_emit_vertex_format_state(r300);
         r300->dirty_state &= ~R300_NEW_VERTEX_FORMAT;
     }
+
+    if (r300->dirty_state & R300_NEW_VERTEX_SHADER) {
+        r300_emit_vertex_shader(r300, r300->vs);
+        r300->dirty_state &= ~R300_NEW_VERTEX_SHADER;
+    }
+
+    /* Finally, emit the VBO. */
+    r300_emit_vertex_buffer(r300);
+
+    r300->dirty_hw++;
 }
index 31dbc7ab8531315029a299aa5f46f598ab34f50c..946f625bd89df5da5ce011f7eb31e1788fdd56e9 100644 (file)
@@ -36,6 +36,9 @@ void r300_emit_blend_state(struct r300_context* r300,
 void r300_emit_blend_color_state(struct r300_context* r300,
                                  struct r300_blend_color_state* bc);
 
+void r300_emit_clip_state(struct r300_context* r300,
+                          struct pipe_clip_state* clip);
+
 void r300_emit_dsa_state(struct r300_context* r300,
                          struct r300_dsa_state* dsa);
 
@@ -62,6 +65,8 @@ void r300_emit_scissor_state(struct r300_context* r300,
 void r300_emit_texture(struct r300_context* r300,
                        struct r300_texture* tex, unsigned offset);
 
+void r300_emit_vertex_buffer(struct r300_context* r300);
+
 void r300_emit_vertex_format_state(struct r300_context* r300);
 
 void r300_emit_vertex_shader(struct r300_context* r300,
index 660816e1da158e8139c20e3ba58a9c60370ac69a..3bb9bc47b50c4a1cd6c34d476fdb98938b9b1333 100644 (file)
@@ -511,11 +511,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #       define R300_PVS_XYZW_VALID_INST_SHIFT    10
 #       define R300_PVS_LAST_INST_SHIFT          20
 #       define R300_PVS_FIRST_INST(x)            ((x) << 0)
+#       define R300_PVS_XYZW_VALID_INST(x)       ((x) << 10)
 #       define R300_PVS_LAST_INST(x)             ((x) << 20)
 /* Addresses are relative the the vertex program parameters area. */
 #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_PVS_MAX_CONST_ADDR(x)        ((x) << 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
@@ -3040,6 +3042,7 @@ enum {
 #   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_RGB_WMASK_RGB                     (7 << 11)
 #   define R500_INST_ALPHA_WMASK                       (1 << 14)
 #   define R500_INST_RGB_OMASK_R                       (1 << 15)
 #   define R500_INST_RGB_OMASK_G                       (1 << 16)
index cbd84d7c569d9fe9b3a04d82e6040b2c8aa079da..cd458d019ae93e5572fced0b3ff42311ef9aee8c 100644 (file)
@@ -45,11 +45,7 @@ struct r300_render {
 
     /* VBO */
     struct pipe_buffer* vbo;
-    size_t vbo_size;
-    size_t vbo_offset;
-    void* vbo_map;
     size_t vbo_alloc_size;
-    size_t vbo_max_used;
 };
 
 static INLINE struct r300_render*
@@ -78,24 +74,21 @@ static boolean r300_render_allocate_vertices(struct vbuf_render* render,
     struct pipe_screen* screen = r300->context.screen;
     size_t size = (size_t)vertex_size * (size_t)count;
 
-    if (r300render->vbo) {
+    if (r300render->vbo && (size > r300render->vbo_alloc_size)) {
         pipe_buffer_reference(&r300render->vbo, NULL);
     }
+    
+    if (!r300render->vbo) {
+        r300render->vbo = pipe_buffer_create(screen,
+                                             64,
+                                             PIPE_BUFFER_USAGE_VERTEX,
+                                             size);
+    }
 
-    r300render->vbo_size = MAX2(size, r300render->vbo_alloc_size);
-    r300render->vbo_offset = 0;
-    r300render->vbo = pipe_buffer_create(screen,
-                                         64,
-                                         PIPE_BUFFER_USAGE_VERTEX,
-                                         r300render->vbo_size);
-
+    r300render->vbo_alloc_size = MAX2(size, r300render->vbo_alloc_size);
     r300render->vertex_size = vertex_size;
 
-    if (r300render->vbo) {
-        return TRUE;
-    } else {
-        return FALSE;
-    }
+    return (r300render->vbo) ? TRUE : FALSE;
 }
 
 static void* r300_render_map_vertices(struct vbuf_render* render)
@@ -103,10 +96,8 @@ static void* r300_render_map_vertices(struct vbuf_render* render)
     struct r300_render* r300render = r300_render(render);
     struct pipe_screen* screen = r300render->r300->context.screen;
 
-    r300render->vbo_map = pipe_buffer_map(screen, r300render->vbo,
-                                          PIPE_BUFFER_USAGE_CPU_WRITE);
-
-    return (unsigned char*)r300render->vbo_map + r300render->vbo_offset;
+    return (unsigned char*)pipe_buffer_map(screen, r300render->vbo,
+                                           PIPE_BUFFER_USAGE_CPU_WRITE);
 }
 
 static void r300_render_unmap_vertices(struct vbuf_render* render,
@@ -116,9 +107,6 @@ static void r300_render_unmap_vertices(struct vbuf_render* render,
     struct r300_render* r300render = r300_render(render);
     struct pipe_screen* screen = r300render->r300->context.screen;
 
-    r300render->vbo_max_used = MAX2(r300render->vbo_max_used,
-             r300render->vertex_size * (max + 1));
-
     pipe_buffer_unmap(screen, r300render->vbo);
 }
 
@@ -180,27 +168,9 @@ static void prepare_render(struct r300_render* render, unsigned count)
 
     CS_LOCALS(r300);
 
-    /* Make sure that all possible state is emitted. */
-    r300_emit_dirty_state(r300);
+    r300->vbo = render->vbo;
 
-    debug_printf("r300: Preparing vertex buffer %p for render, "
-            "vertex size %d, vertex count %d\n", render->vbo,
-            r300->vertex_info.vinfo.size, count);
-    /* Set the pointer to our vertex buffer. The emitted values are this:
-     * PACKET3 [3D_LOAD_VBPNTR]
-     * COUNT   [1]
-     * FORMAT  [size | stride << 8]
-     * OFFSET  [0]
-     * VBPNTR  [relocated BO]
-     */
-    BEGIN_CS(7);
-    OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR, 3);
-    OUT_CS(1);
-    OUT_CS(r300->vertex_info.vinfo.size |
-            (r300->vertex_info.vinfo.size << 8));
-    OUT_CS(render->vbo_offset);
-    OUT_CS_RELOC(render->vbo, 0, RADEON_GEM_DOMAIN_GTT, 0, 0);
-    END_CS;
+    r300_emit_dirty_state(r300);
 }
 
 static void r300_render_draw_arrays(struct vbuf_render* render,
@@ -212,8 +182,6 @@ static void r300_render_draw_arrays(struct vbuf_render* render,
 
     CS_LOCALS(r300);
 
-    r300render->vbo_offset = start;
-
     prepare_render(r300render, count);
 
     debug_printf("r300: Doing vbuf render, count %d\n", count);
@@ -248,13 +216,14 @@ static void r300_render_draw(struct vbuf_render* render,
         return;
     }
 
+/*
     index_map = pipe_buffer_map(screen, index_buffer,
                                 PIPE_BUFFER_USAGE_CPU_WRITE);
     memcpy(index_map, indices, count);
     pipe_buffer_unmap(screen, index_buffer);
 
     debug_printf("r300: Doing indexbuf render, count %d\n", count);
-/*
+
     BEGIN_CS(8);
     OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, 0);
     OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) |
@@ -264,13 +233,15 @@ static void r300_render_draw(struct vbuf_render* render,
     OUT_CS_INDEX_RELOC(index_buffer, 0, count, RADEON_GEM_DOMAIN_GTT, 0, 0);
     END_CS; */
 
-    BEGIN_CS(2 + count);
-    OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, count);
+    BEGIN_CS(2 + (count+1)/2);
+    OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, (count+1)/2);
     OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) |
-           r300render->hwprim | R300_VAP_VF_CNTL__INDEX_SIZE_32bit);
-    for (i = 0; i < count; i++) {
-        index = indices[i];
-        OUT_CS(index);
+           r300render->hwprim);
+    for (i = 0; i < count-1; i += 2) {
+        OUT_CS(indices[i+1] << 16 | indices[i]);
+    }
+    if (count % 2) {
+        OUT_CS(indices[count-1]);
     }
     END_CS;
 }
index d2c5998c261783b21fa067ef556c786e7fc04ea8..a6f1efe3563ec73d97b64b08ed7512a6e61ef072 100644 (file)
@@ -87,23 +87,25 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)
             } else {
                 return 0;
             }
-            return 0;
         case PIPE_CAP_GLSL:
-            /* IN THEORY */
-            return 0;
+            if (r300screen->caps->is_r500) {
+                return 1;
+            } else {
+                return 0;
+            }
         case PIPE_CAP_S3TC:
             /* IN THEORY */
             return 0;
         case PIPE_CAP_ANISOTROPIC_FILTER:
-            /* IN THEORY */
-            return 0;
+            return 1;
         case PIPE_CAP_POINT_SPRITE:
             /* IN THEORY */
             return 0;
         case PIPE_CAP_MAX_RENDER_TARGETS:
             return 4;
         case PIPE_CAP_OCCLUSION_QUERY:
-            return 1;
+            /* IN THEORY */
+            return 0;
         case PIPE_CAP_TEXTURE_SHADOW_MAP:
             /* IN THEORY */
             return 0;
@@ -152,17 +154,20 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)
 
 static float r300_get_paramf(struct pipe_screen* pscreen, int param)
 {
+    struct r300_screen* r300screen = r300_screen(pscreen);
+
     switch (param) {
         case PIPE_CAP_MAX_LINE_WIDTH:
         case PIPE_CAP_MAX_LINE_WIDTH_AA:
-            /* XXX this is the biggest thing that will fit in that register.
-            * Perhaps the actual rendering limits are less? */
-            return 10922.0f;
         case PIPE_CAP_MAX_POINT_WIDTH:
         case PIPE_CAP_MAX_POINT_WIDTH_AA:
-            /* XXX this is the biggest thing that will fit in that register.
-             * Perhaps the actual rendering limits are less? */
-            return 10922.0f;
+            /* The maximum dimensions of the colorbuffer are our practical
+             * rendering limits. 2048 pixels should be enough for anybody. */
+            if (r300screen->caps->is_r500) {
+                return 4096.0f;
+            } else {
+                return 2048.0f;
+            }
         case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
             return 16.0f;
         case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
@@ -230,9 +235,16 @@ static boolean r300_is_format_supported(struct pipe_screen* pscreen,
         case PIPE_TEXTURE_2D:
             return check_tex_2d_format(format,
                 r300_screen(pscreen)->caps->is_r500);
+        case PIPE_TEXTURE_1D:
+        case PIPE_TEXTURE_3D:
+        case PIPE_TEXTURE_CUBE:
+            debug_printf("r300: Implementation error: Unsupported format "
+                    "target: %d\n", target);
+            break;
         default:
-            debug_printf("r300: Warning: Got unknown format target: %d\n",
-                format);
+            debug_printf("r300: Fatal: This is not a format target: %d\n",
+                target);
+            assert(0);
             break;
     }
 
@@ -337,7 +349,6 @@ struct pipe_screen* r300_create_screen(struct r300_winsys* r300_winsys)
         return NULL;
 
     caps->pci_id = r300_winsys->pci_id;
-    caps->num_frag_pipes = r300_winsys->gb_pipes;
 
     r300_parse_chipset(caps);
 
index 184a23c9e6878628e9a2efc0ab7cb35def037420..01e2b511534af1b20c2f10408afd22a4f55b0d1f 100644 (file)
@@ -62,8 +62,6 @@ static void* r300_create_blend_state(struct pipe_context* pipe,
     }
 
     /* PIPE_LOGICOP_* don't need to be translated, fortunately. */
-    /* XXX are logicops still allowed if blending's disabled?
-     * Does Gallium take care of it for us? */
     if (state->logicop_enable) {
         blend->rop = R300_RB3D_ROPCNTL_ROP_ENABLE |
                 (state->logicop_func) << R300_RB3D_ROPCNTL_ROP_SHIFT;
@@ -121,9 +119,14 @@ static void r300_set_clip_state(struct pipe_context* pipe,
                                 const struct pipe_clip_state* state)
 {
     struct r300_context* r300 = r300_context(pipe);
-    /* XXX Draw */
-    draw_flush(r300->draw);
-    draw_set_clip_state(r300->draw, state);
+
+    if (r300_screen(pipe->screen)->caps->has_tcl) {
+        r300->clip_state = *state;
+        r300->dirty_state |= R300_NEW_CLIP;
+    } else {
+        draw_flush(r300->draw);
+        draw_set_clip_state(r300->draw, state);
+    }
 }
 
 static void
@@ -153,10 +156,12 @@ static void
 
     /* If the number of constants have changed, invalidate the shader. */
     if (r300->shader_constants[shader].user_count != i) {
-        if (shader == PIPE_SHADER_FRAGMENT && r300->fs) {
+        if (shader == PIPE_SHADER_FRAGMENT && r300->fs &&
+                r300->fs->uses_imms) {
             r300->fs->translated = FALSE;
             r300_translate_fragment_shader(r300, r300->fs);
-        } else if (shader == PIPE_SHADER_VERTEX && r300->vs) {
+        } else if (shader == PIPE_SHADER_VERTEX && r300->vs &&
+                r300->vs->uses_imms) {
             r300->vs->translated = FALSE;
             r300_translate_vertex_shader(r300, r300->vs);
         }
@@ -257,6 +262,7 @@ static void r300_set_edgeflags(struct pipe_context* pipe,
                                const unsigned* bitfield)
 {
     /* XXX you know it's bad when i915 has this blank too */
+    /* XXX and even worse, I have no idea WTF the bitfield is */
 }
 
 static void
@@ -289,6 +295,7 @@ static void* r300_create_fs_state(struct pipe_context* pipe,
 
     /* Copy state directly into shader. */
     fs->state = *shader;
+    fs->state.tokens = tgsi_dup_tokens(shader->tokens);
 
     tgsi_scan_shader(shader->tokens, &fs->info);
 
@@ -317,13 +324,15 @@ static void r300_bind_fs_state(struct pipe_context* pipe, void* shader)
 /* Delete fragment shader state. */
 static void r300_delete_fs_state(struct pipe_context* pipe, void* shader)
 {
+    struct r3xx_fragment_shader* fs = (struct r3xx_fragment_shader*)shader;
+    FREE(fs->state.tokens);
     FREE(shader);
 }
 
 static void r300_set_polygon_stipple(struct pipe_context* pipe,
                                      const struct pipe_poly_stipple* state)
 {
-    /* XXX */
+    /* XXX no idea how to set this up, but not terribly important */
 }
 
 /* Create a new rasterizer state based on the CSO rasterizer state.
@@ -341,6 +350,8 @@ static void* r300_create_rs_state(struct pipe_context* pipe,
     /* Copy rasterizer state for Draw. */
     rs->rs = *state;
 
+    rs->enable_vte = !state->bypass_vs_clip_and_viewport;
+
     /* If bypassing TCL, or if no TCL engine is present, turn off the HW TCL.
      * Else, enable HW TCL and force Draw's TCL off. */
     if (state->bypass_vs_clip_and_viewport ||
@@ -555,40 +566,35 @@ static void r300_set_viewport_state(struct pipe_context* pipe,
 {
     struct r300_context* r300 = r300_context(pipe);
 
-    draw_flush(r300->draw);
-
-    if (r300_screen(r300->context.screen)->caps->has_tcl) {
-        /* Do the transform in HW. */
-        r300->viewport_state->vte_control = R300_VTX_W0_FMT;
+    /* Do the transform in HW. */
+    r300->viewport_state->vte_control = R300_VTX_W0_FMT;
 
-        if (state->scale[0] != 1.0f) {
-            r300->viewport_state->xscale = state->scale[0];
-            r300->viewport_state->vte_control |= R300_VPORT_X_SCALE_ENA;
-        }
-        if (state->scale[1] != 1.0f) {
-            r300->viewport_state->yscale = state->scale[1];
-            r300->viewport_state->vte_control |= R300_VPORT_Y_SCALE_ENA;
-        }
-        if (state->scale[2] != 1.0f) {
-            r300->viewport_state->zscale = state->scale[2];
-            r300->viewport_state->vte_control |= R300_VPORT_Z_SCALE_ENA;
-        }
-        if (state->translate[0] != 0.0f) {
-            r300->viewport_state->xoffset = state->translate[0];
-            r300->viewport_state->vte_control |= R300_VPORT_X_OFFSET_ENA;
-        }
-        if (state->translate[1] != 0.0f) {
-            r300->viewport_state->yoffset = state->translate[1];
-            r300->viewport_state->vte_control |= R300_VPORT_Y_OFFSET_ENA;
-        }
-        if (state->translate[2] != 0.0f) {
-            r300->viewport_state->zoffset = state->translate[2];
-            r300->viewport_state->vte_control |= R300_VPORT_Z_OFFSET_ENA;
-        }
-    } else {
-        r300->viewport_state->vte_control = 0;
-        /* Have Draw do the actual transform. */
-        draw_set_viewport_state(r300->draw, state);
+    if (state->scale[0] != 1.0f) {
+        assert(state->scale[0] != 0.0f);
+        r300->viewport_state->xscale = state->scale[0];
+        r300->viewport_state->vte_control |= R300_VPORT_X_SCALE_ENA;
+    }
+    if (state->scale[1] != 1.0f) {
+        assert(state->scale[1] != 0.0f);
+        r300->viewport_state->yscale = state->scale[1];
+        r300->viewport_state->vte_control |= R300_VPORT_Y_SCALE_ENA;
+    }
+    if (state->scale[2] != 1.0f) {
+        assert(state->scale[2] != 0.0f);
+        r300->viewport_state->zscale = state->scale[2];
+        r300->viewport_state->vte_control |= R300_VPORT_Z_SCALE_ENA;
+    }
+    if (state->translate[0] != 0.0f) {
+        r300->viewport_state->xoffset = state->translate[0];
+        r300->viewport_state->vte_control |= R300_VPORT_X_OFFSET_ENA;
+    }
+    if (state->translate[1] != 0.0f) {
+        r300->viewport_state->yoffset = state->translate[1];
+        r300->viewport_state->vte_control |= R300_VPORT_Y_OFFSET_ENA;
+    }
+    if (state->translate[2] != 0.0f) {
+        r300->viewport_state->zoffset = state->translate[2];
+        r300->viewport_state->vte_control |= R300_VPORT_Z_OFFSET_ENA;
     }
 
     r300->dirty_state |= R300_NEW_VIEWPORT;
@@ -628,6 +634,7 @@ static void* r300_create_vs_state(struct pipe_context* pipe,
         struct r300_vertex_shader* vs = CALLOC_STRUCT(r300_vertex_shader);
         /* Copy state directly into shader. */
         vs->state = *shader;
+        vs->state.tokens = tgsi_dup_tokens(shader->tokens);
 
         tgsi_scan_shader(shader->tokens, &vs->info);
 
@@ -673,6 +680,7 @@ static void r300_delete_vs_state(struct pipe_context* pipe, void* shader)
         struct r300_vertex_shader* vs = (struct r300_vertex_shader*)shader;
 
         draw_delete_vertex_shader(r300->draw, vs->draw);
+        FREE(vs->state.tokens);
         FREE(shader);
     } else {
         draw_delete_vertex_shader(r300->draw,
index c4c9784a00c1302eb7b256bb176edd6f50d931e8..2477b30822b81d07ddb2f6a4acfb9eb0cdaf9f1f 100644 (file)
@@ -64,6 +64,7 @@ static void r300_vs_tab_routes(struct r300_context* r300,
                     break;
                 case TGSI_SEMANTIC_FOG:
                     fog = TRUE;
+                    /* Fall through */
                 case TGSI_SEMANTIC_GENERIC:
                     texs++;
                     break;
@@ -103,6 +104,9 @@ static void r300_vs_tab_routes(struct r300_context* r300,
         }
     }
 
+    /* XXX magic */
+    assert(texs <= 8);
+
     /* Do the actual vertex_info setup.
      *
      * vertex_info has four uints of hardware-specific data in it.
@@ -140,21 +144,32 @@ static void r300_vs_tab_routes(struct r300_context* r300,
         vinfo->hwfmt[2] |= (R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT << i);
     }
 
-    for (i = 0; i < texs; i++) {
+    /* Init i right here, increment it if fog is enabled.
+     * This gets around a double-increment problem. */
+    i = 0;
+
+    if (fog) {
+        i++;
         draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE,
-            draw_find_vs_output(r300->draw, TGSI_SEMANTIC_GENERIC, i));
+            draw_find_vs_output(r300->draw, TGSI_SEMANTIC_FOG, 0));
         vinfo->hwfmt[1] |= (R300_INPUT_CNTL_TC0 << i);
         vinfo->hwfmt[3] |= (4 << (3 * i));
     }
 
-    if (fog) {
-        i++;
+    for (i; i < texs; i++) {
         draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE,
-            draw_find_vs_output(r300->draw, TGSI_SEMANTIC_FOG, 0));
+            draw_find_vs_output(r300->draw, TGSI_SEMANTIC_GENERIC, i));
         vinfo->hwfmt[1] |= (R300_INPUT_CNTL_TC0 << i);
         vinfo->hwfmt[3] |= (4 << (3 * i));
     }
 
+    /* Handle the case where the vertex shader will be generating some of
+     * the attribs based on its inputs. */
+    if (r300screen->caps->has_tcl &&
+            info->num_inputs < info->num_outputs) {
+        vinfo->num_attribs = info->num_inputs;
+    }
+
     draw_compute_vertex_size(vinfo);
 }
 
@@ -162,26 +177,40 @@ static void r300_vs_tab_routes(struct r300_context* r300,
 static void r300_vertex_psc(struct r300_context* r300,
                             struct r300_vertex_format* vformat)
 {
+    struct r300_screen* r300screen = r300_screen(r300->context.screen);
     struct vertex_info* vinfo = &vformat->vinfo;
     int* tab = vformat->vs_tab;
     uint32_t temp;
-    int i;
+    int i, attrib_count;
 
-    debug_printf("r300: attrib count: %d\n", vinfo->num_attribs);
-    for (i = 0; i < vinfo->num_attribs; i++) {
-        debug_printf("r300: attrib: offset %d, interp %d, size %d,"
-               " tab %d\n", vinfo->attrib[i].src_index,
-               vinfo->attrib[i].interp_mode, vinfo->attrib[i].emit,
-               tab[i]);
+    /* Vertex shaders have no semantics on their inputs,
+     * so PSC should just route stuff based on their info,
+     * and not on attrib information. */
+    if (r300screen->caps->has_tcl) {
+        attrib_count = r300->vs->info.num_inputs;
+        debug_printf("r300: routing %d attribs in psc for vs\n",
+                attrib_count);
+    } else {
+        attrib_count = vinfo->num_attribs;
+        debug_printf("r300: attrib count: %d\n", attrib_count);
+        for (i = 0; i < attrib_count; i++) {
+            debug_printf("r300: attrib: offset %d, interp %d, size %d,"
+                   " tab %d\n", vinfo->attrib[i].src_index,
+                   vinfo->attrib[i].interp_mode, vinfo->attrib[i].emit,
+                   tab[i]);
+        }
     }
 
-    for (i = 0; i < vinfo->num_attribs; i++) {
+    for (i = 0; i < attrib_count; i++) {
         /* Make sure we have a proper destination for our attribute */
         assert(tab[i] != -1);
 
         /* Add the attribute to the PSC table. */
-        temp = translate_vertex_data_type(vinfo->attrib[i].emit) |
-            (tab[i] << R300_DST_VEC_LOC_SHIFT);
+        temp = r300screen->caps->has_tcl ?
+            R300_DATA_TYPE_FLOAT_4 :
+            translate_vertex_data_type(vinfo->attrib[i].emit);
+        temp |= tab[i] << R300_DST_VEC_LOC_SHIFT;
+
         if (i & 1) {
             vformat->vap_prog_stream_cntl[i >> 1] &= 0x0000ffff;
             vformat->vap_prog_stream_cntl[i >> 1] |= temp << 16;
@@ -206,7 +235,6 @@ static void r300_vertex_psc(struct r300_context* r300,
 /* Update the vertex format. */
 static void r300_update_vertex_format(struct r300_context* r300)
 {
-    struct r300_screen* r300screen = r300_screen(r300->context.screen);
     struct r300_vertex_format vformat;
     int i;
 
index 91b93fc367eda2089431a89a9b964fe3e552b75b..22c8e199ae32399810cb098da4125a408373f75d 100644 (file)
@@ -353,25 +353,6 @@ static INLINE uint32_t r300_translate_out_fmt(enum pipe_format format)
 
 /* Non-CSO state. (For now.) */
 
-static INLINE uint32_t r300_translate_gb_pipes(int pipe_count)
-{
-    switch (pipe_count) {
-        case 1:
-            return R300_GB_TILE_PIPE_COUNT_RV300;
-            break;
-        case 2:
-            return R300_GB_TILE_PIPE_COUNT_R300;
-            break;
-        case 3:
-            return R300_GB_TILE_PIPE_COUNT_R420_3P;
-            break;
-        case 4:
-            return R300_GB_TILE_PIPE_COUNT_R420;
-            break;
-    }
-    return 0;
-}
-
 static INLINE uint32_t translate_vertex_data_type(int type) {
     switch (type) {
         case EMIT_1F:
index 8bd9b41bd74d12119dd95c0cf99b2311ec58308f..e438114010c784f8dd02b3f2e2f28ead745294e0 100644 (file)
@@ -34,36 +34,19 @@ void r300_emit_invariant_state(struct r300_context* r300)
     struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps;
     CS_LOCALS(r300);
 
-    BEGIN_CS(30 + (caps->has_tcl ? 2: 0));
+    BEGIN_CS(26 + (caps->has_tcl ? 2: 0));
 
     /*** Graphics Backend (GB) ***/
     /* Various GB enables */
     OUT_CS_REG(R300_GB_ENABLE, 0x0);
     /* Subpixel multisampling for AA */
     OUT_CS_REG(R300_GB_MSPOS0, 0x66666666);
-    OUT_CS_REG(R300_GB_MSPOS1, 0x66666666);
-    /* GB tile config and pipe setup */
-    OUT_CS_REG(R300_GB_TILE_CONFIG, R300_GB_TILE_DISABLE |
-        r300_translate_gb_pipes(caps->num_frag_pipes));
+    OUT_CS_REG(R300_GB_MSPOS1, 0x6666666);
     /* Source of fog depth */
     OUT_CS_REG(R300_GB_SELECT, R300_GB_FOG_SELECT_1_1_W);
     /* AA enable */
     OUT_CS_REG(R300_GB_AA_CONFIG, 0x0);
 
-    /*** Geometry Assembly (GA) ***/
-    /* GA errata fixes. */
-    if (caps->is_r500) {
-        OUT_CS_REG(R300_GA_ENHANCE,
-                R300_GA_ENHANCE_DEADLOCK_CNTL_PREVENT_TCL |
-                R300_GA_ENHANCE_FASTSYNC_CNTL_ENABLE |
-                R500_GA_ENHANCE_REG_READWRITE_ENABLE |
-                R500_GA_ENHANCE_REG_NOSTALL_ENABLE);
-    } else {
-        OUT_CS_REG(R300_GA_ENHANCE,
-                R300_GA_ENHANCE_DEADLOCK_CNTL_PREVENT_TCL |
-                R300_GA_ENHANCE_FASTSYNC_CNTL_ENABLE);
-    }
-
     /*** Fog (FG) ***/
     OUT_CS_REG(R300_FG_FOG_BLEND, 0x0);
     OUT_CS_REG(R300_FG_FOG_COLOR_R, 0x0);
@@ -86,7 +69,7 @@ void r300_emit_invariant_state(struct r300_context* r300)
     END_CS;
 
     /* XXX unsorted stuff from surface_fill */
-    BEGIN_CS(79 + (caps->has_tcl ? 7 : 0));
+    BEGIN_CS(77 + (caps->has_tcl ? 5 : 0));
     /* Flush PVS. */
     OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0);
 
@@ -97,8 +80,6 @@ void r300_emit_invariant_state(struct r300_context* r300)
     /* XXX endian */
     if (caps->has_tcl) {
         OUT_CS_REG(R300_VAP_CNTL_STATUS, R300_VC_NO_SWAP);
-        OUT_CS_REG(R300_VAP_CLIP_CNTL, R300_CLIP_DISABLE |
-            R300_PS_UCP_MODE_CLIP_AS_TRIFAN);
         OUT_CS_REG_SEQ(R300_VAP_GB_VERT_CLIP_ADJ, 4);
         OUT_CS_32F(1.0);
         OUT_CS_32F(1.0);
@@ -113,11 +94,14 @@ void r300_emit_invariant_state(struct r300_context* r300)
     OUT_CS_32F(0.0);
     OUT_CS_REG_SEQ(R300_GA_POINT_S1, 1);
     OUT_CS_32F(1.0);
+    /* XXX line tex stuffing */
+    OUT_CS_REG_SEQ(R300_GA_LINE_S0, 1);
+    OUT_CS_32F(0.0);
+    OUT_CS_REG_SEQ(R300_GA_LINE_S1, 1);
+    OUT_CS_32F(1.0);
     OUT_CS_REG(R300_GA_TRIANGLE_STIPPLE, 0x5 |
         (0x5 << R300_GA_TRIANGLE_STIPPLE_Y_SHIFT_SHIFT));
     /* XXX this big chunk should be refactored into rs_state */
-    OUT_CS_REG(R300_GA_LINE_S0, 0x00000000);
-    OUT_CS_REG(R300_GA_LINE_S1, 0x3F800000);
     OUT_CS_REG(R300_GA_SOLID_RG, 0x00000000);
     OUT_CS_REG(R300_GA_SOLID_BA, 0x00000000);
     OUT_CS_REG(R300_GA_POLY_MODE, 0x00000000);
@@ -144,8 +128,6 @@ void r300_emit_invariant_state(struct r300_context* r300)
     OUT_CS_REG(R300_VAP_VTX_STATE_CNTL, 0x1);
     OUT_CS_REG(R300_VAP_VSM_VTX_ASSM, 0x405);
     OUT_CS_REG(R300_SE_VTE_CNTL, 0x0000043F);
-    /* Vertex size. */
-    OUT_CS_REG(R300_VAP_VTX_SIZE, 0x8);
 
     /* XXX */
     OUT_CS_REG(R300_SC_CLIP_RULE, 0xaaaa);
index 1b02239ee763201036b54b0447499524353b6d02..cc7f6a7c4b048ccc4270ee00f6f5e5c527a1a12d 100644 (file)
 
 #include "r300_state_shader.h"
 
-static void r300_copy_passthrough_shader(struct r300_fragment_shader* fs)
-{
-    struct r300_fragment_shader* pt = &r300_passthrough_fragment_shader;
-    fs->shader.stack_size = pt->shader.stack_size;
-    fs->alu_instruction_count = pt->alu_instruction_count;
-    fs->tex_instruction_count = pt->tex_instruction_count;
-    fs->indirections = pt->indirections;
-    fs->instructions[0] = pt->instructions[0];
-}
-
-static void r500_copy_passthrough_shader(struct r500_fragment_shader* fs)
-{
-    struct r500_fragment_shader* pt = &r500_passthrough_fragment_shader;
-    fs->shader.stack_size = pt->shader.stack_size;
-    fs->instruction_count = pt->instruction_count;
-    fs->instructions[0] = pt->instructions[0];
-}
-
 static void r300_fs_declare(struct r300_fs_asm* assembler,
                             struct tgsi_full_declaration* decl)
 {
@@ -49,6 +31,7 @@ static void r300_fs_declare(struct r300_fs_asm* assembler,
                 case TGSI_SEMANTIC_COLOR:
                     assembler->color_count++;
                     break;
+                case TGSI_SEMANTIC_FOG:
                 case TGSI_SEMANTIC_GENERIC:
                     assembler->tex_count++;
                     break;
@@ -59,6 +42,12 @@ static void r300_fs_declare(struct r300_fs_asm* assembler,
             }
             break;
         case TGSI_FILE_OUTPUT:
+            /* Depth write. Mark the position of the output so we can
+             * identify it later. */
+            if (decl->Semantic.SemanticName == TGSI_SEMANTIC_POSITION) {
+                assembler->depth_output = decl->DeclarationRange.First;
+            }
+            break;
         case TGSI_FILE_CONSTANT:
             break;
         case TGSI_FILE_TEMPORARY:
@@ -120,6 +109,14 @@ static INLINE unsigned r300_fs_dst(struct r300_fs_asm* assembler,
     return 0;
 }
 
+static INLINE boolean r300_fs_is_depr(struct r300_fs_asm* assembler,
+                                      struct tgsi_dst_register* dst)
+{
+    return (assembler->writes_depth &&
+            (dst->File == TGSI_FILE_OUTPUT) &&
+            (dst->Index == assembler->depth_output));
+}
+
 static INLINE unsigned r500_fix_swiz(unsigned s)
 {
     /* For historical reasons, the swizzle values x, y, z, w, and 0 are
@@ -194,11 +191,17 @@ static INLINE uint32_t r300_alpha_op(unsigned op)
 static INLINE uint32_t r500_rgba_op(unsigned op)
 {
     switch (op) {
+        case TGSI_OPCODE_COS:
         case TGSI_OPCODE_EX2:
         case TGSI_OPCODE_LG2:
         case TGSI_OPCODE_RCP:
         case TGSI_OPCODE_RSQ:
+        case TGSI_OPCODE_SIN:
             return R500_ALU_RGBA_OP_SOP;
+        case TGSI_OPCODE_DDX:
+            return R500_ALU_RGBA_OP_MDH;
+        case TGSI_OPCODE_DDY:
+            return R500_ALU_RGBA_OP_MDV;
         case TGSI_OPCODE_FRC:
             return R500_ALU_RGBA_OP_FRC;
         case TGSI_OPCODE_DP3:
@@ -224,6 +227,8 @@ static INLINE uint32_t r500_rgba_op(unsigned op)
 static INLINE uint32_t r500_alpha_op(unsigned op)
 {
     switch (op) {
+        case TGSI_OPCODE_COS:
+            return R500_ALPHA_OP_COS;
         case TGSI_OPCODE_EX2:
             return R500_ALPHA_OP_EX2;
         case TGSI_OPCODE_LG2:
@@ -234,6 +239,12 @@ static INLINE uint32_t r500_alpha_op(unsigned op)
             return R500_ALPHA_OP_RSQ;
         case TGSI_OPCODE_FRC:
             return R500_ALPHA_OP_FRC;
+        case TGSI_OPCODE_SIN:
+            return R500_ALPHA_OP_SIN;
+        case TGSI_OPCODE_DDX:
+            return R500_ALPHA_OP_MDH;
+        case TGSI_OPCODE_DDY:
+            return R500_ALPHA_OP_MDV;
         case TGSI_OPCODE_DP3:
         case TGSI_OPCODE_DP4:
         case TGSI_OPCODE_DPH:
@@ -295,38 +306,34 @@ static INLINE void r300_emit_maths(struct r300_fragment_shader* fs,
 }
 
 /* Setup an ALU operation. */
-static INLINE void r500_emit_alu(struct r500_fragment_shader* fs,
-                                 struct r300_fs_asm* assembler,
-                                 struct tgsi_full_dst_register* dst)
+static INLINE void r500_emit_maths(struct r500_fragment_shader* fs,
+                                   struct r300_fs_asm* assembler,
+                                   struct tgsi_full_src_register* src,
+                                   struct tgsi_full_dst_register* dst,
+                                   unsigned op,
+                                   unsigned count)
 {
     int i = fs->instruction_count;
 
     if (dst->DstRegister.File == TGSI_FILE_OUTPUT) {
-        fs->instructions[i].inst0 = R500_INST_TYPE_OUT |
-        R500_ALU_OMASK(dst->DstRegister.WriteMask);
+        fs->instructions[i].inst0 = R500_INST_TYPE_OUT;
+        if (r300_fs_is_depr(assembler, dst)) {
+            fs->instructions[i].inst4 = R500_W_OMASK;
+        } else {
+            fs->instructions[i].inst0 |=
+                R500_ALU_OMASK(dst->DstRegister.WriteMask);
+        }
     } else {
         fs->instructions[i].inst0 = R500_INST_TYPE_ALU |
-        R500_ALU_WMASK(dst->DstRegister.WriteMask);
+            R500_ALU_WMASK(dst->DstRegister.WriteMask);
     }
 
     fs->instructions[i].inst0 |= R500_INST_TEX_SEM_WAIT;
 
-    fs->instructions[i].inst4 =
+    fs->instructions[i].inst4 |=
         R500_ALPHA_ADDRD(r300_fs_dst(assembler, &dst->DstRegister));
     fs->instructions[i].inst5 =
         R500_ALU_RGBA_ADDRD(r300_fs_dst(assembler, &dst->DstRegister));
-}
-
-static INLINE void r500_emit_maths(struct r500_fragment_shader* fs,
-                                   struct r300_fs_asm* assembler,
-                                   struct tgsi_full_src_register* src,
-                                   struct tgsi_full_dst_register* dst,
-                                   unsigned op,
-                                   unsigned count)
-{
-    int i = fs->instruction_count;
-
-    r500_emit_alu(fs, assembler, dst);
 
     switch (count) {
         case 3:
@@ -348,8 +355,8 @@ static INLINE void r500_emit_maths(struct r500_fragment_shader* fs,
                 R500_ALU_RGB_SEL_B_SRC1 |
                 R500_SWIZ_RGB_B(r500_rgb_swiz(&src[1]));
             fs->instructions[i].inst4 |=
-                R500_SWIZ_ALPHA_B(r500_alpha_swiz(&src[1])) |
-                R500_ALPHA_SEL_B_SRC1;
+                R500_ALPHA_SEL_B_SRC1 |
+                R500_SWIZ_ALPHA_B(r500_alpha_swiz(&src[1]));
         case 1:
         case 0:
         default:
@@ -361,8 +368,8 @@ static INLINE void r500_emit_maths(struct r500_fragment_shader* fs,
                 R500_ALU_RGB_SEL_A_SRC0 |
                 R500_SWIZ_RGB_A(r500_rgb_swiz(&src[0]));
             fs->instructions[i].inst4 |=
-                R500_SWIZ_ALPHA_A(r500_alpha_swiz(&src[0])) |
-                R500_ALPHA_SEL_A_SRC0;
+                R500_ALPHA_SEL_A_SRC0 |
+                R500_SWIZ_ALPHA_A(r500_alpha_swiz(&src[0]));
             break;
     }
 
@@ -441,6 +448,9 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs,
      * AMD/ATI names for opcodes, please, as it facilitates using the
      * documentation. */
     switch (inst->Instruction.Opcode) {
+        /* XXX trig needs extra prep */
+        case TGSI_OPCODE_COS:
+        case TGSI_OPCODE_SIN:
         /* The simple scalar ops. */
         case TGSI_OPCODE_EX2:
         case TGSI_OPCODE_LG2:
@@ -452,6 +462,8 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs,
             inst->FullSrcRegisters[0].SrcRegister.SwizzleW =
                 inst->FullSrcRegisters[0].SrcRegister.SwizzleX;
             /* Fall through */
+        case TGSI_OPCODE_DDX:
+        case TGSI_OPCODE_DDY:
         case TGSI_OPCODE_FRC:
             r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
                     &inst->FullDstRegisters[0], inst->Instruction.Opcode, 1);
@@ -527,6 +539,60 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs,
                     &inst->FullDstRegisters[0], inst->Instruction.Opcode, 3);
             break;
 
+        /* The compound and hybrid insts. */
+        case TGSI_OPCODE_LRP:
+            /* LRP DST A, B, C -> MAD TMP -A, C, C; MAD DST A, B, TMP */
+            inst->FullSrcRegisters[3] = inst->FullSrcRegisters[1];
+            inst->FullSrcRegisters[1] = inst->FullSrcRegisters[2];
+            inst->FullSrcRegisters[0].SrcRegister.Negate =
+                !(inst->FullSrcRegisters[0].SrcRegister.Negate);
+            inst->FullDstRegisters[1] = inst->FullDstRegisters[0];
+            inst->FullDstRegisters[0].DstRegister.Index =
+                assembler->temp_count;
+            inst->FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
+            r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+                    &inst->FullDstRegisters[0], TGSI_OPCODE_MAD, 3);
+            inst->FullSrcRegisters[2].SrcRegister.Index =
+                assembler->temp_count;
+            inst->FullSrcRegisters[2].SrcRegister.File = TGSI_FILE_TEMPORARY;
+            inst->FullSrcRegisters[2].SrcRegister.SwizzleX = TGSI_SWIZZLE_X;
+            inst->FullSrcRegisters[2].SrcRegister.SwizzleY = TGSI_SWIZZLE_Y;
+            inst->FullSrcRegisters[2].SrcRegister.SwizzleZ = TGSI_SWIZZLE_Z;
+            inst->FullSrcRegisters[2].SrcRegister.SwizzleW = TGSI_SWIZZLE_W;
+            inst->FullSrcRegisters[1] = inst->FullSrcRegisters[3];
+            inst->FullSrcRegisters[0].SrcRegister.Negate =
+                !(inst->FullSrcRegisters[0].SrcRegister.Negate);
+            inst->FullDstRegisters[0] = inst->FullDstRegisters[1];
+            r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+                    &inst->FullDstRegisters[0], TGSI_OPCODE_MAD, 3);
+            break;
+        case TGSI_OPCODE_POW:
+            /* POW DST A, B -> LG2 TMP A; MUL TMP TMP, B; EX2 DST TMP */
+            inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtSwizzleW =
+                inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtSwizzleX;
+            inst->FullSrcRegisters[0].SrcRegister.SwizzleW =
+                inst->FullSrcRegisters[0].SrcRegister.SwizzleX;
+            inst->FullDstRegisters[1] = inst->FullDstRegisters[0];
+            inst->FullDstRegisters[0].DstRegister.Index =
+                assembler->temp_count;
+            inst->FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
+            r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+                    &inst->FullDstRegisters[0], TGSI_OPCODE_LG2, 1);
+            inst->FullSrcRegisters[0].SrcRegister.Index =
+                assembler->temp_count;
+            inst->FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
+            inst->FullSrcRegisters[0].SrcRegister.SwizzleX = TGSI_SWIZZLE_X;
+            inst->FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_Y;
+            inst->FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_Z;
+            inst->FullSrcRegisters[0].SrcRegister.SwizzleW = TGSI_SWIZZLE_W;
+            inst->FullSrcRegisters[2] = r500_constant_zero;
+            r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+                    &inst->FullDstRegisters[0], TGSI_OPCODE_MUL, 3);
+            inst->FullDstRegisters[0] = inst->FullDstRegisters[1];
+            r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+                    &inst->FullDstRegisters[0], TGSI_OPCODE_EX2, 1);
+            break;
+
         /* The texture instruction set. */
         case TGSI_OPCODE_KIL:
         case TGSI_OPCODE_TEX:
@@ -555,7 +621,7 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs,
 static void r300_fs_finalize(struct r3xx_fragment_shader* fs,
                              struct r300_fs_asm* assembler)
 {
-    fs->stack_size = assembler->temp_count + assembler->temp_offset;
+    fs->stack_size = assembler->temp_count + assembler->temp_offset + 1;
 }
 
 static void r500_fs_finalize(struct r500_fragment_shader* fs,
@@ -581,6 +647,8 @@ void r300_translate_fragment_shader(struct r300_context* r300,
     }
     /* Setup starting offset for immediates. */
     assembler->imm_offset = consts->user_count;
+    /* Enable depth writes, if needed. */
+    assembler->writes_depth = fs->info.writes_z;
 
     /* Make sure we start at the beginning of the shader. */
     if (is_r500) {
@@ -630,6 +698,7 @@ void r300_translate_fragment_shader(struct r300_context* r300,
             assembler->tex_count + assembler->color_count);
 
     consts->count = consts->user_count + assembler->imm_count;
+    fs->uses_imms = assembler->imm_count;
     debug_printf("r300: fs: %d total constants, "
             "%d from user and %d from immediates\n", consts->count,
             consts->user_count, assembler->imm_count);
index 185fdd90f0cd93a1c59c0a78b975ade035f2d998..b6087404cefaef9b4e6b42d18b58d402ebe93588 100644 (file)
@@ -57,6 +57,7 @@
 #define R500_TEX_WMASK(x) ((x) << 11)
 #define R500_ALU_WMASK(x) ((x) << 11)
 #define R500_ALU_OMASK(x) ((x) << 15)
+#define R500_W_OMASK (1 << 31)
 
 /* TGSI constants. TGSI is like XML: If it can't solve your problems, you're
  * not using enough of it. */
@@ -99,20 +100,17 @@ struct r300_fs_asm {
     unsigned imm_offset;
     /* Number of immediate constants. */
     unsigned imm_count;
+    /* Are depth writes enabled? */
+    boolean writes_depth;
+    /* Depth write offset. This is the TGSI output that corresponds to
+     * depth writes. */
+    unsigned depth_output;
 };
 
 void r300_translate_fragment_shader(struct r300_context* r300,
                            struct r3xx_fragment_shader* fs);
 
 static struct r300_fragment_shader r300_passthrough_fragment_shader = {
-    /* XXX This is the emission code. TODO: decode
-    OUT_CS_REG(R300_US_CONFIG, 0);
-    OUT_CS_REG(R300_US_CODE_OFFSET, 0x0);
-    OUT_CS_REG(R300_US_CODE_ADDR_0, 0x0);
-    OUT_CS_REG(R300_US_CODE_ADDR_1, 0x0);
-    OUT_CS_REG(R300_US_CODE_ADDR_2, 0x0);
-    OUT_CS_REG(R300_US_CODE_ADDR_3, 0x400000);
-*/
     .alu_instruction_count = 1,
     .tex_instruction_count = 0,
     .indirections = 0,
@@ -159,14 +157,6 @@ static struct r500_fragment_shader r500_passthrough_fragment_shader = {
 };
 
 static struct r300_fragment_shader r300_texture_fragment_shader = {
-    /* XXX This is the emission code. TODO: decode
-    OUT_CS_REG(R300_US_CONFIG, 0);
-    OUT_CS_REG(R300_US_CODE_OFFSET, 0x0);
-    OUT_CS_REG(R300_US_CODE_ADDR_0, 0x0);
-    OUT_CS_REG(R300_US_CODE_ADDR_1, 0x0);
-    OUT_CS_REG(R300_US_CODE_ADDR_2, 0x0);
-    OUT_CS_REG(R300_US_CODE_ADDR_3, 0x400000);
-*/
     .alu_instruction_count = 1,
     .tex_instruction_count = 0,
     .indirections = 0,
@@ -191,7 +181,7 @@ static struct r500_fragment_shader r500_texture_fragment_shader = {
     .instruction_count = 2,
     .instructions[0].inst0 = R500_INST_TYPE_TEX |
         R500_INST_TEX_SEM_WAIT |
-        R500_INST_RGB_OMASK_RGB | R500_INST_ALPHA_OMASK |
+        R500_INST_RGB_WMASK_RGB | R500_INST_ALPHA_WMASK |
         R500_INST_RGB_CLAMP | R500_INST_ALPHA_CLAMP,
     .instructions[0].inst1 = R500_TEX_ID(0) | R500_TEX_INST_LD |
         R500_TEX_SEM_ACQUIRE | R500_TEX_IGNORE_UNCOVERED,
index d84912de48fdefab062cfb9abd5cc31bf979fd58..8cf8250425ec740a847162ebf6d58a7c587a3f27 100644 (file)
@@ -71,16 +71,13 @@ static INLINE unsigned r300_vs_src_type(struct r300_vs_asm* assembler,
 {
     switch (src->File) {
         case TGSI_FILE_NULL:
-            /* Probably a zero or one swizzle */
-            return R300_PVS_SRC_REG_INPUT;
-            break;
         case TGSI_FILE_INPUT:
+            /* Probably a zero or one swizzle */
             return R300_PVS_SRC_REG_INPUT;
-            break;
         case TGSI_FILE_TEMPORARY:
             return R300_PVS_SRC_REG_TEMPORARY;
-            break;
         case TGSI_FILE_CONSTANT:
+        case TGSI_FILE_IMMEDIATE:
             return R300_PVS_SRC_REG_CONSTANT;
         default:
             debug_printf("r300: vs: Unimplemented src type %d\n", src->File);
@@ -89,16 +86,32 @@ static INLINE unsigned r300_vs_src_type(struct r300_vs_asm* assembler,
     return 0;
 }
 
+static INLINE unsigned r300_vs_src(struct r300_vs_asm* assembler,
+                                   struct tgsi_src_register* src)
+{
+    switch (src->File) {
+        case TGSI_FILE_NULL:
+        case TGSI_FILE_INPUT:
+        case TGSI_FILE_TEMPORARY:
+        case TGSI_FILE_CONSTANT:
+            return src->Index;
+        case TGSI_FILE_IMMEDIATE:
+            return src->Index + assembler->imm_offset;
+        default:
+            debug_printf("r300: vs: Unimplemented src type %d\n", src->File);
+            break;
+    }
+    return 0;
+}
+
 static INLINE unsigned r300_vs_dst_type(struct r300_vs_asm* assembler,
                                         struct tgsi_dst_register* dst)
 {
     switch (dst->File) {
         case TGSI_FILE_TEMPORARY:
             return R300_PVS_DST_REG_TEMPORARY;
-            break;
         case TGSI_FILE_OUTPUT:
             return R300_PVS_DST_REG_OUT;
-            break;
         default:
             debug_printf("r300: vs: Unimplemented dst type %d\n", dst->File);
             break;
@@ -112,10 +125,8 @@ static INLINE unsigned r300_vs_dst(struct r300_vs_asm* assembler,
     switch (dst->File) {
         case TGSI_FILE_TEMPORARY:
             return dst->Index;
-            break;
         case TGSI_FILE_OUTPUT:
             return assembler->tab[dst->Index];
-            break;
         default:
             debug_printf("r300: vs: Unimplemented dst %d\n", dst->File);
             break;
@@ -133,8 +144,15 @@ static uint32_t r300_vs_op(unsigned op)
             return R300_VE_MULTIPLY;
         case TGSI_OPCODE_ADD:
         case TGSI_OPCODE_MOV:
+        case TGSI_OPCODE_SUB:
         case TGSI_OPCODE_SWZ:
             return R300_VE_ADD;
+        case TGSI_OPCODE_MAX:
+            return R300_VE_MAXIMUM;
+        case TGSI_OPCODE_SLT:
+            return R300_VE_SET_LESS_THAN;
+        case TGSI_OPCODE_RSQ:
+            return R300_PVS_DST_MATH_INST | R300_ME_RECIP_DX;
         case TGSI_OPCODE_MAD:
             return R300_PVS_DST_MACRO_INST | R300_PVS_MACRO_OP_2CLK_MADD;
         default:
@@ -146,51 +164,78 @@ static uint32_t r300_vs_op(unsigned op)
 static uint32_t r300_vs_swiz(struct tgsi_full_src_register* reg)
 {
     if (reg->SrcRegister.Extended) {
-        return reg->SrcRegisterExtSwz.ExtSwizzleX |
+        return (reg->SrcRegister.Negate ? (0xf << 12) : 0) |
+            reg->SrcRegisterExtSwz.ExtSwizzleX |
             (reg->SrcRegisterExtSwz.ExtSwizzleY << 3) |
             (reg->SrcRegisterExtSwz.ExtSwizzleZ << 6) |
             (reg->SrcRegisterExtSwz.ExtSwizzleW << 9);
     } else {
-        return reg->SrcRegister.SwizzleX |
+        return (reg->SrcRegister.Negate ? (0xf << 12) : 0) |
+            reg->SrcRegister.SwizzleX |
             (reg->SrcRegister.SwizzleY << 3) |
             (reg->SrcRegister.SwizzleZ << 6) |
             (reg->SrcRegister.SwizzleW << 9);
     }
 }
 
+/* XXX icky icky icky icky */
+static uint32_t r300_vs_scalar_swiz(struct tgsi_full_src_register* reg)
+{
+    if (reg->SrcRegister.Extended) {
+        return (reg->SrcRegister.Negate ? (0xf << 12) : 0) |
+            reg->SrcRegisterExtSwz.ExtSwizzleX |
+            (reg->SrcRegisterExtSwz.ExtSwizzleX << 3) |
+            (reg->SrcRegisterExtSwz.ExtSwizzleX << 6) |
+            (reg->SrcRegisterExtSwz.ExtSwizzleX << 9);
+    } else {
+        return (reg->SrcRegister.Negate ? (0xf << 12) : 0) |
+            reg->SrcRegister.SwizzleX |
+            (reg->SrcRegister.SwizzleX << 3) |
+            (reg->SrcRegister.SwizzleX << 6) |
+            (reg->SrcRegister.SwizzleX << 9);
+    }
+}
+
+/* XXX scalar stupidity */
 static void r300_vs_emit_inst(struct r300_vertex_shader* vs,
                               struct r300_vs_asm* assembler,
                               struct tgsi_full_src_register* src,
                               struct tgsi_full_dst_register* dst,
                               unsigned op,
-                              unsigned count)
+                              unsigned count,
+                              boolean is_scalar)
 {
     int i = vs->instruction_count;
     vs->instructions[i].inst0 = R300_PVS_DST_OPCODE(r300_vs_op(op)) |
         R300_PVS_DST_REG_TYPE(r300_vs_dst_type(assembler, &dst->DstRegister)) |
         R300_PVS_DST_OFFSET(r300_vs_dst(assembler, &dst->DstRegister)) |
-        R300_PVS_DST_WE_XYZW;
+        R300_PVS_DST_WE(dst->DstRegister.WriteMask);
     switch (count) {
         case 3:
             vs->instructions[i].inst3 =
                 R300_PVS_SRC_REG_TYPE(r300_vs_src_type(assembler,
                             &src[2].SrcRegister)) |
-                R300_PVS_SRC_OFFSET(src[2].SrcRegister.Index) |
+                R300_PVS_SRC_OFFSET(r300_vs_src(assembler,
+                            &src[2].SrcRegister)) |
                 R300_PVS_SRC_SWIZZLE(r300_vs_swiz(&src[2]));
             /* Fall through */
         case 2:
             vs->instructions[i].inst2 =
                 R300_PVS_SRC_REG_TYPE(r300_vs_src_type(assembler,
                             &src[1].SrcRegister)) |
-                R300_PVS_SRC_OFFSET(src[1].SrcRegister.Index) |
+                R300_PVS_SRC_OFFSET(r300_vs_src(assembler,
+                            &src[1].SrcRegister)) |
                 R300_PVS_SRC_SWIZZLE(r300_vs_swiz(&src[1]));
             /* Fall through */
         case 1:
             vs->instructions[i].inst1 =
                 R300_PVS_SRC_REG_TYPE(r300_vs_src_type(assembler,
                             &src[0].SrcRegister)) |
-                R300_PVS_SRC_OFFSET(src[0].SrcRegister.Index) |
-                R300_PVS_SRC_SWIZZLE(r300_vs_swiz(&src[0]));
+                R300_PVS_SRC_OFFSET(r300_vs_src(assembler,
+                            &src[0].SrcRegister)) |
+                /* XXX the icky, it burns */
+                R300_PVS_SRC_SWIZZLE(is_scalar ? r300_vs_scalar_swiz(&src[0])
+                        : r300_vs_swiz(&src[0]));
             break;
     }
     vs->instruction_count++;
@@ -201,11 +246,22 @@ static void r300_vs_instruction(struct r300_vertex_shader* vs,
                                 struct tgsi_full_instruction* inst)
 {
     switch (inst->Instruction.Opcode) {
+        case TGSI_OPCODE_RSQ:
+            r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters,
+                    &inst->FullDstRegisters[0], inst->Instruction.Opcode,
+                    1, TRUE);
+            break;
+        case TGSI_OPCODE_SUB:
+            inst->FullSrcRegisters[1].SrcRegister.Negate =
+                !inst->FullSrcRegisters[1].SrcRegister.Negate;
+            /* Fall through */
         case TGSI_OPCODE_ADD:
         case TGSI_OPCODE_MUL:
+        case TGSI_OPCODE_MAX:
+        case TGSI_OPCODE_SLT:
             r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters,
                     &inst->FullDstRegisters[0], inst->Instruction.Opcode,
-                    2);
+                    2, FALSE);
             break;
         case TGSI_OPCODE_DP3:
             /* Set alpha swizzle to zero for src0 and src1 */
@@ -235,19 +291,19 @@ static void r300_vs_instruction(struct r300_vertex_shader* vs,
         case TGSI_OPCODE_DP4:
             r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters,
                     &inst->FullDstRegisters[0], inst->Instruction.Opcode,
-                    2);
+                    2, FALSE);
             break;
         case TGSI_OPCODE_MOV:
         case TGSI_OPCODE_SWZ:
             inst->FullSrcRegisters[1] = r300_constant_zero;
             r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters,
                     &inst->FullDstRegisters[0], inst->Instruction.Opcode,
-                    2);
+                    2, FALSE);
             break;
         case TGSI_OPCODE_MAD:
             r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters,
                     &inst->FullDstRegisters[0], inst->Instruction.Opcode,
-                    3);
+                    3, FALSE);
             break;
         case TGSI_OPCODE_END:
             break;
@@ -278,6 +334,8 @@ static void r300_vs_init(struct r300_vertex_shader* vs,
                 break;
         }
     }
+
+    vs->instruction_count = 0;
 }
 
 void r300_translate_vertex_shader(struct r300_context* r300,
@@ -337,6 +395,7 @@ void r300_translate_vertex_shader(struct r300_context* r300,
             assembler->tex_count + assembler->color_count);
 
     consts->count = consts->user_count + assembler->imm_count;
+    vs->uses_imms = assembler->imm_count;
     debug_printf("r300: vs: %d total constants, "
             "%d from user and %d from immediates\n", consts->count,
             consts->user_count, assembler->imm_count);
index e2e1357d4360225ba190476195462078f652f605..2c8b586c2f56ab7dda95b1825d4e1b10197b1c11 100644 (file)
 #   define R300_VE_DOT_PRODUCT            1
 #   define R300_VE_MULTIPLY               2
 #   define R300_VE_ADD                    3
+#   define R300_VE_MAXIMUM                7
+#   define R300_VE_SET_LESS_THAN          10
+#define R300_PVS_DST_MATH_INST     (1 << 6)
+#   define R300_ME_RECIP_DX               6
 #define R300_PVS_DST_MACRO_INST    (1 << 7)
 #   define R300_PVS_MACRO_OP_2CLK_MADD    0
 #define R300_PVS_DST_REG_TYPE(x) ((x) << 8)
     ((R300_PVS_SRC_SELECT_FORCE_1 | (R300_PVS_SRC_SELECT_FORCE_1 << 3) | \
      (R300_PVS_SRC_SELECT_FORCE_1 << 6) | \
       (R300_PVS_SRC_SELECT_FORCE_1 << 9)) << 13)
+#define R300_PVS_MODIFIER_X        (1 << 25)
+#define R300_PVS_MODIFIER_Y        (1 << 26)
+#define R300_PVS_MODIFIER_Z        (1 << 27)
+#define R300_PVS_MODIFIER_W        (1 << 28)
+#define R300_PVS_NEGATE_XYZW \
+    (R300_PVS_MODIFIER_X | R300_PVS_MODIFIER_Y | \
+     R300_PVS_MODIFIER_Z | R300_PVS_MODIFIER_W)
 
 static const struct tgsi_full_src_register r300_constant_zero = {
     .SrcRegister.Extended = TRUE,
index 4dd5b8af99a5e052f4a5991164ad4b347305947f..c9e2dff14ed7fef81e59fe3cca8281b8cb9be625 100644 (file)
 
 #include "r300_surface.h"
 
-static void r300_surface_setup(struct pipe_context* pipe,
-                               struct pipe_surface* dest,
+static void r300_surface_setup(struct r300_context* r300,
+                               struct r300_texture* dest,
                                unsigned x, unsigned y,
                                unsigned w, unsigned h)
 {
-    struct r300_context* r300 = r300_context(pipe);
-    struct r300_capabilities* caps = r300_screen(pipe->screen)->caps;
-    struct r300_texture* tex = (struct r300_texture*)dest->texture;
-    unsigned pixpitch = tex->stride / tex->tex.block.size;
+    struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps;
+    unsigned pixpitch = dest->stride / dest->tex.block.size;
     CS_LOCALS(r300);
 
-    /* Make sure our target BO is okay. */
-    r300->winsys->add_buffer(r300->winsys, tex->buffer,
-            0, RADEON_GEM_DOMAIN_VRAM);
-    if (r300->winsys->validate(r300->winsys)) {
-        r300->context.flush(&r300->context, 0, NULL);
-    }
-
     r300_emit_blend_state(r300, &blend_clear_state);
     r300_emit_blend_color_state(r300, &blend_color_clear_state);
     r300_emit_dsa_state(r300, &dsa_clear_state);
     r300_emit_rs_state(r300, &rs_clear_state);
 
-    BEGIN_CS(15);
+    BEGIN_CS(24);
+
+    /* Viewport setup */
+    OUT_CS_REG_SEQ(R300_SE_VPORT_XSCALE, 6);
+    OUT_CS_32F((float)w);
+    OUT_CS_32F((float)x);
+    OUT_CS_32F((float)h);
+    OUT_CS_32F((float)y);
+    OUT_CS_32F(1.0);
+    OUT_CS_32F(0.0);
+
+    OUT_CS_REG(R300_VAP_VTE_CNTL, R300_VPORT_X_SCALE_ENA |
+            R300_VPORT_X_OFFSET_ENA |
+            R300_VPORT_Y_SCALE_ENA |
+            R300_VPORT_Y_OFFSET_ENA |
+            R300_VTX_XY_FMT | R300_VTX_Z_FMT);
 
     /* Pixel scissors. */
     OUT_CS_REG_SEQ(R300_SC_SCISSORS_TL, 2);
@@ -71,9 +77,9 @@ static void r300_surface_setup(struct pipe_context* pipe,
 
     /* Setup colorbuffer. */
     OUT_CS_REG_SEQ(R300_RB3D_COLOROFFSET0, 1);
-    OUT_CS_RELOC(tex->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+    OUT_CS_RELOC(dest->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
     OUT_CS_REG(R300_RB3D_COLORPITCH0, pixpitch |
-        r300_translate_colorformat(tex->tex.format));
+        r300_translate_colorformat(dest->tex.format));
     OUT_CS_REG(RB3D_COLOR_CHANNEL_MASK, 0xf);
 
     END_CS;
@@ -93,6 +99,7 @@ static void r300_surface_fill(struct pipe_context* pipe,
     struct r300_capabilities* caps = r300_screen(pipe->screen)->caps;
     struct r300_texture* tex = (struct r300_texture*)dest->texture;
     unsigned pixpitch = tex->stride / tex->tex.block.size;
+    boolean invalid = FALSE;
     CS_LOCALS(r300);
 
     a = (float)((color >> 24) & 0xff) / 255.0f;
@@ -105,12 +112,29 @@ static void r300_surface_fill(struct pipe_context* pipe,
 
     /* Fallback? */
     if (FALSE) {
+fallback:
         debug_printf("r300: Falling back on surface clear...");
         util_surface_fill(pipe, dest, x, y, w, h, color);
         return;
     }
 
-    r300_surface_setup(r300, dest, x, y, w, h);
+    /* Make sure our target BO is okay. */
+validate:
+    if (!r300->winsys->add_buffer(r300->winsys, tex->buffer,
+                0, RADEON_GEM_DOMAIN_VRAM)) {
+        r300->context.flush(&r300->context, 0, NULL);
+        goto validate;
+    }
+    if (r300->winsys->validate(r300->winsys)) {
+        r300->context.flush(&r300->context, 0, NULL);
+        if (invalid) {
+            goto fallback;
+        }
+        invalid = TRUE;
+        goto validate;
+    }
+
+    r300_surface_setup(r300, tex, x, y, w, h);
 
     /* Vertex shader setup */
     if (caps->has_tcl) {
@@ -134,7 +158,7 @@ static void r300_surface_fill(struct pipe_context* pipe,
         r300_emit_rs_block_state(r300, &r300_rs_block_clear_state);
     }
 
-    BEGIN_CS(31);
+    BEGIN_CS(26);
 
     /* VAP stream control, mapping from input memory to PVS/RS memory */
     if (caps->has_tcl) {
@@ -161,27 +185,21 @@ static void r300_surface_fill(struct pipe_context* pipe,
     /* Disable textures */
     OUT_CS_REG(R300_TX_ENABLE, 0x0);
 
-    /* Viewport setup */
-    OUT_CS_REG_SEQ(R300_SE_VPORT_XSCALE, 6);
-    OUT_CS_32F(1.0);
-    OUT_CS_32F((float)x);
-    OUT_CS_32F(1.0);
-    OUT_CS_32F((float)y);
-    OUT_CS_32F(1.0);
-    OUT_CS_32F(0.0);
-
     /* The size of the point we're about to draw, in sixths of pixels */
     OUT_CS_REG(R300_GA_POINT_SIZE,
-        ((h * 6) & R300_POINTSIZE_Y_MASK) |
+        ((h * 6)  & R300_POINTSIZE_Y_MASK) |
         ((w * 6) << R300_POINTSIZE_X_SHIFT));
 
+    /* Vertex size. */
+    OUT_CS_REG(R300_VAP_VTX_SIZE, 0x8);
+
     /* Packet3 with our point vertex */
     OUT_CS_PKT3(R200_3D_DRAW_IMMD_2, 8);
     OUT_CS(R300_PRIM_TYPE_POINT | R300_PRIM_WALK_RING |
             (1 << R300_PRIM_NUM_VERTICES_SHIFT));
     /* Position */
-    OUT_CS_32F(w / 2.0);
-    OUT_CS_32F(h / 2.0);
+    OUT_CS_32F(0.5);
+    OUT_CS_32F(0.5);
     OUT_CS_32F(1.0);
     OUT_CS_32F(1.0);
     /* Color */
@@ -190,11 +208,7 @@ static void r300_surface_fill(struct pipe_context* pipe,
     OUT_CS_32F(b);
     OUT_CS_32F(a);
 
-    /* XXX figure out why this is 0xA and not 0x2 */
     OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, 0xA);
-    /* XXX OUT_CS_REG(R300_ZB_ZCACHE_CTLSTAT,
-        R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE |
-        R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE); */
 
     END_CS;
 
@@ -213,6 +227,7 @@ static void r300_surface_copy(struct pipe_context* pipe,
     struct r300_texture* srctex = (struct r300_texture*)src->texture;
     struct r300_texture* desttex = (struct r300_texture*)dest->texture;
     unsigned pixpitch = srctex->stride / srctex->tex.block.size;
+    boolean invalid = FALSE;
     CS_LOCALS(r300);
 
     debug_printf("r300: Copying surface %p at (%d,%d) to %p at (%d, %d),"
@@ -222,18 +237,48 @@ static void r300_surface_copy(struct pipe_context* pipe,
     if ((srctex == desttex) &&
             ((destx < srcx + w) || (srcx < destx + w)) &&
             ((desty < srcy + h) || (srcy < desty + h))) {
+fallback:
         debug_printf("r300: Falling back on surface_copy\n");
         util_surface_copy(pipe, FALSE, dest, destx, desty, src,
                 srcx, srcy, w, h);
     }
 
+    /* Add our target BOs to the list. */
+validate:
+    if (!r300->winsys->add_buffer(r300->winsys, srctex->buffer,
+                RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0)) {
+        r300->context.flush(&r300->context, 0, NULL);
+        goto validate;
+    }
+    if (!r300->winsys->add_buffer(r300->winsys, desttex->buffer,
+                0, RADEON_GEM_DOMAIN_VRAM)) {
+        r300->context.flush(&r300->context, 0, NULL);
+        goto validate;
+    }
+    if (r300->winsys->validate(r300->winsys)) {
+        r300->context.flush(&r300->context, 0, NULL);
+        if (invalid) {
+            goto fallback;
+        }
+        invalid = TRUE;
+        goto validate;
+    }
+
+    r300_surface_setup(r300, desttex, destx, desty, w, h);
+
+    /* Setup the texture. */
     r300_emit_sampler(r300, &r300_sampler_copy_state, 0);
     r300_emit_texture(r300, srctex, 0);
-    r300_flush_textures(r300);
+
+    /* Flush and enable. */
+    BEGIN_CS(4);
+    OUT_CS_REG(R300_TX_INVALTAGS, 0);
+    OUT_CS_REG(R300_TX_ENABLE, 0x1);
+    END_CS;
 
     /* Vertex shader setup */
     if (caps->has_tcl) {
-        r300_emit_vertex_shader(r300, &r300_texture_vertex_shader);
+        r300_emit_vertex_shader(r300, &r300_passthrough_vertex_shader);
     } else {
         BEGIN_CS(4);
         OUT_CS_REG(R300_VAP_CNTL_STATUS, R300_VAP_TCL_BYPASS);
@@ -253,6 +298,7 @@ static void r300_surface_copy(struct pipe_context* pipe,
         r300_emit_rs_block_state(r300, &r300_rs_block_copy_state);
     }
 
+    BEGIN_CS(30);
     /* VAP stream control, mapping from input memory to PVS/RS memory */
     if (caps->has_tcl) {
         OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0,
@@ -275,33 +321,38 @@ static void r300_surface_copy(struct pipe_context* pipe,
     /* Two components of texture 0 */
     OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_1, 0x2);
 
+    /* Vertex size. */
+    OUT_CS_REG(R300_VAP_VTX_SIZE, 0x4);
+
     /* Packet3 with our texcoords */
-    OUT_CS_PKT3(R200_3D_DRAW_IMMD_2, 8);
+    OUT_CS_PKT3(R200_3D_DRAW_IMMD_2, 16);
     OUT_CS(R300_PRIM_TYPE_QUADS | R300_PRIM_WALK_RING |
             (4 << R300_PRIM_NUM_VERTICES_SHIFT));
     /* (x    , y    ) */
-    OUT_CS_32F((float)destx);
-    OUT_CS_32F((float)desty);
-    OUT_CS_32F((float)srcx);
-    OUT_CS_32F((float)srcy);
+    OUT_CS_32F((float)(destx / dest->width));
+    OUT_CS_32F((float)(desty / dest->height));
+    OUT_CS_32F((float)(srcx  / dest->width));
+    OUT_CS_32F((float)(srcy  / dest->height));
     /* (x    , y + h) */
-    OUT_CS_32F((float)destx);
-    OUT_CS_32F((float)(desty + h));
-    OUT_CS_32F((float)srcx);
-    OUT_CS_32F((float)(srcy + h));
+    OUT_CS_32F((float)(destx / dest->width));
+    OUT_CS_32F((float)((desty + h) / dest->height));
+    OUT_CS_32F((float)(srcx  / dest->width));
+    OUT_CS_32F((float)((srcy  + h) / dest->height));
     /* (x + w, y + h) */
-    OUT_CS_32F((float)(destx + w));
-    OUT_CS_32F((float)(desty + h));
-    OUT_CS_32F((float)(srcx + w));
-    OUT_CS_32F((float)(srcy + h));
+    OUT_CS_32F((float)((destx + w) / dest->width));
+    OUT_CS_32F((float)((desty + h) / dest->height));
+    OUT_CS_32F((float)((srcx  + w) / dest->width));
+    OUT_CS_32F((float)((srcy  + h) / dest->height));
     /* (x + w, y    ) */
-    OUT_CS_32F((float)(destx + w));
-    OUT_CS_32F((float)desty);
-    OUT_CS_32F((float)(srcx + w));
-    OUT_CS_32F((float)srcy);
+    OUT_CS_32F((float)((destx + w) / dest->width));
+    OUT_CS_32F((float)(desty / dest->height));
+    OUT_CS_32F((float)((srcx  + w) / dest->width));
+    OUT_CS_32F((float)(srcy  / dest->height));
 
     OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, 0xA);
 
+    END_CS;
+
     r300->dirty_hw++;
 }
 
index 894def07aa8b3a46cbe7da0ceda975bac1aed30a..9a4c39f58bdbf5a1fe80a1eab7c1b8c10180efc4 100644 (file)
@@ -101,7 +101,7 @@ static struct r300_rs_block r300_rs_block_copy_state = {
         R500_RS_SEL_Q(R300_RS_SEL_K1),
     .inst[0] = R300_RS_INST_COL_CN_WRITE,
     .count = R300_IT_COUNT(2) | R300_IC_COUNT(0) | R300_HIRES_EN,
-    .inst_count = R300_RS_TX_OFFSET(6),
+    .inst_count = R300_RS_TX_OFFSET(0),
 };
 
 static struct r300_rs_block r500_rs_block_copy_state = {
@@ -111,7 +111,7 @@ static struct r300_rs_block r500_rs_block_copy_state = {
         R500_RS_SEL_Q(R500_RS_IP_PTR_K1),
     .inst[0] = R500_RS_INST_TEX_CN_WRITE,
     .count = R300_IT_COUNT(2) | R300_IC_COUNT(0) | R300_HIRES_EN,
-    .inst_count = R300_RS_TX_OFFSET(6),
+    .inst_count = R300_RS_TX_OFFSET(0),
 };
 
 static struct r300_sampler_state r300_sampler_copy_state = {
index fe91f4e18449399d96b79ed25e5af75ce4675b93..5ea9f56247be39509f7a4e50e08927f74e9ffc0c 100644 (file)
@@ -86,8 +86,6 @@ static struct pipe_texture*
     r300_texture_create(struct pipe_screen* screen,
                         const struct pipe_texture* template)
 {
-    /* XXX struct r300_screen* r300screen = r300_screen(screen); */
-
     struct r300_texture* tex = CALLOC_STRUCT(r300_texture);
 
     if (!tex) {
index a833bb0399af7021c01753ce73e8c63bf794de9f..d2893c3b9d76b3f41a8a8d670ebe443dba0bf986 100644 (file)
@@ -45,9 +45,6 @@ struct r300_winsys {
     /* PCI ID */
     uint32_t pci_id;
 
-    /* GB pipe count */
-    uint32_t gb_pipes;
-
     /* GART size. */
     uint32_t gart_size;
 
@@ -55,10 +52,10 @@ struct r300_winsys {
     uint32_t vram_size;
 
     /* Add a pipe_buffer to the list of buffer objects to validate. */
-    void (*add_buffer)(struct r300_winsys* winsys,
-                       struct pipe_buffer* pbuffer,
-                       uint32_t rd,
-                       uint32_t wd);
+    boolean (*add_buffer)(struct r300_winsys* winsys,
+                          struct pipe_buffer* pbuffer,
+                          uint32_t rd,
+                          uint32_t wd);
 
     /* Revalidate all currently setup pipe_buffers.
      * Returns TRUE if a flush is required. */
index dffc15a4f1991ae72e0eab836bd21ca99695c32c..7888c2f644bd085d32e6156b5f2a2eba563672ac 100644 (file)
@@ -92,6 +92,7 @@ struct softpipe_context {
     * queries.
     */
    uint64_t occlusion_count;
+   unsigned active_query_count;
 
    /** Mapped vertex buffers */
    ubyte *mapped_vbuffer[PIPE_MAX_ATTRIBS];
index 892ef87ee9f5dd7f2933d0a292387c99655ae6ce..b5f69b74264f571d2b733f1500c61c306284ffa8 100644 (file)
@@ -80,7 +80,7 @@ sp_build_quad_pipeline(struct softpipe_context *sp)
          sp_push_quad_first( sp, sp->quad[i].blend, i );
       }
 
-      if (sp->depth_stencil->depth.occlusion_count) {
+      if (sp->active_query_count) {
          sp_push_quad_first( sp, sp->quad[i].occlusion, i );
       }
 
index 93dab236d6609ceec27ca35a58cfaee9bd0a3c6b..379cf4ad064d201f35d12bea4e8b7bf53a001a98 100644 (file)
@@ -34,6 +34,7 @@
 #include "util/u_memory.h"
 #include "sp_context.h"
 #include "sp_query.h"
+#include "sp_state.h"
 
 struct softpipe_query {
    uint64_t start;
@@ -69,6 +70,8 @@ softpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q)
    struct softpipe_query *sq = softpipe_query(q);
    
    sq->start = softpipe->occlusion_count;
+   softpipe->active_query_count++;
+   softpipe->dirty |= SP_NEW_QUERY;
 }
 
 
@@ -78,7 +81,9 @@ softpipe_end_query(struct pipe_context *pipe, struct pipe_query *q)
    struct softpipe_context *softpipe = softpipe_context( pipe );
    struct softpipe_query *sq = softpipe_query(q);
 
+   softpipe->active_query_count--;
    sq->end = softpipe->occlusion_count;
+   softpipe->dirty |= SP_NEW_QUERY;
 }
 
 
index a32fd3a1ba0d46624a102b1a6693daa831ab6e81..692deeb8fd36d8f7239421625467ef3ba7711caa 100644 (file)
@@ -82,11 +82,11 @@ softpipe_get_param(struct pipe_screen *screen, int param)
    case PIPE_CAP_TEXTURE_SHADOW_MAP:
       return 1;
    case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
-      return 12; /* max 2Kx2K */
+      return 13; /* max 4Kx4K */
    case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
       return 8;  /* max 128x128x128 */
    case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
-      return 12; /* max 2Kx2K */
+      return 13; /* max 4Kx4K */
    default:
       return 0;
    }
@@ -106,7 +106,7 @@ softpipe_get_paramf(struct pipe_screen *screen, int param)
    case PIPE_CAP_MAX_POINT_WIDTH_AA:
       return 255.0; /* arbitrary */
    case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
-      return 0.0;
+      return 16.0; /* not actually signficant at this time */
    case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
       return 16.0; /* arbitrary */
    default:
index e5be65242d6e8b4d35b486b89a50d5fa850d5a62..cb5d0fb6c2a2e51bc7ce1ff8083437b0c0d7a835 100644 (file)
@@ -507,6 +507,8 @@ static void print_vertex(const struct setup_context *setup,
 #endif
 
 /**
+ * Sort the vertices from top to bottom order, setting up the triangle
+ * edge fields (ebot, emaj, etop).
  * \return FALSE if coords are inf/nan (cull the tri), TRUE otherwise
  */
 static boolean setup_sort_vertices( struct setup_context *setup,
index 9e19745889ee28643b0da9143559a4d614b9eab3..7a533dad9f014fc6c0f03b92ab53d15c0065236b 100644 (file)
@@ -42,6 +42,7 @@
 #include "sp_texture.h"
 #include "sp_tile_cache.h"
 #include "sp_screen.h"
+#include "sp_winsys.h"
 
 
 /* Simple, maximally packed layout.
index e087db169aa80f304164c530e5671808af34c106..4aeb8e3d7edd38600e30f846776c5bc0536345d3 100644 (file)
@@ -7,8 +7,10 @@ C_SOURCES = \
        tr_buffer.c \
        tr_context.c \
        tr_dump.c \
+       tr_dump_state.c \
        tr_screen.c \
        tr_state.c \
+       tr_rbug.c \
        tr_texture.c
 
 include ../../Makefile.template
index 73dce20372e25e5dcfd121bb65de23e6862c49f1..1000c31e49aa9da084d0b354066ec8b79e22fd7c 100644 (file)
@@ -3,7 +3,8 @@
 
 = About =
 
-This directory contains a Gallium3D pipe driver which traces all incoming calls.
+This directory contains a Gallium3D debugger pipe driver.
+It can traces all incoming calls and/or provide remote debugging functionality.
 
 
 = Build Instructions =
@@ -23,7 +24,9 @@ ensure the right libGL.so is being picked by doing
 
  ldd progs/trivial/tri 
 
-and then try running
+== Traceing ==
+
+For traceing then do
 
  export XMESA_TRACE=y
  GALLIUM_TRACE=tri.trace progs/trivial/tri
@@ -32,6 +35,16 @@ which should create a tri.trace file, which is an XML file. You can view copying
 trace.xsl to the same directory, and opening with a XSLT capable browser such as 
 Firefox or Internet Explorer.
 
+== Remote debugging ==
+
+For remote debugging
+
+ export XMESA_TRACE=y
+ GALLIUM_RBUG=true progs/trivial/tri
+
+which should open gallium remote debugging session. While the program is running
+you can launch the small remote debugging application from progs/rbug. More
+information is in that directory.
 
 = Integrating =
 
@@ -62,3 +75,4 @@ trace_screen with real_screen when creating them.
 
 --
 Jose Fonseca <jrfonseca@tungstengraphics.com>
+Jakob Bornecrantz <jakob@vmware.com>
index 4215215d1a1cf5453c71db5999a1d21409a894fa..e635fed77d843c9603c9a1cdbb03145f56ba90ff 100644 (file)
@@ -8,8 +8,10 @@ trace = env.ConvenienceLibrary(
         'tr_buffer.c',
         'tr_context.c',
         'tr_dump.c',
+        'tr_dump_state.c',
         'tr_screen.c',
         'tr_state.c',
+        'tr_rbug.c',
         'tr_texture.c',
     ])
 
index 47280459a75ab9d70373c36f8de8d21f2bffcb2b..4ab718f233d4a5c854172263cf1f030a8ba8ad60 100644 (file)
 #include "pipe/p_screen.h"
 
 #include "tr_dump.h"
+#include "tr_dump_state.h"
 #include "tr_state.h"
 #include "tr_buffer.h"
 #include "tr_screen.h"
 #include "tr_texture.h"
-#include "tr_context.h"
 
 
 static INLINE struct pipe_buffer *
@@ -113,6 +113,65 @@ trace_context_set_edgeflags(struct pipe_context *_pipe,
 }
 
 
+static INLINE void
+trace_context_draw_block(struct trace_context *tr_ctx, int flag)
+{
+   int k;
+
+   pipe_mutex_lock(tr_ctx->draw_mutex);
+
+   if (tr_ctx->draw_blocker & flag) {
+      tr_ctx->draw_blocked |= flag;
+   } else if ((tr_ctx->draw_rule.blocker & flag) &&
+              (tr_ctx->draw_blocker & 4)) {
+      boolean block = FALSE;
+      debug_printf("%s (%lu %lu) (%lu %lu) (%lu %u) (%lu %u)\n", __FUNCTION__,
+                                       tr_ctx->draw_rule.fs, tr_ctx->curr.fs,
+                                       tr_ctx->draw_rule.vs, tr_ctx->curr.vs,
+                                       tr_ctx->draw_rule.surf, 0,
+                                       tr_ctx->draw_rule.tex, 0);
+      if (tr_ctx->draw_rule.fs &&
+          tr_ctx->draw_rule.fs == tr_ctx->curr.fs)
+         block = TRUE;
+      if (tr_ctx->draw_rule.vs &&
+          tr_ctx->draw_rule.vs == tr_ctx->curr.vs)
+         block = TRUE;
+      if (tr_ctx->draw_rule.surf &&
+          tr_ctx->draw_rule.surf == tr_ctx->curr.zsbuf)
+            block = TRUE;
+      if (tr_ctx->draw_rule.surf)
+         for (k = 0; k < tr_ctx->curr.nr_cbufs; k++)
+            if (tr_ctx->draw_rule.surf == tr_ctx->curr.cbufs[k])
+               block = TRUE;
+      if (tr_ctx->draw_rule.tex)
+         for (k = 0; k < tr_ctx->curr.num_texs; k++)
+            if (tr_ctx->draw_rule.tex == tr_ctx->curr.tex[k])
+               block = TRUE;
+
+      if (block)
+         tr_ctx->draw_blocked |= (flag | 4);
+   }
+
+   if (tr_ctx->draw_blocked)
+      trace_rbug_notify_draw_blocked(tr_ctx);
+
+   /* wait for rbug to clear the blocked flag */
+   while (tr_ctx->draw_blocked & flag) {
+      tr_ctx->draw_blocked |= flag;
+#ifdef PIPE_THREAD_HAVE_CONDVAR
+      pipe_condvar_wait(tr_ctx->draw_cond, tr_ctx->draw_mutex);
+#else
+      pipe_mutex_unlock(tr_ctx->draw_mutex);
+#ifdef PIPE_SUBSYSTEM_WINDOWS_USER
+      Sleep(1);
+#endif
+      pipe_mutex_lock(tr_ctx->draw_mutex);
+#endif
+   }
+
+   pipe_mutex_unlock(tr_ctx->draw_mutex);
+}
+
 static INLINE boolean
 trace_context_draw_arrays(struct pipe_context *_pipe,
                           unsigned mode, unsigned start, unsigned count)
@@ -121,6 +180,11 @@ trace_context_draw_arrays(struct pipe_context *_pipe,
    struct pipe_context *pipe = tr_ctx->pipe;
    boolean result;
 
+   if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled)
+      return 0;
+
+   trace_context_draw_block(tr_ctx, 1);
+
    trace_dump_call_begin("pipe_context", "draw_arrays");
 
    trace_dump_arg(ptr, pipe);
@@ -134,6 +198,8 @@ trace_context_draw_arrays(struct pipe_context *_pipe,
 
    trace_dump_call_end();
 
+   trace_context_draw_block(tr_ctx, 2);
+
    return result;
 }
 
@@ -150,6 +216,11 @@ trace_context_draw_elements(struct pipe_context *_pipe,
    struct pipe_buffer *indexBuffer = tr_buf->buffer;
    boolean result;
 
+   if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled)
+      return 0;
+
+   trace_context_draw_block(tr_ctx, 1);
+
    trace_screen_user_buffer_update(_pipe->screen, indexBuffer);
 
    trace_dump_call_begin("pipe_context", "draw_elements");
@@ -167,6 +238,8 @@ trace_context_draw_elements(struct pipe_context *_pipe,
 
    trace_dump_call_end();
 
+   trace_context_draw_block(tr_ctx, 2);
+
    return result;
 }
 
@@ -187,6 +260,11 @@ trace_context_draw_range_elements(struct pipe_context *_pipe,
    struct pipe_buffer *indexBuffer = tr_buf->buffer;
    boolean result;
 
+   if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled)
+      return 0;
+
+   trace_context_draw_block(tr_ctx, 1);
+
    trace_screen_user_buffer_update(_pipe->screen, indexBuffer);
 
    trace_dump_call_begin("pipe_context", "draw_range_elements");
@@ -209,6 +287,8 @@ trace_context_draw_range_elements(struct pipe_context *_pipe,
 
    trace_dump_call_end();
 
+   trace_context_draw_block(tr_ctx, 2);
+
    return result;
 }
 
@@ -573,23 +653,32 @@ trace_context_create_fs_state(struct pipe_context *_pipe,
 
    trace_dump_call_end();
 
+   result = trace_shader_create(tr_ctx, state, result, TRACE_SHADER_FRAGMENT);
+
    return result;
 }
 
 
 static INLINE void
 trace_context_bind_fs_state(struct pipe_context *_pipe,
-                            void *state)
+                            void *_state)
 {
    struct trace_context *tr_ctx = trace_context(_pipe);
+   struct trace_shader *tr_shdr = trace_shader(_state);
    struct pipe_context *pipe = tr_ctx->pipe;
+   void *state = tr_shdr ? tr_shdr->state : NULL;
 
    trace_dump_call_begin("pipe_context", "bind_fs_state");
 
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(ptr, state);
 
-   pipe->bind_fs_state(pipe, state);;
+   tr_ctx->curr.fs = tr_shdr;
+
+   if (tr_shdr && tr_shdr->replaced)
+      state = tr_shdr->replaced;
+
+   pipe->bind_fs_state(pipe, state);
 
    trace_dump_call_end();
 }
@@ -597,19 +686,23 @@ trace_context_bind_fs_state(struct pipe_context *_pipe,
 
 static INLINE void
 trace_context_delete_fs_state(struct pipe_context *_pipe,
-                              void *state)
+                              void *_state)
 {
    struct trace_context *tr_ctx = trace_context(_pipe);
+   struct trace_shader *tr_shdr = trace_shader(_state);
    struct pipe_context *pipe = tr_ctx->pipe;
+   void *state = tr_shdr->state;
 
    trace_dump_call_begin("pipe_context", "delete_fs_state");
 
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(ptr, state);
 
-   pipe->delete_fs_state(pipe, state);;
+   pipe->delete_fs_state(pipe, state);
 
    trace_dump_call_end();
+
+   trace_shader_destroy(tr_ctx, tr_shdr);
 }
 
 
@@ -626,28 +719,37 @@ trace_context_create_vs_state(struct pipe_context *_pipe,
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(shader_state, state);
 
-   result = pipe->create_vs_state(pipe, state);;
+   result = pipe->create_vs_state(pipe, state);
 
    trace_dump_ret(ptr, result);
 
    trace_dump_call_end();
 
+   result = trace_shader_create(tr_ctx, state, result, TRACE_SHADER_VERTEX);
+
    return result;
 }
 
 
 static INLINE void
 trace_context_bind_vs_state(struct pipe_context *_pipe,
-                            void *state)
+                            void *_state)
 {
    struct trace_context *tr_ctx = trace_context(_pipe);
+   struct trace_shader *tr_shdr = trace_shader(_state);
    struct pipe_context *pipe = tr_ctx->pipe;
+   void *state = tr_shdr ? tr_shdr->state : NULL;
 
    trace_dump_call_begin("pipe_context", "bind_vs_state");
 
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(ptr, state);
 
+   tr_ctx->curr.vs = tr_shdr;
+
+   if (tr_shdr && tr_shdr->replaced)
+      state = tr_shdr->replaced;
+
    pipe->bind_vs_state(pipe, state);;
 
    trace_dump_call_end();
@@ -656,10 +758,12 @@ trace_context_bind_vs_state(struct pipe_context *_pipe,
 
 static INLINE void
 trace_context_delete_vs_state(struct pipe_context *_pipe,
-                              void *state)
+                              void *_state)
 {
    struct trace_context *tr_ctx = trace_context(_pipe);
+   struct trace_shader *tr_shdr = trace_shader(_state);
    struct pipe_context *pipe = tr_ctx->pipe;
+   void *state = tr_shdr->state;
 
    trace_dump_call_begin("pipe_context", "delete_vs_state");
 
@@ -669,6 +773,8 @@ trace_context_delete_vs_state(struct pipe_context *_pipe,
    pipe->delete_vs_state(pipe, state);;
 
    trace_dump_call_end();
+
+   trace_shader_destroy(tr_ctx, tr_shdr);
 }
 
 
@@ -747,6 +853,19 @@ trace_context_set_framebuffer_state(struct pipe_context *_pipe,
    struct pipe_framebuffer_state unwrapped_state;
    unsigned i;
 
+   {
+      tr_ctx->curr.nr_cbufs = state->nr_cbufs;
+      for (i = 0; i < state->nr_cbufs; i++)
+         if (state->cbufs[i])
+            tr_ctx->curr.cbufs[i] = trace_texture(state->cbufs[i]->texture);
+         else
+            tr_ctx->curr.cbufs[i] = NULL;
+      if (state->zsbuf)
+         tr_ctx->curr.zsbuf = trace_texture(state->zsbuf->texture);
+      else
+         tr_ctx->curr.zsbuf = NULL;
+   }
+
    /* Unwrap the input state */
    memcpy(&unwrapped_state, state, sizeof(unwrapped_state));
    for(i = 0; i < state->nr_cbufs; ++i)
@@ -827,12 +946,17 @@ trace_context_set_sampler_textures(struct pipe_context *_pipe,
                                    struct pipe_texture **textures)
 {
    struct trace_context *tr_ctx = trace_context(_pipe);
+   struct trace_texture *tr_tex;
    struct pipe_context *pipe = tr_ctx->pipe;
    struct pipe_texture *unwrapped_textures[PIPE_MAX_SAMPLERS];
    unsigned i;
 
-   for(i = 0; i < num_textures; ++i)
-      unwrapped_textures[i] = trace_texture_unwrap(tr_ctx, textures[i]);
+   tr_ctx->curr.num_texs = num_textures;
+   for(i = 0; i < num_textures; ++i) {
+      tr_tex = trace_texture(textures[i]);
+      tr_ctx->curr.tex[i] = tr_tex;
+      unwrapped_textures[i] = tr_tex ? tr_tex->texture : NULL;
+   }
    textures = unwrapped_textures;
 
    trace_dump_call_begin("pipe_context", "set_sampler_textures");
@@ -1078,6 +1202,12 @@ trace_is_buffer_referenced( struct pipe_context *_pipe,
    return referenced;
 }
 
+static const struct debug_named_value rbug_blocker_flags[] = {
+   {"before", 1},
+   {"after", 2},
+   {NULL, 0},
+};
+
 struct pipe_context *
 trace_context_create(struct pipe_screen *_screen,
                      struct pipe_context *pipe)
@@ -1089,7 +1219,7 @@ trace_context_create(struct pipe_screen *_screen,
    if(!pipe)
       goto error1;
 
-   if(!trace_dump_trace_enabled())
+   if(!trace_enabled())
       goto error1;
 
    tr_scr = trace_screen(_screen);
@@ -1099,6 +1229,14 @@ trace_context_create(struct pipe_screen *_screen,
    if(!tr_ctx)
       goto error1;
 
+   tr_ctx->draw_blocker = debug_get_flags_option("RBUG_BLOCK",
+                                                 rbug_blocker_flags,
+                                                 0);
+   pipe_mutex_init(tr_ctx->draw_mutex);
+   pipe_condvar_init(tr_ctx->draw_cond);
+   pipe_mutex_init(tr_ctx->list_mutex);
+   make_empty_list(&tr_ctx->shaders);
+
    tr_ctx->base.winsys = _screen->winsys;
    tr_ctx->base.screen = _screen;
    tr_ctx->base.destroy = trace_context_destroy;
index 2512a0a2328221f0eb61ef93f4255da859984a2f..6febe4b41143b9a0cc78d7a74bc864a9ce4e71f4 100644 (file)
@@ -33,6 +33,7 @@
 #include "util/u_debug.h"
 #include "pipe/p_context.h"
 
+#include "tr_screen.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -45,7 +46,41 @@ struct trace_context
 
    struct pipe_context *pipe;
 
+   /* current state */
+   struct {
+      struct trace_shader *fs;
+      struct trace_shader *vs;
+
+      struct trace_texture *tex[PIPE_MAX_SAMPLERS];
+      unsigned num_texs;
+
+      unsigned nr_cbufs;
+      struct trace_texture *cbufs[PIPE_MAX_COLOR_BUFS];
+      struct trace_texture *zsbuf;
+   } curr;
+
+   struct {
+      struct trace_shader *fs;
+      struct trace_shader *vs;
+
+      struct trace_texture *tex;
+      struct trace_texture *surf;
+
+      int blocker;
+   } draw_rule;
+   unsigned draw_num_rules;
+   pipe_condvar draw_cond;
+   pipe_mutex draw_mutex;
+   int draw_blocker;
+   int draw_blocked;
+
+   /* for list on screen */
    struct tr_list list;
+
+   /* list of state objects */
+   pipe_mutex list_mutex;
+   unsigned num_shaders;
+   struct tr_list shaders;
 };
 
 
@@ -62,6 +97,9 @@ struct pipe_context *
 trace_context_create(struct pipe_screen *screen,
                      struct pipe_context *pipe);
 
+void
+trace_rbug_notify_draw_blocked(struct trace_context *tr_ctx);
+
 
 #ifdef __cplusplus
 }
diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c
new file mode 100644 (file)
index 0000000..23a2473
--- /dev/null
@@ -0,0 +1,490 @@
+/**************************************************************************
+ *
+ * Copyright 2008 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 "pipe/p_compiler.h"
+#include "util/u_memory.h"
+#include "tgsi/tgsi_dump.h"
+
+#include "tr_dump.h"
+#include "tr_dump_state.h"
+
+
+void trace_dump_format(enum pipe_format format)
+{
+   trace_dump_enum(pf_name(format) );
+}
+
+
+void trace_dump_block(const struct pipe_format_block *block)
+{
+   trace_dump_struct_begin("pipe_format_block");
+   trace_dump_member(uint, block, size);
+   trace_dump_member(uint, block, width);
+   trace_dump_member(uint, block, height);
+   trace_dump_struct_end();
+}
+
+
+static void trace_dump_reference(const struct pipe_reference *reference)
+{
+   trace_dump_struct_begin("pipe_reference");
+   trace_dump_member(int, &reference->count, count);
+   trace_dump_struct_end();
+}
+
+
+void trace_dump_template(const struct pipe_texture *templat)
+{
+   if(!templat) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_texture");
+
+   trace_dump_member(int, templat, target);
+   trace_dump_member(format, templat, format);
+
+   trace_dump_member_begin("width");
+   trace_dump_array(uint, templat->width, 1);
+   trace_dump_member_end();
+
+   trace_dump_member_begin("height");
+   trace_dump_array(uint, templat->height, 1);
+   trace_dump_member_end();
+
+   trace_dump_member_begin("depth");
+   trace_dump_array(uint, templat->depth, 1);
+   trace_dump_member_end();
+
+   trace_dump_member_begin("block");
+   trace_dump_block(&templat->block);
+   trace_dump_member_end();
+
+   trace_dump_member(uint, templat, last_level);
+   trace_dump_member(uint, templat, tex_usage);
+
+   trace_dump_struct_end();
+}
+
+
+void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state)
+{
+   if(!state) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_rasterizer_state");
+
+   trace_dump_member(bool, state, flatshade);
+   trace_dump_member(bool, state, light_twoside);
+   trace_dump_member(uint, state, front_winding);
+   trace_dump_member(uint, state, cull_mode);
+   trace_dump_member(uint, state, fill_cw);
+   trace_dump_member(uint, state, fill_ccw);
+   trace_dump_member(bool, state, offset_cw);
+   trace_dump_member(bool, state, offset_ccw);
+   trace_dump_member(bool, state, scissor);
+   trace_dump_member(bool, state, poly_smooth);
+   trace_dump_member(bool, state, poly_stipple_enable);
+   trace_dump_member(bool, state, point_smooth);
+   trace_dump_member(bool, state, point_sprite);
+   trace_dump_member(bool, state, point_size_per_vertex);
+   trace_dump_member(bool, state, multisample);
+   trace_dump_member(bool, state, line_smooth);
+   trace_dump_member(bool, state, line_stipple_enable);
+   trace_dump_member(uint, state, line_stipple_factor);
+   trace_dump_member(uint, state, line_stipple_pattern);
+   trace_dump_member(bool, state, line_last_pixel);
+   trace_dump_member(bool, state, bypass_vs_clip_and_viewport);
+   trace_dump_member(bool, state, flatshade_first);
+   trace_dump_member(bool, state, gl_rasterization_rules);
+
+   trace_dump_member(float, state, line_width);
+   trace_dump_member(float, state, point_size);
+   trace_dump_member(float, state, point_size_min);
+   trace_dump_member(float, state, point_size_max);
+   trace_dump_member(float, state, offset_units);
+   trace_dump_member(float, state, offset_scale);
+
+   trace_dump_member_array(uint, state, sprite_coord_mode);
+
+   trace_dump_struct_end();
+}
+
+
+void trace_dump_poly_stipple(const struct pipe_poly_stipple *state)
+{
+   if(!state) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_poly_stipple");
+
+   trace_dump_member_begin("stipple");
+   trace_dump_array(uint,
+                    state->stipple,
+                    Elements(state->stipple));
+   trace_dump_member_end();
+
+   trace_dump_struct_end();
+}
+
+
+void trace_dump_viewport_state(const struct pipe_viewport_state *state)
+{
+   if(!state) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_viewport_state");
+
+   trace_dump_member_array(float, state, scale);
+   trace_dump_member_array(float, state, translate);
+
+   trace_dump_struct_end();
+}
+
+
+void trace_dump_scissor_state(const struct pipe_scissor_state *state)
+{
+   if(!state) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_scissor_state");
+
+   trace_dump_member(uint, state, minx);
+   trace_dump_member(uint, state, miny);
+   trace_dump_member(uint, state, maxx);
+   trace_dump_member(uint, state, maxy);
+
+   trace_dump_struct_end();
+}
+
+
+void trace_dump_clip_state(const struct pipe_clip_state *state)
+{
+   unsigned i;
+
+   if(!state) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_clip_state");
+
+   trace_dump_member_begin("ucp");
+   trace_dump_array_begin();
+   for(i = 0; i < PIPE_MAX_CLIP_PLANES; ++i) {
+      trace_dump_elem_begin();
+      trace_dump_array(float, state->ucp[i], 4);
+      trace_dump_elem_end();
+   }
+   trace_dump_array_end();
+   trace_dump_member_end();
+
+   trace_dump_member(uint, state, nr);
+
+   trace_dump_struct_end();
+}
+
+
+void trace_dump_constant_buffer(const struct pipe_constant_buffer *state)
+{
+   if(!state) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_constant_buffer");
+
+   trace_dump_member(buffer_ptr, state, buffer);
+
+   trace_dump_struct_end();
+}
+
+
+void trace_dump_shader_state(const struct pipe_shader_state *state)
+{
+   static char str[8192];
+
+   if(!state) {
+      trace_dump_null();
+      return;
+   }
+
+   tgsi_dump_str(state->tokens, 0, str, sizeof(str));
+
+   trace_dump_struct_begin("pipe_shader_state");
+
+   trace_dump_member_begin("tokens");
+   trace_dump_string(str);
+   trace_dump_member_end();
+
+   trace_dump_struct_end();
+}
+
+
+void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state)
+{
+   unsigned i;
+
+   if(!state) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_depth_stencil_alpha_state");
+
+   trace_dump_member_begin("depth");
+   trace_dump_struct_begin("pipe_depth_state");
+   trace_dump_member(bool, &state->depth, enabled);
+   trace_dump_member(bool, &state->depth, writemask);
+   trace_dump_member(uint, &state->depth, func);
+   trace_dump_struct_end();
+   trace_dump_member_end();
+
+   trace_dump_member_begin("stencil");
+   trace_dump_array_begin();
+   for(i = 0; i < Elements(state->stencil); ++i) {
+      trace_dump_elem_begin();
+      trace_dump_struct_begin("pipe_stencil_state");
+      trace_dump_member(bool, &state->stencil[i], enabled);
+      trace_dump_member(uint, &state->stencil[i], func);
+      trace_dump_member(uint, &state->stencil[i], fail_op);
+      trace_dump_member(uint, &state->stencil[i], zpass_op);
+      trace_dump_member(uint, &state->stencil[i], zfail_op);
+      trace_dump_member(uint, &state->stencil[i], ref_value);
+      trace_dump_member(uint, &state->stencil[i], valuemask);
+      trace_dump_member(uint, &state->stencil[i], writemask);
+      trace_dump_struct_end();
+      trace_dump_elem_end();
+   }
+   trace_dump_array_end();
+   trace_dump_member_end();
+
+   trace_dump_member_begin("alpha");
+   trace_dump_struct_begin("pipe_alpha_state");
+   trace_dump_member(bool, &state->alpha, enabled);
+   trace_dump_member(uint, &state->alpha, func);
+   trace_dump_member(float, &state->alpha, ref_value);
+   trace_dump_struct_end();
+   trace_dump_member_end();
+
+   trace_dump_struct_end();
+}
+
+
+void trace_dump_blend_state(const struct pipe_blend_state *state)
+{
+   if(!state) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_blend_state");
+
+   trace_dump_member(bool, state, blend_enable);
+
+   trace_dump_member(uint, state, rgb_func);
+   trace_dump_member(uint, state, rgb_src_factor);
+   trace_dump_member(uint, state, rgb_dst_factor);
+
+   trace_dump_member(uint, state, alpha_func);
+   trace_dump_member(uint, state, alpha_src_factor);
+   trace_dump_member(uint, state, alpha_dst_factor);
+
+   trace_dump_member(bool, state, logicop_enable);
+   trace_dump_member(uint, state, logicop_func);
+
+   trace_dump_member(uint, state, colormask);
+   trace_dump_member(bool, state, dither);
+
+   trace_dump_struct_end();
+}
+
+
+void trace_dump_blend_color(const struct pipe_blend_color *state)
+{
+   if(!state) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_blend_color");
+
+   trace_dump_member_array(float, state, color);
+
+   trace_dump_struct_end();
+}
+
+
+void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state)
+{
+   trace_dump_struct_begin("pipe_framebuffer_state");
+
+   trace_dump_member(uint, state, width);
+   trace_dump_member(uint, state, height);
+   trace_dump_member(uint, state, nr_cbufs);
+   trace_dump_member_array(ptr, state, cbufs);
+   trace_dump_member(ptr, state, zsbuf);
+
+   trace_dump_struct_end();
+}
+
+
+void trace_dump_sampler_state(const struct pipe_sampler_state *state)
+{
+   if(!state) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_sampler_state");
+
+   trace_dump_member(uint, state, wrap_s);
+   trace_dump_member(uint, state, wrap_t);
+   trace_dump_member(uint, state, wrap_r);
+   trace_dump_member(uint, state, min_img_filter);
+   trace_dump_member(uint, state, min_mip_filter);
+   trace_dump_member(uint, state, mag_img_filter);
+   trace_dump_member(bool, state, compare_mode);
+   trace_dump_member(uint, state, compare_func);
+   trace_dump_member(bool, state, normalized_coords);
+   trace_dump_member(uint, state, prefilter);
+   trace_dump_member(float, state, shadow_ambient);
+   trace_dump_member(float, state, lod_bias);
+   trace_dump_member(float, state, min_lod);
+   trace_dump_member(float, state, max_lod);
+   trace_dump_member_array(float, state, border_color);
+   trace_dump_member(float, state, max_anisotropy);
+
+   trace_dump_struct_end();
+}
+
+
+void trace_dump_surface(const struct pipe_surface *state)
+{
+   if(!state) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_surface");
+
+   trace_dump_reference(&state->reference);
+
+   trace_dump_member(format, state, format);
+   trace_dump_member(uint, state, width);
+   trace_dump_member(uint, state, height);
+
+   trace_dump_member(uint, state, layout);
+   trace_dump_member(uint, state, offset);
+   trace_dump_member(uint, state, usage);
+
+   trace_dump_member(ptr, state, texture);
+   trace_dump_member(uint, state, face);
+   trace_dump_member(uint, state, level);
+   trace_dump_member(uint, state, zslice);
+
+   trace_dump_struct_end();
+}
+
+
+void trace_dump_transfer(const struct pipe_transfer *state)
+{
+   if(!state) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_transfer");
+
+   trace_dump_member(format, state, format);
+   trace_dump_member(uint, state, width);
+   trace_dump_member(uint, state, height);
+
+   trace_dump_member_begin("block");
+   trace_dump_block(&state->block);
+   trace_dump_member_end();
+
+   trace_dump_member(uint, state, nblocksx);
+   trace_dump_member(uint, state, nblocksy);
+   trace_dump_member(uint, state, stride);
+   trace_dump_member(uint, state, usage);
+
+   trace_dump_member(ptr, state, texture);
+   trace_dump_member(uint, state, face);
+   trace_dump_member(uint, state, level);
+   trace_dump_member(uint, state, zslice);
+
+   trace_dump_struct_end();
+}
+
+
+void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state)
+{
+   if(!state) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_vertex_buffer");
+
+   trace_dump_member(uint, state, stride);
+   trace_dump_member(uint, state, max_index);
+   trace_dump_member(uint, state, buffer_offset);
+   trace_dump_member(buffer_ptr, state, buffer);
+
+   trace_dump_struct_end();
+}
+
+
+void trace_dump_vertex_element(const struct pipe_vertex_element *state)
+{
+   if(!state) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_vertex_element");
+
+   trace_dump_member(uint, state, src_offset);
+
+   trace_dump_member(uint, state, vertex_buffer_index);
+   trace_dump_member(uint, state, nr_components);
+
+   trace_dump_member(format, state, src_format);
+
+   trace_dump_struct_end();
+}
diff --git a/src/gallium/drivers/trace/tr_dump_state.h b/src/gallium/drivers/trace/tr_dump_state.h
new file mode 100644 (file)
index 0000000..05b821a
--- /dev/null
@@ -0,0 +1,78 @@
+/**************************************************************************
+ *
+ * Copyright 2008 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 TR_DUMP_STATE_H_
+#define TR_DUMP_STATE_H_
+
+#include "pipe/p_format.h"
+#include "pipe/p_state.h"
+#include "pipe/p_shader_tokens.h"
+
+
+void trace_dump_format(enum pipe_format format);
+
+void trace_dump_block(const struct pipe_format_block *block);
+
+void trace_dump_template(const struct pipe_texture *templat);
+
+
+void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state);
+
+void trace_dump_poly_stipple(const struct pipe_poly_stipple *state);
+
+void trace_dump_viewport_state(const struct pipe_viewport_state *state);
+
+void trace_dump_scissor_state(const struct pipe_scissor_state *state);
+
+void trace_dump_clip_state(const struct pipe_clip_state *state);
+
+void trace_dump_constant_buffer(const struct pipe_constant_buffer *state);
+
+void trace_dump_token(const struct tgsi_token *token);
+
+void trace_dump_shader_state(const struct pipe_shader_state *state);
+
+void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state);
+
+void trace_dump_blend_state(const struct pipe_blend_state *state);
+
+void trace_dump_blend_color(const struct pipe_blend_color *state);
+
+void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state);
+
+void trace_dump_sampler_state(const struct pipe_sampler_state *state);
+
+void trace_dump_surface(const struct pipe_surface *state);
+
+void trace_dump_transfer(const struct pipe_transfer *state);
+
+void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state);
+
+void trace_dump_vertex_element(const struct pipe_vertex_element *state);
+
+
+#endif /* TR_STATE_H */
diff --git a/src/gallium/drivers/trace/tr_rbug.c b/src/gallium/drivers/trace/tr_rbug.c
new file mode 100644 (file)
index 0000000..e85ac15
--- /dev/null
@@ -0,0 +1,864 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL 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 "util/u_string.h"
+#include "util/u_memory.h"
+#include "util/u_simple_list.h"
+#include "util/u_network.h"
+
+#include "tgsi/tgsi_parse.h"
+
+#include "tr_dump.h"
+#include "tr_state.h"
+#include "tr_buffer.h"
+#include "tr_texture.h"
+
+#include "rbug/rbug.h"
+
+#include <errno.h>
+
+#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+#  define sleep Sleep
+#elif defined(PIPE_OS_LINUX)
+void usleep(int);
+#  define sleep usleep
+#else
+#  warning "No socket implementation"
+#endif
+
+#define U642VOID(x) ((void *)(unsigned long)(x))
+#define VOID2U64(x) ((uint64_t)(unsigned long)(x))
+
+struct trace_rbug
+{
+   struct trace_screen *tr_scr;
+   struct rbug_connection *con;
+   pipe_thread thread;
+   boolean running;
+};
+
+PIPE_THREAD_ROUTINE(trace_rbug_thread, void_tr_rbug);
+
+
+/**********************************************************
+ * Helper functions
+ */
+
+
+static struct trace_context *
+trace_rbug_get_context_locked(struct trace_screen *tr_scr, rbug_context_t ctx)
+{
+   struct trace_context *tr_ctx = NULL;
+   struct tr_list *ptr;
+
+   foreach(ptr, &tr_scr->contexts) {
+      tr_ctx = (struct trace_context *)((char*)ptr - offsetof(struct trace_context, list));
+      if (ctx == VOID2U64(tr_ctx))
+         break;
+      tr_ctx = NULL;
+   }
+
+   return tr_ctx;
+}
+
+static struct trace_shader *
+trace_rbug_get_shader_locked(struct trace_context *tr_ctx, rbug_shader_t shdr)
+{
+   struct trace_shader *tr_shdr = NULL;
+   struct tr_list *ptr;
+
+   foreach(ptr, &tr_ctx->shaders) {
+      tr_shdr = (struct trace_shader *)((char*)ptr - offsetof(struct trace_shader, list));
+      if (shdr == VOID2U64(tr_shdr))
+         break;
+      tr_shdr = NULL;
+   }
+
+   return tr_shdr;
+}
+
+static void *
+trace_shader_create_locked(struct pipe_context *pipe,
+                           struct trace_shader *tr_shdr,
+                           struct tgsi_token *tokens)
+{
+   void *state = NULL;
+   struct pipe_shader_state pss = { 0 };
+   pss.tokens = tokens;
+
+   if (tr_shdr->type == TRACE_SHADER_FRAGMENT) {
+      state = pipe->create_fs_state(pipe, &pss);
+   } else if (tr_shdr->type == TRACE_SHADER_VERTEX) {
+      state = pipe->create_vs_state(pipe, &pss);
+   } else
+      assert(0);
+
+   return state;
+}
+
+static void
+trace_shader_bind_locked(struct pipe_context *pipe,
+                         struct trace_shader *tr_shdr,
+                         void *state)
+{
+   if (tr_shdr->type == TRACE_SHADER_FRAGMENT) {
+      pipe->bind_fs_state(pipe, state);
+   } else if (tr_shdr->type == TRACE_SHADER_VERTEX) {
+      pipe->bind_vs_state(pipe, state);
+   } else
+      assert(0);
+}
+
+static void
+trace_shader_delete_locked(struct pipe_context *pipe,
+                           struct trace_shader *tr_shdr,
+                           void *state)
+{
+   if (tr_shdr->type == TRACE_SHADER_FRAGMENT) {
+      pipe->delete_fs_state(pipe, state);
+   } else if (tr_shdr->type == TRACE_SHADER_VERTEX) {
+      pipe->delete_vs_state(pipe, state);
+   } else
+      assert(0);
+}
+
+/************************************************
+ * Request handler functions
+ */
+
+
+static int
+trace_rbug_texture_list(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial)
+{
+   struct trace_screen *tr_scr = tr_rbug->tr_scr;
+   struct trace_texture *tr_tex = NULL;
+   struct tr_list *ptr;
+   rbug_texture_t *texs;
+   int i = 0;
+
+   pipe_mutex_lock(tr_scr->list_mutex);
+   texs = MALLOC(tr_scr->num_textures * sizeof(rbug_texture_t));
+   foreach(ptr, &tr_scr->textures) {
+      tr_tex = (struct trace_texture *)((char*)ptr - offsetof(struct trace_texture, list));
+      texs[i++] = VOID2U64(tr_tex);
+   }
+   pipe_mutex_unlock(tr_scr->list_mutex);
+
+   rbug_send_texture_list_reply(tr_rbug->con, serial, texs, i, NULL);
+   FREE(texs);
+
+   return 0;
+}
+
+static int
+trace_rbug_texture_info(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial)
+{
+   struct trace_screen *tr_scr = tr_rbug->tr_scr;
+   struct trace_texture *tr_tex;
+   struct rbug_proto_texture_info *gpti = (struct rbug_proto_texture_info *)header;
+   struct tr_list *ptr;
+   struct pipe_texture *t;
+
+   pipe_mutex_lock(tr_scr->list_mutex);
+   foreach(ptr, &tr_scr->textures) {
+      tr_tex = (struct trace_texture *)((char*)ptr - offsetof(struct trace_texture, list));
+      if (gpti->texture == VOID2U64(tr_tex))
+         break;
+      tr_tex = NULL;
+   }
+
+   if (!tr_tex) {
+      pipe_mutex_unlock(tr_scr->list_mutex);
+      return -ESRCH;
+   }
+
+   t = tr_tex->texture;
+   rbug_send_texture_info_reply(tr_rbug->con, serial,
+                               t->target, t->format,
+                               t->width, t->last_level + 1,
+                               t->height, t->last_level + 1,
+                               t->depth, t->last_level + 1,
+                               t->block.width, t->block.height, t->block.size,
+                               t->last_level,
+                               t->nr_samples,
+                               t->tex_usage,
+                               NULL);
+
+   pipe_mutex_unlock(tr_scr->list_mutex);
+
+   return 0;
+}
+
+static int
+trace_rbug_texture_read(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial)
+{
+   struct rbug_proto_texture_read *gptr = (struct rbug_proto_texture_read *)header;
+
+   struct trace_screen *tr_scr = tr_rbug->tr_scr;
+   struct trace_texture *tr_tex;
+   struct tr_list *ptr;
+
+   struct pipe_screen *screen = tr_scr->screen;
+   struct pipe_texture *tex;
+   struct pipe_transfer *t;
+
+   void *map;
+
+   pipe_mutex_lock(tr_scr->list_mutex);
+   foreach(ptr, &tr_scr->textures) {
+      tr_tex = (struct trace_texture *)((char*)ptr - offsetof(struct trace_texture, list));
+      if (gptr->texture == VOID2U64(tr_tex))
+         break;
+      tr_tex = NULL;
+   }
+
+   if (!tr_tex) {
+      pipe_mutex_unlock(tr_scr->list_mutex);
+      return -ESRCH;
+   }
+
+   tex = tr_tex->texture;
+   t = screen->get_tex_transfer(tr_scr->screen, tex,
+                                gptr->face, gptr->level, gptr->zslice,
+                                PIPE_TRANSFER_READ,
+                                gptr->x, gptr->y, gptr->w, gptr->h);
+
+   map = screen->transfer_map(screen, t);
+
+   rbug_send_texture_read_reply(tr_rbug->con, serial,
+                                t->format,
+                                t->block.width, t->block.height, t->block.size,
+                                (uint8_t*)map, t->stride * t->nblocksy,
+                                t->stride,
+                                NULL);
+
+   screen->transfer_unmap(screen, t);
+   screen->tex_transfer_destroy(t);
+
+   pipe_mutex_unlock(tr_scr->list_mutex);
+
+   return 0;
+}
+
+static int
+trace_rbug_context_list(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial)
+{
+   struct trace_screen *tr_scr = tr_rbug->tr_scr;
+   struct tr_list *ptr;
+   struct trace_context *tr_ctx = NULL;
+   rbug_context_t *ctxs;
+   int i = 0;
+
+   pipe_mutex_lock(tr_scr->list_mutex);
+   ctxs = MALLOC(tr_scr->num_contexts * sizeof(rbug_context_t));
+   foreach(ptr, &tr_scr->contexts) {
+      tr_ctx = (struct trace_context *)((char*)ptr - offsetof(struct trace_context, list));
+      ctxs[i++] = VOID2U64(tr_ctx);
+   }
+   pipe_mutex_unlock(tr_scr->list_mutex);
+
+   rbug_send_context_list_reply(tr_rbug->con, serial, ctxs, i, NULL);
+   FREE(ctxs);
+
+   return 0;
+}
+
+static int
+trace_rbug_context_info(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial)
+{
+   struct rbug_proto_context_info *info = (struct rbug_proto_context_info *)header;
+
+   struct trace_screen *tr_scr = tr_rbug->tr_scr;
+   struct trace_context *tr_ctx = NULL;
+   rbug_texture_t cbufs[PIPE_MAX_COLOR_BUFS];
+   rbug_texture_t texs[PIPE_MAX_SAMPLERS];
+   int i;
+
+   pipe_mutex_lock(tr_scr->list_mutex);
+   tr_ctx = trace_rbug_get_context_locked(tr_scr, info->context);
+
+   if (!tr_ctx) {
+      pipe_mutex_unlock(tr_scr->list_mutex);
+      return -ESRCH;
+   }
+
+   /* protect the pipe context */
+   pipe_mutex_lock(tr_ctx->draw_mutex);
+   trace_dump_call_lock();
+
+   for (i = 0; i < tr_ctx->curr.nr_cbufs; i++)
+      cbufs[i] = VOID2U64(tr_ctx->curr.cbufs[i]);
+
+   for (i = 0; i < tr_ctx->curr.num_texs; i++)
+      texs[i] = VOID2U64(tr_ctx->curr.tex[i]);
+
+   rbug_send_context_info_reply(tr_rbug->con, serial,
+                                VOID2U64(tr_ctx->curr.vs), VOID2U64(tr_ctx->curr.fs),
+                                texs, tr_ctx->curr.num_texs,
+                                cbufs, tr_ctx->curr.nr_cbufs,
+                                VOID2U64(tr_ctx->curr.zsbuf),
+                                tr_ctx->draw_blocker, tr_ctx->draw_blocked, NULL);
+
+   trace_dump_call_unlock();
+   pipe_mutex_unlock(tr_ctx->draw_mutex);
+
+   pipe_mutex_unlock(tr_scr->list_mutex);
+
+   return 0;
+}
+
+static int
+trace_rbug_context_draw_block(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial)
+{
+   struct rbug_proto_context_draw_block *block = (struct rbug_proto_context_draw_block *)header;
+
+   struct trace_screen *tr_scr = tr_rbug->tr_scr;
+   struct trace_context *tr_ctx = NULL;
+
+   pipe_mutex_lock(tr_scr->list_mutex);
+   tr_ctx = trace_rbug_get_context_locked(tr_scr, block->context);
+
+   if (!tr_ctx) {
+      pipe_mutex_unlock(tr_scr->list_mutex);
+      return -ESRCH;
+   }
+
+   pipe_mutex_lock(tr_ctx->draw_mutex);
+   tr_ctx->draw_blocker |= block->block;
+   pipe_mutex_unlock(tr_ctx->draw_mutex);
+
+   pipe_mutex_unlock(tr_scr->list_mutex);
+
+   return 0;
+}
+
+static int
+trace_rbug_context_draw_step(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial)
+{
+   struct rbug_proto_context_draw_step *step = (struct rbug_proto_context_draw_step *)header;
+
+   struct trace_screen *tr_scr = tr_rbug->tr_scr;
+   struct trace_context *tr_ctx = NULL;
+
+   pipe_mutex_lock(tr_scr->list_mutex);
+   tr_ctx = trace_rbug_get_context_locked(tr_scr, step->context);
+
+   if (!tr_ctx) {
+      pipe_mutex_unlock(tr_scr->list_mutex);
+      return -ESRCH;
+   }
+
+   pipe_mutex_lock(tr_ctx->draw_mutex);
+   if (tr_ctx->draw_blocked & RBUG_BLOCK_RULE) {
+      if (step->step & RBUG_BLOCK_RULE)
+         tr_ctx->draw_blocked &= ~RBUG_BLOCK_MASK;
+   } else {
+      tr_ctx->draw_blocked &= ~step->step;
+   }
+   pipe_mutex_unlock(tr_ctx->draw_mutex);
+
+#ifdef PIPE_THREAD_HAVE_CONDVAR
+   pipe_condvar_broadcast(tr_ctx->draw_cond);
+#endif
+
+   pipe_mutex_unlock(tr_scr->list_mutex);
+
+   return 0;
+}
+
+static int
+trace_rbug_context_draw_unblock(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial)
+{
+   struct rbug_proto_context_draw_unblock *unblock = (struct rbug_proto_context_draw_unblock *)header;
+
+   struct trace_screen *tr_scr = tr_rbug->tr_scr;
+   struct trace_context *tr_ctx = NULL;
+
+   pipe_mutex_lock(tr_scr->list_mutex);
+   tr_ctx = trace_rbug_get_context_locked(tr_scr, unblock->context);
+
+   if (!tr_ctx) {
+      pipe_mutex_unlock(tr_scr->list_mutex);
+      return -ESRCH;
+   }
+
+   pipe_mutex_lock(tr_ctx->draw_mutex);
+   if (tr_ctx->draw_blocked & RBUG_BLOCK_RULE) {
+      if (unblock->unblock & RBUG_BLOCK_RULE)
+         tr_ctx->draw_blocked &= ~RBUG_BLOCK_MASK;
+   } else {
+      tr_ctx->draw_blocked &= ~unblock->unblock;
+   }
+   tr_ctx->draw_blocker &= ~unblock->unblock;
+   pipe_mutex_unlock(tr_ctx->draw_mutex);
+
+#ifdef PIPE_THREAD_HAVE_CONDVAR
+   pipe_condvar_broadcast(tr_ctx->draw_cond);
+#endif
+
+   pipe_mutex_unlock(tr_scr->list_mutex);
+
+   return 0;
+}
+
+static int
+trace_rbug_context_draw_rule(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial)
+{
+   struct rbug_proto_context_draw_rule *rule = (struct rbug_proto_context_draw_rule *)header;
+
+   struct trace_screen *tr_scr = tr_rbug->tr_scr;
+   struct trace_context *tr_ctx = NULL;
+
+   pipe_mutex_lock(tr_scr->list_mutex);
+   tr_ctx = trace_rbug_get_context_locked(tr_scr, rule->context);
+
+   if (!tr_ctx) {
+      pipe_mutex_unlock(tr_scr->list_mutex);
+      return -ESRCH;
+   }
+
+   pipe_mutex_lock(tr_ctx->draw_mutex);
+   tr_ctx->draw_rule.vs = U642VOID(rule->vertex);
+   tr_ctx->draw_rule.fs = U642VOID(rule->fragment);
+   tr_ctx->draw_rule.tex = U642VOID(rule->texture);
+   tr_ctx->draw_rule.surf = U642VOID(rule->surface);
+   tr_ctx->draw_rule.blocker = rule->block;
+   tr_ctx->draw_blocker |= RBUG_BLOCK_RULE;
+   pipe_mutex_unlock(tr_ctx->draw_mutex);
+
+#ifdef PIPE_THREAD_HAVE_CONDVAR
+   pipe_condvar_broadcast(tr_ctx->draw_cond);
+#endif
+
+   pipe_mutex_unlock(tr_scr->list_mutex);
+
+   return 0;
+}
+
+static int
+trace_rbug_context_flush(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial)
+{
+   struct rbug_proto_context_flush *flush = (struct rbug_proto_context_flush *)header;
+
+   struct trace_screen *tr_scr = tr_rbug->tr_scr;
+   struct trace_context *tr_ctx = NULL;
+
+   pipe_mutex_lock(tr_scr->list_mutex);
+   tr_ctx = trace_rbug_get_context_locked(tr_scr, flush->context);
+
+   if (!tr_ctx) {
+      pipe_mutex_unlock(tr_scr->list_mutex);
+      return -ESRCH;
+   }
+
+   /* protect the pipe context */
+   trace_dump_call_lock();
+
+   tr_ctx->pipe->flush(tr_ctx->pipe, flush->flags, NULL);
+
+   trace_dump_call_unlock();
+   pipe_mutex_unlock(tr_scr->list_mutex);
+
+   return 0;
+}
+
+static int
+trace_rbug_shader_list(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial)
+{
+   struct rbug_proto_shader_list *list = (struct rbug_proto_shader_list *)header;
+
+   struct trace_screen *tr_scr = tr_rbug->tr_scr;
+   struct trace_context *tr_ctx = NULL;
+   struct trace_shader *tr_shdr = NULL;
+   struct tr_list *ptr;
+   rbug_shader_t *shdrs;
+   int i = 0;
+
+   pipe_mutex_lock(tr_scr->list_mutex);
+   tr_ctx = trace_rbug_get_context_locked(tr_scr, list->context);
+
+   if (!tr_ctx) {
+      pipe_mutex_unlock(tr_scr->list_mutex);
+      return -ESRCH;
+   }
+
+   pipe_mutex_lock(tr_ctx->list_mutex);
+   shdrs = MALLOC(tr_ctx->num_shaders * sizeof(rbug_shader_t));
+   foreach(ptr, &tr_ctx->shaders) {
+      tr_shdr = (struct trace_shader *)((char*)ptr - offsetof(struct trace_shader, list));
+      shdrs[i++] = VOID2U64(tr_shdr);
+   }
+
+   pipe_mutex_unlock(tr_ctx->list_mutex);
+   pipe_mutex_unlock(tr_scr->list_mutex);
+
+   rbug_send_shader_list_reply(tr_rbug->con, serial, shdrs, i, NULL);
+   FREE(shdrs);
+
+   return 0;
+}
+
+static int
+trace_rbug_shader_info(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial)
+{
+   struct rbug_proto_shader_info *info = (struct rbug_proto_shader_info *)header;
+
+   struct trace_screen *tr_scr = tr_rbug->tr_scr;
+   struct trace_context *tr_ctx = NULL;
+   struct trace_shader *tr_shdr = NULL;
+   unsigned original_len;
+   unsigned replaced_len;
+
+   pipe_mutex_lock(tr_scr->list_mutex);
+   tr_ctx = trace_rbug_get_context_locked(tr_scr, info->context);
+
+   if (!tr_ctx) {
+      pipe_mutex_unlock(tr_scr->list_mutex);
+      return -ESRCH;
+   }
+
+   pipe_mutex_lock(tr_ctx->list_mutex);
+
+   tr_shdr = trace_rbug_get_shader_locked(tr_ctx, info->shader);
+
+   if (!tr_shdr) {
+      pipe_mutex_unlock(tr_ctx->list_mutex);
+      pipe_mutex_unlock(tr_scr->list_mutex);
+      return -ESRCH;
+   }
+
+   /* just in case */
+   assert(sizeof(struct tgsi_token) == 4);
+
+   original_len = tgsi_num_tokens(tr_shdr->tokens);
+   if (tr_shdr->replaced_tokens)
+      replaced_len = tgsi_num_tokens(tr_shdr->replaced_tokens);
+   else
+      replaced_len = 0;
+
+   rbug_send_shader_info_reply(tr_rbug->con, serial,
+                               (uint32_t*)tr_shdr->tokens, original_len,
+                               (uint32_t*)tr_shdr->replaced_tokens, replaced_len,
+                               tr_shdr->disabled,
+                               NULL);
+
+   pipe_mutex_unlock(tr_ctx->list_mutex);
+   pipe_mutex_unlock(tr_scr->list_mutex);
+
+   return 0;
+}
+
+static int
+trace_rbug_shader_disable(struct trace_rbug *tr_rbug, struct rbug_header *header)
+{
+   struct rbug_proto_shader_disable *dis = (struct rbug_proto_shader_disable *)header;
+
+   struct trace_screen *tr_scr = tr_rbug->tr_scr;
+   struct trace_context *tr_ctx = NULL;
+   struct trace_shader *tr_shdr = NULL;
+
+   pipe_mutex_lock(tr_scr->list_mutex);
+   tr_ctx = trace_rbug_get_context_locked(tr_scr, dis->context);
+
+   if (!tr_ctx) {
+      pipe_mutex_unlock(tr_scr->list_mutex);
+      return -ESRCH;
+   }
+
+   pipe_mutex_lock(tr_ctx->list_mutex);
+
+   tr_shdr = trace_rbug_get_shader_locked(tr_ctx, dis->shader);
+
+   if (!tr_shdr) {
+      pipe_mutex_unlock(tr_ctx->list_mutex);
+      pipe_mutex_unlock(tr_scr->list_mutex);
+      return -ESRCH;
+   }
+
+   tr_shdr->disabled = dis->disable;
+
+   pipe_mutex_unlock(tr_ctx->list_mutex);
+   pipe_mutex_unlock(tr_scr->list_mutex);
+
+   return 0;
+}
+
+static int
+trace_rbug_shader_replace(struct trace_rbug *tr_rbug, struct rbug_header *header)
+{
+   struct rbug_proto_shader_replace *rep = (struct rbug_proto_shader_replace *)header;
+
+   struct trace_screen *tr_scr = tr_rbug->tr_scr;
+   struct trace_context *tr_ctx = NULL;
+   struct trace_shader *tr_shdr = NULL;
+   struct pipe_context *pipe = NULL;
+   void *state;
+
+   pipe_mutex_lock(tr_scr->list_mutex);
+   tr_ctx = trace_rbug_get_context_locked(tr_scr, rep->context);
+
+   if (!tr_ctx) {
+      pipe_mutex_unlock(tr_scr->list_mutex);
+      return -ESRCH;
+   }
+
+   pipe_mutex_lock(tr_ctx->list_mutex);
+
+   tr_shdr = trace_rbug_get_shader_locked(tr_ctx, rep->shader);
+
+   if (!tr_shdr) {
+      pipe_mutex_unlock(tr_ctx->list_mutex);
+      pipe_mutex_unlock(tr_scr->list_mutex);
+      return -ESRCH;
+   }
+
+   /* protect the pipe context */
+   trace_dump_call_lock();
+
+   pipe = tr_ctx->pipe;
+
+   /* remove old replaced shader */
+   if (tr_shdr->replaced) {
+      if (tr_ctx->curr.fs == tr_shdr || tr_ctx->curr.vs == tr_shdr)
+         trace_shader_bind_locked(pipe, tr_shdr, tr_shdr->state);
+
+      FREE(tr_shdr->replaced_tokens);
+      trace_shader_delete_locked(pipe, tr_shdr, tr_shdr->replaced);
+      tr_shdr->replaced = NULL;
+      tr_shdr->replaced_tokens = NULL;
+   }
+
+   /* empty inputs means restore old which we did above */
+   if (rep->tokens_len == 0)
+      goto out;
+
+   tr_shdr->replaced_tokens = tgsi_dup_tokens((struct tgsi_token *)rep->tokens);
+   if (!tr_shdr->replaced_tokens)
+      goto err;
+
+   state = trace_shader_create_locked(pipe, tr_shdr, tr_shdr->replaced_tokens);
+   if (!state)
+      goto err;
+
+   /* bind new shader if the shader is currently a bound */
+   if (tr_ctx->curr.fs == tr_shdr || tr_ctx->curr.vs == tr_shdr)
+      trace_shader_bind_locked(pipe, tr_shdr, state);
+
+   /* save state */
+   tr_shdr->replaced = state;
+
+out:
+   trace_dump_call_unlock();
+   pipe_mutex_unlock(tr_ctx->list_mutex);
+   pipe_mutex_unlock(tr_scr->list_mutex);
+
+   return 0;
+
+err:
+   FREE(tr_shdr->replaced_tokens);
+   tr_shdr->replaced = NULL;
+   tr_shdr->replaced_tokens = NULL;
+
+   trace_dump_call_unlock();
+   pipe_mutex_unlock(tr_ctx->list_mutex);
+   pipe_mutex_unlock(tr_scr->list_mutex);
+   return -EINVAL;
+}
+
+static boolean
+trace_rbug_header(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial)
+{
+   int ret = 0;
+
+   switch(header->opcode) {
+      case RBUG_OP_PING:
+         rbug_send_ping_reply(tr_rbug->con, serial, NULL);
+         break;
+      case RBUG_OP_TEXTURE_LIST:
+         ret = trace_rbug_texture_list(tr_rbug, header, serial);
+         break;
+      case RBUG_OP_TEXTURE_INFO:
+         ret = trace_rbug_texture_info(tr_rbug, header, serial);
+         break;
+      case RBUG_OP_TEXTURE_READ:
+         ret = trace_rbug_texture_read(tr_rbug, header, serial);
+         break;
+      case RBUG_OP_CONTEXT_LIST:
+         ret = trace_rbug_context_list(tr_rbug, header, serial);
+         break;
+      case RBUG_OP_CONTEXT_INFO:
+         ret = trace_rbug_context_info(tr_rbug, header, serial);
+         break;
+      case RBUG_OP_CONTEXT_DRAW_BLOCK:
+         ret = trace_rbug_context_draw_block(tr_rbug, header, serial);
+         break;
+      case RBUG_OP_CONTEXT_DRAW_STEP:
+         ret = trace_rbug_context_draw_step(tr_rbug, header, serial);
+         break;
+      case RBUG_OP_CONTEXT_DRAW_UNBLOCK:
+         ret = trace_rbug_context_draw_unblock(tr_rbug, header, serial);
+         break;
+      case RBUG_OP_CONTEXT_DRAW_RULE:
+         ret = trace_rbug_context_draw_rule(tr_rbug, header, serial);
+         break;
+      case RBUG_OP_CONTEXT_FLUSH:
+         ret = trace_rbug_context_flush(tr_rbug, header, serial);
+         break;
+      case RBUG_OP_SHADER_LIST:
+         ret = trace_rbug_shader_list(tr_rbug, header, serial);
+         break;
+      case RBUG_OP_SHADER_INFO:
+         ret = trace_rbug_shader_info(tr_rbug, header, serial);
+         break;
+      case RBUG_OP_SHADER_DISABLE:
+         ret = trace_rbug_shader_disable(tr_rbug, header);
+         break;
+      case RBUG_OP_SHADER_REPLACE:
+         ret = trace_rbug_shader_replace(tr_rbug, header);
+         break;
+      default:
+         debug_printf("%s - unsupported opcode %u\n", __FUNCTION__, header->opcode);
+         ret = -ENOSYS;
+         break;
+   }
+   rbug_free_header(header);
+
+   if (ret)
+      rbug_send_error_reply(tr_rbug->con, serial, ret, NULL);
+
+   return TRUE;
+}
+
+static void
+trace_rbug_con(struct trace_rbug *tr_rbug)
+{
+   struct rbug_header *header;
+   uint32_t serial;
+
+   debug_printf("%s - connection received\n", __FUNCTION__);
+
+   while(tr_rbug->running) {
+      header = rbug_get_message(tr_rbug->con, &serial);
+      if (!header)
+         break;
+
+      if (!trace_rbug_header(tr_rbug, header, serial))
+         break;
+   }
+
+   debug_printf("%s - connection closed\n", __FUNCTION__);
+
+   rbug_disconnect(tr_rbug->con);
+   tr_rbug->con = NULL;
+}
+
+PIPE_THREAD_ROUTINE(trace_rbug_thread, void_tr_rbug)
+{
+   struct trace_rbug *tr_rbug = void_tr_rbug;
+   uint16_t port = 13370;
+   int s = -1;
+   int c;
+
+   u_socket_init();
+
+   for (;port <= 13379 && s < 0; port++)
+      s = u_socket_listen_on_port(port);
+
+   if (s < 0) {
+      debug_printf("trace_rbug - failed to listen\n");
+      return NULL;
+   }
+
+   u_socket_block(s, false);
+
+   debug_printf("trace_rbug - remote debugging listening on port %u\n", --port);
+
+   while(tr_rbug->running) {
+      sleep(1);
+
+      c = u_socket_accept(s);
+      if (c < 0)
+         continue;
+
+      u_socket_block(c, true);
+      tr_rbug->con = rbug_from_socket(c);
+
+      trace_rbug_con(tr_rbug);
+
+      u_socket_close(c);
+   }
+
+   u_socket_close(s);
+
+   u_socket_stop();
+
+   return NULL;
+}
+
+/**********************************************************
+ *
+ */
+
+struct trace_rbug *
+trace_rbug_start(struct trace_screen *tr_scr)
+{
+   struct trace_rbug *tr_rbug = CALLOC_STRUCT(trace_rbug);
+   if (!tr_rbug)
+      return NULL;
+
+   tr_rbug->tr_scr = tr_scr;
+   tr_rbug->running = TRUE;
+   tr_rbug->thread = pipe_thread_create(trace_rbug_thread, tr_rbug);
+
+   return tr_rbug;
+}
+
+void
+trace_rbug_stop(struct trace_rbug *tr_rbug)
+{
+   if (!tr_rbug)
+      return;
+
+   tr_rbug->running = false;
+   pipe_thread_wait(tr_rbug->thread);
+
+   FREE(tr_rbug);
+
+   return;
+}
+
+void
+trace_rbug_notify_draw_blocked(struct trace_context *tr_ctx)
+{
+   struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen);
+   struct trace_rbug *tr_rbug = tr_scr->rbug;
+
+   if (tr_rbug && tr_rbug->con)
+      rbug_send_context_draw_blocked(tr_rbug->con,
+                                     VOID2U64(tr_ctx), tr_ctx->draw_blocked, NULL);
+}
index 12a85353428413315d38a97499cde68cc0e0c0b7..920f418ebf0665a0a3bcb4b1998c683ce6825c41 100644 (file)
 
 #include "tr_buffer.h"
 #include "tr_dump.h"
-#include "tr_state.h"
+#include "tr_dump_state.h"
 #include "tr_texture.h"
 #include "tr_screen.h"
 
 #include "pipe/p_inlines.h"
 
 
+static boolean trace = FALSE;
+
 static const char *
 trace_screen_get_name(struct pipe_screen *_screen)
 {
@@ -212,10 +214,12 @@ static struct pipe_texture *
 trace_screen_texture_blanket(struct pipe_screen *_screen,
                              const struct pipe_texture *templat,
                              const unsigned *ppitch,
-                             struct pipe_buffer *buffer)
+                             struct pipe_buffer *_buffer)
 {
    struct trace_screen *tr_scr = trace_screen(_screen);
+   struct trace_buffer *tr_buf = trace_buffer(_buffer);
    struct pipe_screen *screen = tr_scr->screen;
+   struct pipe_buffer *buffer = tr_buf->buffer;
    unsigned pitch = *ppitch;
    struct pipe_texture *result;
 
@@ -818,34 +822,48 @@ trace_screen_destroy(struct pipe_screen *_screen)
    struct pipe_screen *screen = tr_scr->screen;
 
    trace_dump_call_begin("pipe_screen", "destroy");
-
    trace_dump_arg(ptr, screen);
-
-   screen->destroy(screen);
-
    trace_dump_call_end();
-
    trace_dump_trace_end();
 
+   if (tr_scr->rbug)
+      trace_rbug_stop(tr_scr->rbug);
+
+   screen->destroy(screen);
+
    FREE(tr_scr);
 }
 
+boolean
+trace_enabled(void)
+{
+   return trace;
+}
 
 struct pipe_screen *
 trace_screen_create(struct pipe_screen *screen)
 {
    struct trace_screen *tr_scr;
    struct pipe_winsys *winsys;
+   boolean rbug = FALSE;
 
    if(!screen)
       goto error1;
 
    trace_dump_init();
 
-   if(!trace_dump_trace_begin())
-      goto error1;
+   if(trace_dump_trace_begin()) {
+      trace_dumping_start();
+      trace = TRUE;
+   }
 
-   trace_dumping_start();
+   if (debug_get_bool_option("GALLIUM_RBUG", FALSE)) {
+      trace = TRUE;
+      rbug = TRUE;
+   }
+
+   if (!trace)
+      goto error1;
 
    trace_dump_call_begin("", "pipe_screen_create");
 
@@ -904,6 +922,9 @@ trace_screen_create(struct pipe_screen *screen)
    trace_dump_ret(ptr, screen);
    trace_dump_call_end();
 
+   if (rbug)
+      tr_scr->rbug = trace_rbug_start(tr_scr);
+
    return &tr_scr->base;
 
 #if 0
index 59f254166d4dcb317903161c15302041e4e4fe77..dba8cd7c6535a5de4733df9e0efb3a48eb17a1cf 100644 (file)
@@ -57,6 +57,9 @@ struct trace_screen
 
    struct pipe_screen *screen;
 
+   /* remote debugger */
+   struct trace_rbug *rbug;
+
    pipe_mutex list_mutex;
    int num_buffers;
    int num_contexts;
@@ -71,14 +74,34 @@ struct trace_screen
 };
 
 
+/*
+ * tr_rbug.c
+ */
+
+
+struct trace_rbug;
+
+struct trace_rbug *
+trace_rbug_start(struct trace_screen *tr_scr);
+
+void
+trace_rbug_stop(struct trace_rbug *tr_rbug);
+
+
+/*
+ * tr_screen.c
+ */
+
+
+boolean
+trace_enabled(void);
+
 struct trace_screen *
 trace_screen(struct pipe_screen *screen);
 
-
 struct pipe_screen *
 trace_screen_create(struct pipe_screen *screen);
 
-
 void
 trace_screen_user_buffer_update(struct pipe_screen *screen,
                                 struct pipe_buffer *buffer);
@@ -99,6 +122,7 @@ trace_screen_user_buffer_update(struct pipe_screen *screen,
       pipe_mutex_unlock(tr_scr->list_mutex);             \
    } while (0)
 
+
 #ifdef __cplusplus
 }
 #endif
index a9570c1aebdc7b690f69d924a3e6051e1fb4e67c..d8c11640bf346efaa925ea1837cd6aecda89c8a5 100644 (file)
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+/*
+ * Copyright 2009 VMware, Inc.
  * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
+ * 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 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
  *
- **************************************************************************/
-
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE 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 "pipe/p_compiler.h"
-#include "util/u_memory.h"
-#include "tgsi/tgsi_dump.h"
-
-#include "tr_dump.h"
 #include "tr_state.h"
 
+#include "util/u_memory.h"
+#include "util/u_simple_list.h"
 
-void trace_dump_format(enum pipe_format format)
-{
-   trace_dump_enum(pf_name(format) );
-}
-
-
-void trace_dump_block(const struct pipe_format_block *block)
-{
-   trace_dump_struct_begin("pipe_format_block");
-   trace_dump_member(uint, block, size);
-   trace_dump_member(uint, block, width);
-   trace_dump_member(uint, block, height);
-   trace_dump_struct_end();
-}
-
-
-static void trace_dump_reference(const struct pipe_reference *reference)
-{
-   trace_dump_struct_begin("pipe_reference");
-   trace_dump_member(int, &reference->count, count);
-   trace_dump_struct_end();
-}
-
-
-void trace_dump_template(const struct pipe_texture *templat)
-{
-   if(!templat) {
-      trace_dump_null();
-      return;
-   }
-
-   trace_dump_struct_begin("pipe_texture");
-
-   trace_dump_member(int, templat, target);
-   trace_dump_member(format, templat, format);
-
-   trace_dump_member_begin("width");
-   trace_dump_array(uint, templat->width, 1);
-   trace_dump_member_end();
-
-   trace_dump_member_begin("height");
-   trace_dump_array(uint, templat->height, 1);
-   trace_dump_member_end();
-
-   trace_dump_member_begin("depth");
-   trace_dump_array(uint, templat->depth, 1);
-   trace_dump_member_end();
-
-   trace_dump_member_begin("block");
-   trace_dump_block(&templat->block);
-   trace_dump_member_end();
-
-   trace_dump_member(uint, templat, last_level);
-   trace_dump_member(uint, templat, tex_usage);
-
-   trace_dump_struct_end();
-}
-
-
-void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state)
-{
-   if(!state) {
-      trace_dump_null();
-      return;
-   }
-
-   trace_dump_struct_begin("pipe_rasterizer_state");
-
-   trace_dump_member(bool, state, flatshade);
-   trace_dump_member(bool, state, light_twoside);
-   trace_dump_member(uint, state, front_winding);
-   trace_dump_member(uint, state, cull_mode);
-   trace_dump_member(uint, state, fill_cw);
-   trace_dump_member(uint, state, fill_ccw);
-   trace_dump_member(bool, state, offset_cw);
-   trace_dump_member(bool, state, offset_ccw);
-   trace_dump_member(bool, state, scissor);
-   trace_dump_member(bool, state, poly_smooth);
-   trace_dump_member(bool, state, poly_stipple_enable);
-   trace_dump_member(bool, state, point_smooth);
-   trace_dump_member(bool, state, point_sprite);
-   trace_dump_member(bool, state, point_size_per_vertex);
-   trace_dump_member(bool, state, multisample);
-   trace_dump_member(bool, state, line_smooth);
-   trace_dump_member(bool, state, line_stipple_enable);
-   trace_dump_member(uint, state, line_stipple_factor);
-   trace_dump_member(uint, state, line_stipple_pattern);
-   trace_dump_member(bool, state, line_last_pixel);
-   trace_dump_member(bool, state, bypass_vs_clip_and_viewport);
-   trace_dump_member(bool, state, flatshade_first);
-   trace_dump_member(bool, state, gl_rasterization_rules);
-
-   trace_dump_member(float, state, line_width);
-   trace_dump_member(float, state, point_size);
-   trace_dump_member(float, state, point_size_min);
-   trace_dump_member(float, state, point_size_max);
-   trace_dump_member(float, state, offset_units);
-   trace_dump_member(float, state, offset_scale);
-
-   trace_dump_member_array(uint, state, sprite_coord_mode);
-
-   trace_dump_struct_end();
-}
-
-
-void trace_dump_poly_stipple(const struct pipe_poly_stipple *state)
-{
-   if(!state) {
-      trace_dump_null();
-      return;
-   }
-
-   trace_dump_struct_begin("pipe_poly_stipple");
-
-   trace_dump_member_begin("stipple");
-   trace_dump_array(uint,
-                    state->stipple,
-                    Elements(state->stipple));
-   trace_dump_member_end();
-
-   trace_dump_struct_end();
-}
-
-
-void trace_dump_viewport_state(const struct pipe_viewport_state *state)
-{
-   if(!state) {
-      trace_dump_null();
-      return;
-   }
-
-   trace_dump_struct_begin("pipe_viewport_state");
-
-   trace_dump_member_array(float, state, scale);
-   trace_dump_member_array(float, state, translate);
-
-   trace_dump_struct_end();
-}
-
-
-void trace_dump_scissor_state(const struct pipe_scissor_state *state)
-{
-   if(!state) {
-      trace_dump_null();
-      return;
-   }
-
-   trace_dump_struct_begin("pipe_scissor_state");
-
-   trace_dump_member(uint, state, minx);
-   trace_dump_member(uint, state, miny);
-   trace_dump_member(uint, state, maxx);
-   trace_dump_member(uint, state, maxy);
-
-   trace_dump_struct_end();
-}
-
-
-void trace_dump_clip_state(const struct pipe_clip_state *state)
-{
-   unsigned i;
-
-   if(!state) {
-      trace_dump_null();
-      return;
-   }
-
-   trace_dump_struct_begin("pipe_clip_state");
-
-   trace_dump_member_begin("ucp");
-   trace_dump_array_begin();
-   for(i = 0; i < PIPE_MAX_CLIP_PLANES; ++i) {
-      trace_dump_elem_begin();
-      trace_dump_array(float, state->ucp[i], 4);
-      trace_dump_elem_end();
-   }
-   trace_dump_array_end();
-   trace_dump_member_end();
-
-   trace_dump_member(uint, state, nr);
-
-   trace_dump_struct_end();
-}
-
-
-void trace_dump_constant_buffer(const struct pipe_constant_buffer *state)
-{
-   if(!state) {
-      trace_dump_null();
-      return;
-   }
-
-   trace_dump_struct_begin("pipe_constant_buffer");
-
-   trace_dump_member(buffer_ptr, state, buffer);
-
-   trace_dump_struct_end();
-}
-
-
-void trace_dump_shader_state(const struct pipe_shader_state *state)
-{
-   static char str[8192];
-
-   if(!state) {
-      trace_dump_null();
-      return;
-   }
-
-   tgsi_dump_str(state->tokens, 0, str, sizeof(str));
-
-   trace_dump_struct_begin("pipe_shader_state");
-
-   trace_dump_member_begin("tokens");
-   trace_dump_string(str);
-   trace_dump_member_end();
-
-   trace_dump_struct_end();
-}
-
-
-void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state)
-{
-   unsigned i;
-
-   if(!state) {
-      trace_dump_null();
-      return;
-   }
-
-   trace_dump_struct_begin("pipe_depth_stencil_alpha_state");
-
-   trace_dump_member_begin("depth");
-   trace_dump_struct_begin("pipe_depth_state");
-   trace_dump_member(bool, &state->depth, enabled);
-   trace_dump_member(bool, &state->depth, writemask);
-   trace_dump_member(uint, &state->depth, func);
-   trace_dump_member(bool, &state->depth, occlusion_count);
-   trace_dump_struct_end();
-   trace_dump_member_end();
-
-   trace_dump_member_begin("stencil");
-   trace_dump_array_begin();
-   for(i = 0; i < Elements(state->stencil); ++i) {
-      trace_dump_elem_begin();
-      trace_dump_struct_begin("pipe_stencil_state");
-      trace_dump_member(bool, &state->stencil[i], enabled);
-      trace_dump_member(uint, &state->stencil[i], func);
-      trace_dump_member(uint, &state->stencil[i], fail_op);
-      trace_dump_member(uint, &state->stencil[i], zpass_op);
-      trace_dump_member(uint, &state->stencil[i], zfail_op);
-      trace_dump_member(uint, &state->stencil[i], ref_value);
-      trace_dump_member(uint, &state->stencil[i], valuemask);
-      trace_dump_member(uint, &state->stencil[i], writemask);
-      trace_dump_struct_end();
-      trace_dump_elem_end();
-   }
-   trace_dump_array_end();
-   trace_dump_member_end();
-
-   trace_dump_member_begin("alpha");
-   trace_dump_struct_begin("pipe_alpha_state");
-   trace_dump_member(bool, &state->alpha, enabled);
-   trace_dump_member(uint, &state->alpha, func);
-   trace_dump_member(float, &state->alpha, ref_value);
-   trace_dump_struct_end();
-   trace_dump_member_end();
-
-   trace_dump_struct_end();
-}
-
-
-void trace_dump_blend_state(const struct pipe_blend_state *state)
-{
-   if(!state) {
-      trace_dump_null();
-      return;
-   }
-
-   trace_dump_struct_begin("pipe_blend_state");
-
-   trace_dump_member(bool, state, blend_enable);
-
-   trace_dump_member(uint, state, rgb_func);
-   trace_dump_member(uint, state, rgb_src_factor);
-   trace_dump_member(uint, state, rgb_dst_factor);
-
-   trace_dump_member(uint, state, alpha_func);
-   trace_dump_member(uint, state, alpha_src_factor);
-   trace_dump_member(uint, state, alpha_dst_factor);
-
-   trace_dump_member(bool, state, logicop_enable);
-   trace_dump_member(uint, state, logicop_func);
-
-   trace_dump_member(uint, state, colormask);
-   trace_dump_member(bool, state, dither);
-
-   trace_dump_struct_end();
-}
-
-
-void trace_dump_blend_color(const struct pipe_blend_color *state)
-{
-   if(!state) {
-      trace_dump_null();
-      return;
-   }
-
-   trace_dump_struct_begin("pipe_blend_color");
-
-   trace_dump_member_array(float, state, color);
-
-   trace_dump_struct_end();
-}
-
-
-void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state)
-{
-   trace_dump_struct_begin("pipe_framebuffer_state");
-
-   trace_dump_member(uint, state, width);
-   trace_dump_member(uint, state, height);
-   trace_dump_member(uint, state, nr_cbufs);
-   trace_dump_member_array(ptr, state, cbufs);
-   trace_dump_member(ptr, state, zsbuf);
-
-   trace_dump_struct_end();
-}
-
-
-void trace_dump_sampler_state(const struct pipe_sampler_state *state)
-{
-   if(!state) {
-      trace_dump_null();
-      return;
-   }
-
-   trace_dump_struct_begin("pipe_sampler_state");
-
-   trace_dump_member(uint, state, wrap_s);
-   trace_dump_member(uint, state, wrap_t);
-   trace_dump_member(uint, state, wrap_r);
-   trace_dump_member(uint, state, min_img_filter);
-   trace_dump_member(uint, state, min_mip_filter);
-   trace_dump_member(uint, state, mag_img_filter);
-   trace_dump_member(bool, state, compare_mode);
-   trace_dump_member(uint, state, compare_func);
-   trace_dump_member(bool, state, normalized_coords);
-   trace_dump_member(uint, state, prefilter);
-   trace_dump_member(float, state, shadow_ambient);
-   trace_dump_member(float, state, lod_bias);
-   trace_dump_member(float, state, min_lod);
-   trace_dump_member(float, state, max_lod);
-   trace_dump_member_array(float, state, border_color);
-   trace_dump_member(float, state, max_anisotropy);
-
-   trace_dump_struct_end();
-}
-
-
-void trace_dump_surface(const struct pipe_surface *state)
-{
-   if(!state) {
-      trace_dump_null();
-      return;
-   }
-
-   trace_dump_struct_begin("pipe_surface");
-
-   trace_dump_reference(&state->reference);
-
-   trace_dump_member(format, state, format);
-   trace_dump_member(uint, state, width);
-   trace_dump_member(uint, state, height);
-
-   trace_dump_member(uint, state, layout);
-   trace_dump_member(uint, state, offset);
-   trace_dump_member(uint, state, usage);
-
-   trace_dump_member(ptr, state, texture);
-   trace_dump_member(uint, state, face);
-   trace_dump_member(uint, state, level);
-   trace_dump_member(uint, state, zslice);
-
-   trace_dump_struct_end();
-}
-
+#include "tgsi/tgsi_parse.h"
 
-void trace_dump_transfer(const struct pipe_transfer *state)
+struct trace_shader * trace_shader_create(struct trace_context *tr_ctx,
+                                          const struct pipe_shader_state *state,
+                                          void *result,
+                                          enum trace_shader_type type)
 {
-   if(!state) {
-      trace_dump_null();
-      return;
-   }
+   struct trace_shader *tr_shdr = CALLOC_STRUCT(trace_shader);
 
-   trace_dump_struct_begin("pipe_transfer");
+   tr_shdr->state = result;
+   tr_shdr->type = type;
+   tr_shdr->tokens = tgsi_dup_tokens(state->tokens);
 
-   trace_dump_member(format, state, format);
-   trace_dump_member(uint, state, width);
-   trace_dump_member(uint, state, height);
+   /* works on context as well */
+   trace_screen_add_to_list(tr_ctx, shaders, tr_shdr);
 
-   trace_dump_member_begin("block");
-   trace_dump_block(&state->block);
-   trace_dump_member_end();
-
-   trace_dump_member(uint, state, nblocksx);
-   trace_dump_member(uint, state, nblocksy);
-   trace_dump_member(uint, state, stride);
-   trace_dump_member(uint, state, usage);
-
-   trace_dump_member(ptr, state, texture);
-   trace_dump_member(uint, state, face);
-   trace_dump_member(uint, state, level);
-   trace_dump_member(uint, state, zslice);
-
-   trace_dump_struct_end();
+   return tr_shdr;
 }
 
-
-void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state)
+void trace_shader_destroy(struct trace_context *tr_ctx,
+                          struct trace_shader *tr_shdr)
 {
-   if(!state) {
-      trace_dump_null();
-      return;
-   }
+   trace_screen_remove_from_list(tr_ctx, shaders, tr_shdr);
 
-   trace_dump_struct_begin("pipe_vertex_buffer");
-
-   trace_dump_member(uint, state, stride);
-   trace_dump_member(uint, state, max_index);
-   trace_dump_member(uint, state, buffer_offset);
-   trace_dump_member(buffer_ptr, state, buffer);
-
-   trace_dump_struct_end();
-}
-
-
-void trace_dump_vertex_element(const struct pipe_vertex_element *state)
-{
-   if(!state) {
-      trace_dump_null();
-      return;
+   if (tr_shdr->replaced) {
+      if (tr_shdr->type == TRACE_SHADER_FRAGMENT)
+         tr_ctx->pipe->delete_fs_state(tr_ctx->pipe, tr_shdr->replaced);
+      else if (tr_shdr->type == TRACE_SHADER_VERTEX)
+         tr_ctx->pipe->delete_vs_state(tr_ctx->pipe, tr_shdr->replaced);
+      else
+         assert(0);
    }
 
-   trace_dump_struct_begin("pipe_vertex_element");
-
-   trace_dump_member(uint, state, src_offset);
-
-   trace_dump_member(uint, state, vertex_buffer_index);
-   trace_dump_member(uint, state, nr_components);
-
-   trace_dump_member(format, state, src_format);
-
-   trace_dump_struct_end();
+   FREE(tr_shdr->replaced_tokens);
+   FREE(tr_shdr->tokens);
+   FREE(tr_shdr);
 }
index 513ed0ac98d4453ba0fcedeba21908ab22a03ac4..1c16042ee5a901498be46a3057762f0f0b3e0f99 100644 (file)
@@ -1,78 +1,68 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+/*
+ * Copyright 2009 VMware, Inc.
  * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
+ * 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 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
  *
- **************************************************************************/
-
-#ifndef TR_STATE_H
-#define TR_STATE_H
-
-#include "pipe/p_format.h"
-#include "pipe/p_state.h"
-#include "pipe/p_shader_tokens.h"
-
-
-void trace_dump_format(enum pipe_format format);
-
-void trace_dump_block(const struct pipe_format_block *block);
-
-void trace_dump_template(const struct pipe_texture *templat);
-
-
-void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state);
-
-void trace_dump_poly_stipple(const struct pipe_poly_stipple *state);
-
-void trace_dump_viewport_state(const struct pipe_viewport_state *state);
-
-void trace_dump_scissor_state(const struct pipe_scissor_state *state);
-
-void trace_dump_clip_state(const struct pipe_clip_state *state);
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VMWARE 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.
+ */
 
-void trace_dump_constant_buffer(const struct pipe_constant_buffer *state);
+#ifndef TR_STATE_H_
+#define TR_STATE_H_
 
-void trace_dump_token(const struct tgsi_token *token);
+#include "tr_context.h"
 
-void trace_dump_shader_state(const struct pipe_shader_state *state);
+struct tgsi_token;
 
-void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state);
+enum trace_shader_type {
+   TRACE_SHADER_FRAGMENT = 0,
+   TRACE_SHADER_VERTEX   = 1,
+   TRACE_SHADER_GEOMETRY = 2,
+};
 
-void trace_dump_blend_state(const struct pipe_blend_state *state);
+struct trace_shader
+{
+   struct tr_list list;
 
-void trace_dump_blend_color(const struct pipe_blend_color *state);
+   enum trace_shader_type type;
 
-void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state);
+   void *state;
+   void *replaced;
 
-void trace_dump_sampler_state(const struct pipe_sampler_state *state);
+   struct tgsi_token *tokens;
+   struct tgsi_token *replaced_tokens;
 
-void trace_dump_surface(const struct pipe_surface *state);
+   boolean disabled;
+};
 
-void trace_dump_transfer(const struct pipe_transfer *state);
 
-void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state);
+static INLINE struct trace_shader *
+trace_shader(void *state)
+{
+   return (struct trace_shader *)state;
+}
 
-void trace_dump_vertex_element(const struct pipe_vertex_element *state);
+struct trace_shader * trace_shader_create(struct trace_context *tr_ctx,
+                                          const struct pipe_shader_state *state,
+                                          void *result,
+                                          enum trace_shader_type type);
 
+void trace_shader_destroy(struct trace_context *tr_ctx,
+                          struct trace_shader *tr_shdr);
 
-#endif /* TR_STATE_H */
+#endif
index 82e23c413c813222cd1fd9d99c97ccfe08f493d1..9924046cb2f53d2ed33294bae9f3b3241a5a9ff5 100644 (file)
@@ -132,6 +132,7 @@ enum pipe_texture_target {
 #define PIPE_TEX_FACE_NEG_Y 3
 #define PIPE_TEX_FACE_POS_Z 4
 #define PIPE_TEX_FACE_NEG_Z 5
+#define PIPE_TEX_FACE_MAX   6
 
 #define PIPE_TEX_WRAP_REPEAT                   0
 #define PIPE_TEX_WRAP_CLAMP                    1
@@ -158,14 +159,6 @@ enum pipe_texture_target {
 #define PIPE_TEX_COMPARE_NONE          0
 #define PIPE_TEX_COMPARE_R_TO_TEXTURE  1
 
-#define PIPE_TEX_FACE_POS_X   0
-#define PIPE_TEX_FACE_NEG_X   1
-#define PIPE_TEX_FACE_POS_Y   2
-#define PIPE_TEX_FACE_NEG_Y   3
-#define PIPE_TEX_FACE_POS_Z   4
-#define PIPE_TEX_FACE_NEG_Z   5
-#define PIPE_TEX_FACE_MAX     6
-
 #define PIPE_TEXTURE_USAGE_RENDER_TARGET   0x1
 #define PIPE_TEXTURE_USAGE_DISPLAY_TARGET  0x2 /* ie a backbuffer */
 #define PIPE_TEXTURE_USAGE_PRIMARY         0x4 /* ie a frontbuffer */
@@ -280,9 +273,8 @@ enum pipe_transfer_usage {
 
 
 /**
- * Implementation capabilities/limits
- * Passed to pipe->get_param()
- * XXX this will need some fine tuning...
+ * Implementation capabilities/limits which are queried through
+ * pipe_screen::get_param() and pipe_screen::get_paramf().
  */
 #define PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS 1
 #define PIPE_CAP_NPOT_TEXTURES           2
index ce8d79549ad2659afae31337108ff35fb5b8b541..96e8e087447b6cf9aa34d6eaadb155f34fb3c86d 100644 (file)
@@ -44,6 +44,8 @@
 #include <pthread.h> /* POSIX threads headers */
 #include <stdio.h> /* for perror() */
 
+#define PIPE_THREAD_HAVE_CONDVAR
+
 typedef pthread_t pipe_thread;
 
 #define PIPE_THREAD_ROUTINE( name, param ) \
index 5846390d02c161b55c8c681342a1d2b6e1394757..09cd3091d220bc4d372941a46f29d0abf4e8f475 100644 (file)
@@ -138,6 +138,18 @@ dri_get_buffers(__DRIdrawablePrivate * dPriv)
    dri_drawable->pBackClipRects[0].x2 = dri_drawable->w;
    dri_drawable->pBackClipRects[0].y2 = dri_drawable->h;
 
+   if (drawable->old_num == count &&
+       drawable->old_w == dri_drawable->w &&
+       drawable->old_h == dri_drawable->h &&
+       memcmp(drawable->old, buffers, sizeof(__DRIbuffer) * count) == 0) {
+       return;
+   } else {
+      drawable->old_num = count;
+      drawable->old_w = dri_drawable->w;
+      drawable->old_h = dri_drawable->h;
+      memcpy(drawable->old, buffers, sizeof(__DRIbuffer) * count);
+   }
+
    for (i = 0; i < count; i++) {
       enum pipe_format format = 0;
       int index = 0;
index 78a66624aaf2a711b22374020af5f3a0473e41ed..0f654d804a7dceb4582c757bd636a2e2df647aee 100644 (file)
@@ -46,6 +46,11 @@ struct dri_drawable
    unsigned attachments[8];
    unsigned num_attachments;
 
+   __DRIbuffer old[8];
+   unsigned old_num;
+   unsigned old_w;
+   unsigned old_h;
+
    /* gallium */
    struct st_framebuffer *stfb;
    struct pipe_fence_handle *swap_fences[DRI_SWAP_FENCES_MAX];
index 0c59d42d5c686c08d4a0e5209f9cf9bc268ac2d5..2f48162526b58d696cfbbdca33c2981d69a87ab2 100644 (file)
 #define need_GL_ARB_multisample
 #define need_GL_ARB_occlusion_query
 #define need_GL_ARB_point_parameters
+#define need_GL_ARB_shader_objects
 #define need_GL_ARB_texture_compression
 #define need_GL_ARB_vertex_buffer_object
 #define need_GL_ARB_vertex_program
+#define need_GL_ARB_vertex_shader
 #define need_GL_ARB_window_pos
 #define need_GL_EXT_blend_color
 #define need_GL_EXT_blend_equation_separate
 #define need_GL_EXT_multi_draw_arrays
 #define need_GL_EXT_secondary_color
 #define need_GL_NV_vertex_program
+#define need_GL_VERSION_2_0
+#define need_GL_VERSION_2_1
 #include "extension_helper.h"
 
 /**
  * Extension strings exported by the driver.
  */
 const struct dri_extension card_extensions[] = {
+   {"GL_ARB_fragment_shader", NULL},
    {"GL_ARB_multisample", GL_ARB_multisample_functions},
    {"GL_ARB_multitexture", NULL},
    {"GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions},
+   {"GL_ARB_pixel_buffer_object", NULL},
    {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions},
+   {"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_texture_border_clamp", NULL},
    {"GL_ARB_texture_compression", GL_ARB_texture_compression_functions},
    {"GL_ARB_texture_cube_map", NULL},
@@ -69,7 +78,7 @@ const struct dri_extension card_extensions[] = {
    {"GL_ARB_texture_mirrored_repeat", NULL},
    {"GL_ARB_texture_rectangle", NULL},
    {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions},
-   {"GL_ARB_pixel_buffer_object", NULL},
+   {"GL_ARB_vertex_shader", GL_ARB_vertex_shader_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},
index 692a3c8b76f579cf5faa63ef8573edeba1bcd1ad..e825aa718b6773bdb46a877d6076e2ce737dbe8c 100644 (file)
@@ -1,29 +1,19 @@
-TARGET     = libegldrm.a
-CFILES     = $(wildcard ./*.c)
-OBJECTS    = $(patsubst ./%.c,./%.o,$(CFILES))
-GALLIUMDIR = ../..
-TOP        = ../../../..
+TOP = ../../../..
+include $(TOP)/configs/current
 
-include ${TOP}/configs/current
+LIBNAME = egldrm
 
-CFLAGS := \
-          -I${GALLIUMDIR}/include \
-          -I${GALLIUMDIR}/auxiliary \
-          -I${TOP}/src/mesa/drivers/dri/common \
-          -I${TOP}/src/mesa \
-          -I$(TOP)/include \
-          -I$(TOP)/src/egl/main \
-          ${LIBDRM_CFLAGS} \
-          ${CFLAGS}
+LIBRARY_INCLUDES = \
+       -I$(TOP)/src/gallium/include \
+       -I$(TOP)/src/gallium/auxiliary \
+       -I$(TOP)/src/mesa/drivers/dri/common \
+       -I$(TOP)/src/mesa \
+       -I$(TOP)/include \
+       -I$(TOP)/src/egl/main \
+       $(shell pkg-config --cflags-only-I libdrm)
 
-#############################################
 
-.PHONY = all clean
+C_SOURCES = $(wildcard ./*.c)
 
-all: ${TARGET}
 
-${TARGET}: ${OBJECTS}
-       ar rcs $@ $^
-
-clean:
-       rm -rf ${OBJECTS} ${TARGET}
+include ../../Makefile.template
index 65e7048188e15d89153a2bcdf89caf8e73a7fb07..85e7ecfb9e8d8c00c7b456f4eebfcb6e9826c4e1 100644 (file)
@@ -97,6 +97,9 @@ struct fake_glx_context {
 
 
 
+#define DEFAULT_DIRECT GL_TRUE
+
+
 /**********************************************************************/
 /***                       GLX Visual Code                          ***/
 /**********************************************************************/
@@ -1059,7 +1062,7 @@ Fake_glXCreateContext( Display *dpy, XVisualInfo *visinfo,
       return NULL;
    }
 
-   glxCtx->glxContext.isDirect = GL_FALSE;
+   glxCtx->glxContext.isDirect = DEFAULT_DIRECT;
    glxCtx->glxContext.currentDpy = dpy;
    glxCtx->glxContext.xid = (XID) glxCtx;  /* self pointer */
 
@@ -1296,9 +1299,9 @@ Fake_glXDestroyContext( Display *dpy, GLXContext ctx )
 static Bool
 Fake_glXIsDirect( Display *dpy, GLXContext ctx )
 {
-   (void) dpy;
+   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
    (void) ctx;
-   return False;
+   return glxCtx->glxContext.isDirect;
 }
 
 
@@ -2055,7 +2058,7 @@ Fake_glXCreateNewContext( Display *dpy, GLXFBConfig config,
       return NULL;
    }
 
-   glxCtx->glxContext.isDirect = GL_FALSE;
+   glxCtx->glxContext.isDirect = DEFAULT_DIRECT;
    glxCtx->glxContext.currentDpy = dpy;
    glxCtx->glxContext.xid = (XID) glxCtx;  /* self pointer */
 
@@ -2277,7 +2280,7 @@ Fake_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int re
       return NULL;
    }
 
-   glxCtx->glxContext.isDirect = GL_FALSE;
+   glxCtx->glxContext.isDirect = DEFAULT_DIRECT;
    glxCtx->glxContext.currentDpy = dpy;
    glxCtx->glxContext.xid = (XID) glxCtx;  /* self pointer */
 
index a3d16516531a76e4d16849c9e5d29eba8ea030bf..79c2230588f33332584d2f72d2dba5e44e1369b7 100644 (file)
@@ -1100,26 +1100,19 @@ XMesaContext XMesaGetCurrentContext( void )
 
 
 
-
-
-
-/*
- * Copy the back buffer to the front buffer.  If there's no back buffer
- * this is a no-op.
+/**
+ * Swap front and back color buffers and have winsys display front buffer.
+ * If there's no front color buffer no swap actually occurs.
  */
 PUBLIC
 void XMesaSwapBuffers( XMesaBuffer b )
 {
-   struct pipe_surface *surf;
+   struct pipe_surface *frontLeftSurf;
 
-   /* If we're swapping the buffer associated with the current context
-    * we have to flush any pending rendering commands first.
-    */
-   st_notify_swapbuffers(b->stfb);
+   st_swapbuffers(b->stfb, &frontLeftSurf, NULL);
 
-   st_get_framebuffer_surface(b->stfb, ST_SURFACE_BACK_LEFT, &surf);
-   if (surf) {
-      driver.display_surface(b, surf);
+   if (frontLeftSurf) {
+      driver.display_surface(b, frontLeftSurf);
    }
 
    xmesa_check_and_update_buffer_size(NULL, b);
index 9f92cb42072bb436cf71246025adf8734bac27f3..985e5a861fc26474dbab2a6d339c03985fb44992 100644 (file)
@@ -118,7 +118,7 @@ clean:
 
 install: $(LIBNAME)
        $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
-       $(INSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
+       $(MINSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
 
 
 include depend
diff --git a/src/gallium/winsys/drm/intel/SConscript b/src/gallium/winsys/drm/intel/SConscript
new file mode 100644 (file)
index 0000000..50d7b75
--- /dev/null
@@ -0,0 +1,7 @@
+Import('*')
+
+SConscript(['gem/SConscript',])
+
+if 'mesa' in env['statetrackers']:
+
+    SConscript(['dri/SConscript'])
index ac0891a64639f6ea58ee95201ed81502e2da5071..de39e759d87d9f69f26291eb8fc58f315641c6d2 100644 (file)
@@ -6,6 +6,7 @@ LIBNAME = i915_dri.so
 PIPE_DRIVERS = \
        $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \
        $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
        $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
        $(TOP)/src/gallium/drivers/i915simple/libi915simple.a
 
diff --git a/src/gallium/winsys/drm/intel/dri/SConscript b/src/gallium/winsys/drm/intel/dri/SConscript
new file mode 100644 (file)
index 0000000..e14e96e
--- /dev/null
@@ -0,0 +1,16 @@
+Import('*')
+
+env = drienv.Clone()
+
+drivers = [
+    softpipe,
+    i915simple,
+    trace,
+    inteldrm
+]
+
+env.SharedLibrary(
+    target ='i915_dri.so',
+    source = COMMON_GALLIUM_SOURCES,
+    LIBS = drivers + mesa + auxiliaries + env['LIBS'],
+)
diff --git a/src/gallium/winsys/drm/intel/gem/SConscript b/src/gallium/winsys/drm/intel/gem/SConscript
new file mode 100644 (file)
index 0000000..ea8a2e5
--- /dev/null
@@ -0,0 +1,17 @@
+Import('*')
+
+env = drienv.Clone()
+
+inteldrm_sources = [
+    'intel_be_api.c',
+    'intel_be_batchbuffer.c',
+    'intel_be_context.c',
+    'intel_be_device.c',
+]
+
+inteldrm = env.ConvenienceLibrary(
+    target ='inteldrm',
+    source = inteldrm_sources,
+)
+
+Export('inteldrm')
index f4ef7c2d88b480bfee41871d778fcde1ad67c42d..a74be13bf7abe0c132da9f2e6728e0f8ac9b87e4 100644 (file)
@@ -2,7 +2,13 @@
 #include "intel_be_api.h"
 #include "i915simple/i915_winsys.h"
 
+#ifdef DEBUG
+#include "trace/trace_drm.h"
+
+struct drm_api hooks =
+#else
 struct drm_api drm_api_hooks =
+#endif
 {
        /* intel_be_context.c */
        .create_context = intel_be_create_context,
index b1b6b9362b66f63b9db0a626902234afb00ddbe8..d9aa5d54e1d30e1342dbaddf1242ef2b945bd9c5 100644 (file)
@@ -39,6 +39,6 @@ clean:
 
 install:
        $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
-       $(INSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+       $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
 
 .PHONY = all clean install
index f8c81358544bd312bc65233814d6c45fa02087f5..6c9cbef26df93a451b5cea51758bf08065655bd2 100644 (file)
@@ -2,7 +2,7 @@
 TOP = ../../../../..
 include $(TOP)/configs/current
 
-SUBDIRS = drm dri dri2
+SUBDIRS = drm $(GALLIUM_STATE_TRACKERS_DIRS)
 
 default install clean:
        @for dir in $(SUBDIRS) ; do \
index f7db6201fea55f283d0a8235566a7180c2dcc31e..0937f68c34bbeaf646f3b8f621f8e5c8daf5f1ef 100644 (file)
@@ -3,32 +3,25 @@ include $(TOP)/configs/current
 
 LIBNAME = nouveau_dri.so
 
-MINIGLX_SOURCES =
-
 PIPE_DRIVERS = \
+       $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \
        $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
        $(TOP)/src/gallium/drivers/nv04/libnv04.a \
        $(TOP)/src/gallium/drivers/nv10/libnv10.a \
        $(TOP)/src/gallium/drivers/nv20/libnv20.a \
        $(TOP)/src/gallium/drivers/nv30/libnv30.a \
        $(TOP)/src/gallium/drivers/nv40/libnv40.a \
-       $(TOP)/src/gallium/drivers/nv50/libnv50.a
-       
-DRIVER_SOURCES = \
-       nouveau_context.c \
-       nouveau_screen.c \
-       nouveau_swapbuffers.c \
-       nouveau_lock.c
+       $(TOP)/src/gallium/drivers/nv50/libnv50.a \
+       $(TOP)/src/gallium/drivers/nouveau/libnouveau.a
+
+DRIVER_SOURCES =
 
 C_SOURCES = \
        $(COMMON_GALLIUM_SOURCES) \
        $(DRIVER_SOURCES)
 
-ASM_SOURCES = 
+include ../../Makefile.template
 
-DRIVER_DEFINES = $(shell pkg-config libdrm_nouveau --cflags)
 DRI_LIB_DEPS += $(shell pkg-config libdrm_nouveau --libs)
 
-include ../../Makefile.template
-
 symlinks:
diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_context.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_context.c
deleted file mode 100644 (file)
index deb6ffc..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-#include <main/glheader.h>
-#include <glapi/glthread.h>
-#include <GL/internal/glcore.h>
-#include <utils.h>
-
-#include <state_tracker/st_public.h>
-#include <state_tracker/st_context.h>
-#include <state_tracker/drm_api.h>
-#include <pipe/p_defines.h>
-#include <pipe/p_context.h>
-#include <pipe/p_screen.h>
-
-#include "nouveau_context.h"
-#include "nouveau_screen.h"
-
-#include "nouveau_drmif.h"
-
-GLboolean
-nouveau_context_create(const __GLcontextModes *glVis,
-                      __DRIcontextPrivate *driContextPriv,
-                      void *sharedContextPrivate)
-{
-       __DRIscreenPrivate *driScrnPriv = driContextPriv->driScreenPriv;
-       struct nouveau_screen  *nv_screen = driScrnPriv->private;
-       struct nouveau_context *nv;
-       struct pipe_context *pipe;
-       struct st_context *st_share = NULL;
-
-       if (sharedContextPrivate)
-               st_share = ((struct nouveau_context *)sharedContextPrivate)->st;
-
-       nv = CALLOC_STRUCT(nouveau_context);
-       if (!nv)
-               return GL_FALSE;
-
-       {
-               struct nouveau_device_priv *nvdev =
-                       nouveau_device(nv_screen->device);
-
-               nvdev->ctx  = driContextPriv->hHWContext;
-               nvdev->lock = (drmLock *)&driScrnPriv->pSAREA->lock;
-       }
-
-       pipe = drm_api_hooks.create_context(nv_screen->pscreen);
-       if (!pipe) {
-               FREE(nv);
-               return GL_FALSE;
-       }
-       pipe->priv = nv;
-
-       driContextPriv->driverPrivate = nv;
-       nv->dri_screen = driScrnPriv;
-
-       driParseConfigFiles(&nv->dri_option_cache, &nv_screen->option_cache,
-                           nv->dri_screen->myNum, "nouveau");
-
-       nv->st = st_create_context(pipe, glVis, st_share);
-       return GL_TRUE;
-}
-
-void
-nouveau_context_destroy(__DRIcontextPrivate *driContextPriv)
-{
-       struct nouveau_context *nv = driContextPriv->driverPrivate;
-
-       assert(nv);
-
-       st_finish(nv->st);
-       st_destroy_context(nv->st);
-
-       FREE(nv);
-}
-
-GLboolean
-nouveau_context_bind(__DRIcontextPrivate *driContextPriv,
-                    __DRIdrawablePrivate *driDrawPriv,
-                    __DRIdrawablePrivate *driReadPriv)
-{
-       struct nouveau_context *nv;
-       struct nouveau_framebuffer *draw, *read;
-
-       if (!driContextPriv) {
-               st_make_current(NULL, NULL, NULL);
-               return GL_TRUE;
-       }
-
-       nv = driContextPriv->driverPrivate;
-       draw = driDrawPriv->driverPrivate;
-       read = driReadPriv->driverPrivate;
-
-       st_make_current(nv->st, draw->stfb, read->stfb);
-
-       if ((nv->dri_drawable != driDrawPriv) ||
-           (nv->last_stamp != driDrawPriv->lastStamp)) {
-               nv->dri_drawable = driDrawPriv;
-               st_resize_framebuffer(draw->stfb, driDrawPriv->w,
-                                     driDrawPriv->h);
-               nv->last_stamp = driDrawPriv->lastStamp;
-       }
-
-       if (driDrawPriv != driReadPriv) {
-               st_resize_framebuffer(read->stfb, driReadPriv->w,
-                                     driReadPriv->h);
-       }
-
-       return GL_TRUE;
-}
-
-GLboolean
-nouveau_context_unbind(__DRIcontextPrivate *driContextPriv)
-{
-       struct nouveau_context *nv = driContextPriv->driverPrivate;
-       (void)nv;
-
-       st_flush(nv->st, 0, NULL);
-       return GL_TRUE;
-}
-
diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_context.h b/src/gallium/winsys/drm/nouveau/dri/nouveau_context.h
deleted file mode 100644 (file)
index 2779b09..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef __NOUVEAU_CONTEXT_DRI_H__
-#define __NOUVEAU_CONTEXT_DRI_H__
-
-#include <dri_util.h>
-#include <xmlconfig.h>
-
-#include "nouveau/nouveau_winsys.h"
-
-#define NOUVEAU_ERR(fmt, args...) debug_printf("%s: "fmt, __func__, ##args)
-
-struct nouveau_framebuffer {
-       struct st_framebuffer *stfb;
-};
-
-struct nouveau_context {
-       struct st_context *st;
-
-       /* DRI stuff */
-       __DRIscreenPrivate    *dri_screen;
-       __DRIdrawablePrivate  *dri_drawable;
-       unsigned int           last_stamp;
-       driOptionCache         dri_option_cache;
-       drm_context_t          drm_context;
-       drmLock                drm_lock;
-       int                    locked;
-};
-
-extern GLboolean nouveau_context_create(const __GLcontextModes *,
-                                       __DRIcontextPrivate *, void *);
-extern void nouveau_context_destroy(__DRIcontextPrivate *);
-extern GLboolean nouveau_context_bind(__DRIcontextPrivate *,
-                                     __DRIdrawablePrivate *draw,
-                                     __DRIdrawablePrivate *read);
-extern GLboolean nouveau_context_unbind(__DRIcontextPrivate *);
-
-extern void nouveau_contended_lock(struct nouveau_context *nv);
-extern void LOCK_HARDWARE(struct nouveau_context *nv);
-extern void UNLOCK_HARDWARE(struct nouveau_context *nv);
-
-#ifdef DEBUG
-extern int __nouveau_debug;
-
-#define DEBUG_BO (1 << 0)
-
-#define DBG(flag, ...) do {                   \
-       if (__nouveau_debug & (DEBUG_##flag)) \
-               NOUVEAU_ERR(__VA_ARGS__);     \
-} while(0)
-#else
-#define DBG(flag, ...)
-#endif
-
-#endif
diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_dri.h b/src/gallium/winsys/drm/nouveau/dri/nouveau_dri.h
deleted file mode 100644 (file)
index 1207c2d..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef _NOUVEAU_DRI_
-#define _NOUVEAU_DRI_
-
-#include "xf86drm.h"
-#include "drm.h"
-#include "nouveau_drm.h"
-
-struct nouveau_dri {
-       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 */
-
-};
-
-#endif
-
diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_lock.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_lock.c
deleted file mode 100644 (file)
index 92f5bd0..0000000
+++ /dev/null
@@ -1,73 +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 <pipe/p_thread.h>
-#include "nouveau_context.h"
-#include "nouveau_screen.h"
-#include "nouveau_drmif.h"
-
-pipe_static_mutex(lockMutex);
-
-/* Lock the hardware and validate our state.
- */
-void
-LOCK_HARDWARE(struct nouveau_context *nv)
-{
-       struct nouveau_screen *nv_screen = nv->dri_screen->private;
-       struct nouveau_device *dev = nv_screen->device;
-       struct nouveau_device_priv *nvdev = nouveau_device(dev);
-       char __ret=0;
-
-       assert(!nv->locked);
-       pipe_mutex_lock(lockMutex);
-
-       DRM_CAS(nvdev->lock, nvdev->ctx,
-               (DRM_LOCK_HELD | nvdev->ctx), __ret);
-
-       if (__ret) {
-               drmGetLock(nvdev->fd, nvdev->ctx, 0);
-               nouveau_contended_lock(nv);
-       }
-       nv->locked = 1;
-}
-
-/* Unlock the hardware using the global current context 
- */
-void
-UNLOCK_HARDWARE(struct nouveau_context *nv)
-{
-       struct nouveau_screen *nv_screen = nv->dri_screen->private;
-       struct nouveau_device *dev = nv_screen->device;
-       struct nouveau_device_priv *nvdev = nouveau_device(dev);
-
-       assert(nv->locked);
-       nv->locked = 0;
-
-       DRM_UNLOCK(nvdev->fd, nvdev->lock, nvdev->ctx);
-
-       pipe_mutex_unlock(lockMutex);
-} 
diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c
deleted file mode 100644 (file)
index 4e9b76a..0000000
+++ /dev/null
@@ -1,330 +0,0 @@
-#include <utils.h>
-#include <vblank.h>
-#include <xmlpool.h>
-
-#include <pipe/p_context.h>
-#include <state_tracker/st_public.h>
-#include <state_tracker/st_cb_fbo.h>
-#include <state_tracker/drm_api.h>
-
-#include "nouveau_context.h"
-#include "nouveau_screen.h"
-#include "nouveau_swapbuffers.h"
-#include "nouveau_dri.h"
-
-#include "nouveau_drm.h"
-#include "nouveau_drmif.h"
-
-#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 12
-#error nouveau_drm.h version does not match expected version
-#endif
-
-/* Extension stuff, enabling of extensions handled by Gallium's GL state
- * tracker.  But, we still need to define the entry points we want.
- */
-#define need_GL_ARB_fragment_program
-#define need_GL_ARB_multisample
-#define need_GL_ARB_occlusion_query
-#define need_GL_ARB_point_parameters
-#define need_GL_ARB_shader_objects
-#define need_GL_ARB_texture_compression
-#define need_GL_ARB_vertex_program
-#define need_GL_ARB_vertex_shader
-#define need_GL_ARB_vertex_buffer_object
-#define need_GL_EXT_compiled_vertex_array
-#define need_GL_EXT_fog_coord
-#define need_GL_EXT_secondary_color
-#define need_GL_EXT_framebuffer_object
-#define need_GL_VERSION_2_0
-#define need_GL_VERSION_2_1
-#include "extension_helper.h"
-
-const struct dri_extension card_extensions[] =
-{
-       { "GL_ARB_multisample", GL_ARB_multisample_functions },
-       { "GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions },
-       { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions },
-       { "GL_ARB_shader_objects", GL_ARB_shader_objects_functions },
-       { "GL_ARB_shading_language_100", GL_VERSION_2_0_functions },
-       { "GL_ARB_shading_language_120", GL_VERSION_2_1_functions },
-       { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions },
-       { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions },
-       { "GL_ARB_vertex_shader", GL_ARB_vertex_shader_functions },
-       { "GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions },
-       { "GL_EXT_compiled_vertex_array", GL_EXT_compiled_vertex_array_functions },
-       { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions },
-       { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions },
-       { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions },
-       { NULL, 0 }
-};
-
-PUBLIC const char __driConfigOptions[] =
-DRI_CONF_BEGIN
-DRI_CONF_END;
-static const GLuint __driNConfigOptions = 0;
-
-extern const struct dri_extension common_extensions[];
-extern const struct dri_extension nv40_extensions[];
-
-static GLboolean
-nouveau_create_buffer(__DRIscreenPrivate * driScrnPriv,
-                     __DRIdrawablePrivate * driDrawPriv,
-                     const __GLcontextModes *glVis, GLboolean pixmapBuffer)
-{
-       struct nouveau_framebuffer *nvfb;
-       enum pipe_format colour, depth, stencil;
-
-       if (pixmapBuffer)
-               return GL_FALSE;
-
-       nvfb = CALLOC_STRUCT(nouveau_framebuffer);
-       if (!nvfb)
-               return GL_FALSE;
-
-       if (glVis->redBits == 5)
-               colour = PIPE_FORMAT_R5G6B5_UNORM;
-       else
-               colour = PIPE_FORMAT_A8R8G8B8_UNORM;
-
-       if (glVis->depthBits == 16)
-               depth = PIPE_FORMAT_Z16_UNORM;
-       else if (glVis->depthBits == 24)
-               depth = PIPE_FORMAT_Z24S8_UNORM;
-       else
-               depth = PIPE_FORMAT_NONE;
-
-       if (glVis->stencilBits == 8)
-               stencil = PIPE_FORMAT_Z24S8_UNORM;
-       else
-               stencil = PIPE_FORMAT_NONE;
-
-       nvfb->stfb = st_create_framebuffer(glVis, colour, depth, stencil,
-                                          driDrawPriv->w, driDrawPriv->h,
-                                          (void*)nvfb);
-       if (!nvfb->stfb) {
-               free(nvfb);
-               return  GL_FALSE;
-       }
-
-       driDrawPriv->driverPrivate = (void *)nvfb;
-       return GL_TRUE;
-}
-
-static void
-nouveau_destroy_buffer(__DRIdrawablePrivate * driDrawPriv)
-{
-       struct nouveau_framebuffer *nvfb;
-       
-       nvfb = (struct nouveau_framebuffer *)driDrawPriv->driverPrivate;
-       st_unreference_framebuffer(nvfb->stfb);
-       free(nvfb);
-}
-
-static __DRIconfig **
-nouveau_fill_in_modes(__DRIscreenPrivate *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;
-
-       static const GLenum back_buffer_modes[] = {
-               GLX_NONE, GLX_SWAP_UNDEFINED_OML,
-       };
-
-       uint8_t depth_bits_array[3];
-       uint8_t stencil_bits_array[3];
-       uint8_t msaa_samples_array[1];
-
-       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;
-
-       msaa_samples_array[0] = 0;
-
-       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, msaa_samples_array, 1);
-       if (configs == NULL) {
-        fprintf(stderr, "[%s:%u] Error creating FBConfig!\n",
-                        __func__, __LINE__);
-               return NULL;
-       }
-
-       return configs;
-}
-
-static struct pipe_surface *
-dri_surface_from_handle(struct pipe_screen *screen,
-                        unsigned handle,
-                        enum pipe_format format,
-                        unsigned width,
-                        unsigned height,
-                        unsigned pitch)
-{
-   struct pipe_surface *surface = NULL;
-   struct pipe_texture *texture = NULL;
-   struct pipe_texture templat;
-   struct pipe_buffer *buf = NULL;
-
-   buf = drm_api_hooks.buffer_from_handle(screen, "front buffer", handle);
-   if (!buf)
-      return NULL;
-
-   memset(&templat, 0, sizeof(templat));
-   templat.tex_usage = PIPE_TEXTURE_USAGE_PRIMARY |
-                       NOUVEAU_TEXTURE_USAGE_LINEAR;
-   templat.target = PIPE_TEXTURE_2D;
-   templat.last_level = 0;
-   templat.depth[0] = 1;
-   templat.format = format;
-   templat.width[0] = width;
-   templat.height[0] = height;
-   pf_get_block(templat.format, &templat.block);
-
-   texture = screen->texture_blanket(screen,
-                                     &templat,
-                                     &pitch,
-                                     buf);
-
-   /* we don't need the buffer from this point on */
-   pipe_buffer_reference(&buf, NULL);
-
-   if (!texture)
-      return NULL;
-
-   surface = screen->get_tex_surface(screen, texture, 0, 0, 0,
-                                     PIPE_BUFFER_USAGE_GPU_READ |
-                                     PIPE_BUFFER_USAGE_GPU_WRITE);
-
-   /* we don't need the texture from this point on */
-   pipe_texture_reference(&texture, NULL);
-   return surface;
-}
-
-static const __DRIconfig **
-nouveau_screen_create(__DRIscreenPrivate *psp)
-{
-       struct nouveau_dri *nv_dri = psp->pDevPriv;
-       struct nouveau_screen *nv_screen;
-       static const __DRIversion ddx_expected =
-               { 0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL };
-       static const __DRIversion dri_expected = { 4, 0, 0 };
-       static const __DRIversion drm_expected =
-               { 0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL };
-
-       if (!driCheckDriDdxDrmVersions2("nouveau",
-                                       &psp->dri_version, &dri_expected,
-                                       &psp->ddx_version, &ddx_expected,
-                                       &psp->drm_version, &drm_expected)) {
-               return NULL;
-       }
-
-       if (drm_expected.patch != psp->drm_version.patch) {
-               fprintf(stderr, "Incompatible DRM patch level.\n"
-                               "Expected: %d\n" "Current : %d\n",
-                       drm_expected.patch, psp->drm_version.patch);
-               return NULL;
-       }
-
-       driInitExtensions(NULL, card_extensions, GL_FALSE);
-
-       if (psp->devPrivSize != sizeof(struct nouveau_dri)) {
-               NOUVEAU_ERR("DRI struct mismatch between DDX/DRI\n");
-               return NULL;
-       }
-
-       nv_screen = CALLOC_STRUCT(nouveau_screen);
-       if (!nv_screen)
-               return NULL;
-
-       nouveau_device_open_existing(&nv_screen->device, 0, psp->fd, 0);
-
-       nv_screen->pscreen = drm_api_hooks.create_screen(psp->fd, NULL);
-       if (!nv_screen->pscreen) {
-               FREE(nv_screen);
-               return NULL;
-       }
-       nv_screen->pscreen->flush_frontbuffer = nouveau_flush_frontbuffer;
-
-       {
-               enum pipe_format format;
-
-               if (nv_dri->bpp == 16)
-                       format = PIPE_FORMAT_R5G6B5_UNORM;
-               else
-                       format = PIPE_FORMAT_A8R8G8B8_UNORM;
-
-               nv_screen->fb = dri_surface_from_handle(nv_screen->pscreen,
-                                                       nv_dri->front_offset,
-                                                       format,
-                                                       nv_dri->width,
-                                                       nv_dri->height,
-                                                       nv_dri->front_pitch *
-                                                       nv_dri->bpp / 8);
-       }
-                                               
-       driParseOptionInfo(&nv_screen->option_cache,
-                          __driConfigOptions, __driNConfigOptions);
-
-       nv_screen->driScrnPriv = psp;
-       psp->private = (void *)nv_screen;
-
-       return (const __DRIconfig **)
-               nouveau_fill_in_modes(psp, nv_dri->bpp,
-                                     (nv_dri->bpp == 16) ? 16 : 24,
-                                     (nv_dri->bpp == 16) ? 0 : 8, 1);
-}
-
-static void
-nouveau_screen_destroy(__DRIscreenPrivate *driScrnPriv)
-{
-       struct nouveau_screen *nv_screen = driScrnPriv->private;
-
-       driScrnPriv->private = NULL;
-       FREE(nv_screen);
-}
-
-const struct __DriverAPIRec
-driDriverAPI = {
-       .InitScreen     = nouveau_screen_create,
-       .DestroyScreen  = nouveau_screen_destroy,
-       .CreateContext  = nouveau_context_create,
-       .DestroyContext = nouveau_context_destroy,
-       .CreateBuffer   = nouveau_create_buffer,
-       .DestroyBuffer  = nouveau_destroy_buffer,
-       .SwapBuffers    = nouveau_swap_buffers,
-       .MakeCurrent    = nouveau_context_bind,
-       .UnbindContext  = nouveau_context_unbind,
-       .CopySubBuffer  = nouveau_copy_sub_buffer,
-
-       .InitScreen2    = NULL, /* one day, I promise! */
-};
-
diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.h b/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.h
deleted file mode 100644 (file)
index ac078f3..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef __NOUVEAU_SCREEN_DRI_H__
-#define __NOUVEAU_SCREEN_DRI_H__
-
-#include "xmlconfig.h"
-
-struct nouveau_screen {
-       __DRIscreenPrivate *driScrnPriv;
-       driOptionCache      option_cache;
-
-       struct nouveau_device *device;
-
-       struct pipe_screen *pscreen;
-       struct pipe_surface *fb;
-};
-
-#endif
diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.c
deleted file mode 100644 (file)
index 9c841a0..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-#include <main/glheader.h>
-#include <glapi/glthread.h>
-#include <GL/internal/glcore.h>
-
-#include <pipe/p_context.h>
-#include <state_tracker/st_public.h>
-#include <state_tracker/st_context.h>
-#include <state_tracker/st_cb_fbo.h>
-
-#include "nouveau_context.h"
-#include "nouveau_screen.h"
-#include "nouveau_swapbuffers.h"
-
-#include "nouveau_pushbuf.h"
-
-void
-nouveau_copy_buffer(__DRIdrawablePrivate *dPriv, struct pipe_surface *surf,
-                   const drm_clip_rect_t *rect)
-{
-       struct nouveau_context *nv = dPriv->driContextPriv->driverPrivate;
-       struct nouveau_screen *nv_screen = nv->dri_screen->private;
-       struct pipe_context *pipe = nv->st->pipe;
-       drm_clip_rect_t *pbox;
-       int nbox, i;
-
-       LOCK_HARDWARE(nv);
-       if (!dPriv->numClipRects) {
-               UNLOCK_HARDWARE(nv);
-               return;
-       }
-       pbox = dPriv->pClipRects;
-       nbox = dPriv->numClipRects;
-
-       for (i = 0; i < nbox; i++, pbox++) {
-               int sx, sy, dx, dy, w, h;
-
-               sx = pbox->x1 - dPriv->x;
-               sy = pbox->y1 - dPriv->y;
-               dx = pbox->x1;
-               dy = pbox->y1;
-               w  = pbox->x2 - pbox->x1;
-               h  = pbox->y2 - pbox->y1;
-
-               pipe->surface_copy(pipe, nv_screen->fb, dx, dy, surf,
-                                  sx, sy, w, h);
-       }
-
-       pipe->flush(pipe, 0, NULL);
-       UNLOCK_HARDWARE(nv);
-
-       if (nv->last_stamp != dPriv->lastStamp) {
-               struct nouveau_framebuffer *nvfb = dPriv->driverPrivate;
-               st_resize_framebuffer(nvfb->stfb, dPriv->w, dPriv->h);
-               nv->last_stamp = dPriv->lastStamp;
-       }
-}
-
-void
-nouveau_copy_sub_buffer(__DRIdrawablePrivate *dPriv, int x, int y, int w, int h)
-{
-       struct nouveau_framebuffer *nvfb = dPriv->driverPrivate;
-       struct pipe_surface *surf;
-
-       st_get_framebuffer_surface(nvfb->stfb, ST_SURFACE_BACK_LEFT, &surf);
-       if (surf) {
-               drm_clip_rect_t rect;
-               rect.x1 = x;
-               rect.y1 = y;
-               rect.x2 = x + w;
-               rect.y2 = y + h;
-
-               st_notify_swapbuffers(nvfb->stfb);
-               nouveau_copy_buffer(dPriv, surf, &rect);
-       }
-}
-
-void
-nouveau_swap_buffers(__DRIdrawablePrivate *dPriv)
-{
-       struct nouveau_framebuffer *nvfb = dPriv->driverPrivate;
-       struct pipe_surface *surf;
-
-       st_get_framebuffer_surface(nvfb->stfb, ST_SURFACE_BACK_LEFT, &surf);
-       if (surf) {
-               st_notify_swapbuffers(nvfb->stfb);
-               nouveau_copy_buffer(dPriv, surf, NULL);
-       }
-}
-
-void
-nouveau_flush_frontbuffer(struct pipe_screen *pscreen, struct pipe_surface *ps,
-                         void *context_private)
-{
-       struct nouveau_context *nv = context_private;
-       __DRIdrawablePrivate *dPriv = nv->dri_drawable;
-
-       nouveau_copy_buffer(dPriv, ps, NULL);
-}
-
-void
-nouveau_contended_lock(struct nouveau_context *nv)
-{
-       struct nouveau_context *nv_sub = (struct nouveau_context*)nv;
-       __DRIdrawablePrivate *dPriv = nv_sub->dri_drawable;
-       __DRIscreenPrivate *sPriv = nv_sub->dri_screen;
-
-       /* 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);
-}
-
diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.h b/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.h
deleted file mode 100644 (file)
index 4ca9cc2..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef __NOUVEAU_SWAPBUFFERS_H__
-#define __NOUVEAU_SWAPBUFFERS_H__
-
-void nouveau_copy_buffer(__DRIdrawablePrivate *, struct pipe_surface *,
-                        const drm_clip_rect_t *);
-void nouveau_copy_sub_buffer(__DRIdrawablePrivate *, int x, int y, int w, int h);
-void nouveau_swap_buffers(__DRIdrawablePrivate *);
-void nouveau_flush_frontbuffer(struct pipe_screen *, struct pipe_surface *,
-                              void *context_private);
-
-#endif
diff --git a/src/gallium/winsys/drm/nouveau/dri2/Makefile b/src/gallium/winsys/drm/nouveau/dri2/Makefile
deleted file mode 100644 (file)
index 377a80d..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = nouveau_dri2.so
-
-PIPE_DRIVERS = \
-       $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \
-       $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
-       $(TOP)/src/gallium/drivers/nv04/libnv04.a \
-       $(TOP)/src/gallium/drivers/nv10/libnv10.a \
-       $(TOP)/src/gallium/drivers/nv20/libnv20.a \
-       $(TOP)/src/gallium/drivers/nv30/libnv30.a \
-       $(TOP)/src/gallium/drivers/nv40/libnv40.a \
-       $(TOP)/src/gallium/drivers/nv50/libnv50.a
-
-DRIVER_SOURCES =
-
-C_SOURCES = \
-       $(COMMON_GALLIUM_SOURCES) \
-       $(DRIVER_SOURCES)
-
-include ../../Makefile.template
-
-DRI_LIB_DEPS += $(shell pkg-config libdrm_nouveau --libs)
-
-symlinks:
index 2da78d8690faa5c0f13e94255ac4e40620ead1e5..54c3b26c755ede7f50fb29246393cc630451ed93 100644 (file)
@@ -3,9 +3,7 @@ include $(TOP)/configs/current
 
 LIBNAME = nouveaudrm
 
-C_SOURCES = nouveau_drm_api.c \
-           nouveau_winsys_pipe.c \
-           nouveau_winsys.c
+C_SOURCES = nouveau_drm_api.c
 
 LIBRARY_INCLUDES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-I)
 LIBRARY_DEFINES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-other)
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_dri.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_dri.h
new file mode 100644 (file)
index 0000000..1207c2d
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef _NOUVEAU_DRI_
+#define _NOUVEAU_DRI_
+
+#include "xf86drm.h"
+#include "drm.h"
+#include "nouveau_drm.h"
+
+struct nouveau_dri {
+       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 */
+
+};
+
+#endif
+
index a558fda1401fa2b70400ed4b08917ff80b1e6296..395b21ec7ab7e36acad6f58ebb67f12fa384956d 100644 (file)
@@ -1,20 +1,83 @@
+#include "pipe/p_context.h"
+#include "pipe/p_state.h"
 #include "util/u_memory.h"
 
 #include "nouveau_drm_api.h"
-#include "nouveau_winsys_pipe.h"
 
 #include "nouveau_drmif.h"
 #include "nouveau_channel.h"
 #include "nouveau_bo.h"
 
+#include "nouveau/nouveau_winsys.h"
+#include "nouveau/nouveau_screen.h"
+
+static struct pipe_surface *
+dri_surface_from_handle(struct pipe_screen *screen,
+                        unsigned handle,
+                        enum pipe_format format,
+                        unsigned width,
+                        unsigned height,
+                        unsigned pitch)
+{
+   struct pipe_surface *surface = NULL;
+   struct pipe_texture *texture = NULL;
+   struct pipe_texture templat;
+   struct pipe_buffer *buf = NULL;
+
+   buf = drm_api_hooks.buffer_from_handle(screen, "front buffer", handle);
+   if (!buf)
+      return NULL;
+
+   memset(&templat, 0, sizeof(templat));
+   templat.tex_usage = PIPE_TEXTURE_USAGE_PRIMARY |
+                       NOUVEAU_TEXTURE_USAGE_LINEAR;
+   templat.target = PIPE_TEXTURE_2D;
+   templat.last_level = 0;
+   templat.depth[0] = 1;
+   templat.format = format;
+   templat.width[0] = width;
+   templat.height[0] = height;
+   pf_get_block(templat.format, &templat.block);
+
+   texture = screen->texture_blanket(screen,
+                                     &templat,
+                                     &pitch,
+                                     buf);
+
+   /* we don't need the buffer from this point on */
+   pipe_buffer_reference(&buf, NULL);
+
+   if (!texture)
+      return NULL;
+
+   surface = screen->get_tex_surface(screen, texture, 0, 0, 0,
+                                     PIPE_BUFFER_USAGE_GPU_READ |
+                                     PIPE_BUFFER_USAGE_GPU_WRITE);
+
+   /* we don't need the texture from this point on */
+   pipe_texture_reference(&texture, NULL);
+   return surface;
+}
+
+static struct pipe_surface *
+nouveau_dri1_front_surface(struct pipe_context *pipe)
+{
+       return nouveau_winsys_screen(pipe->screen)->front;
+}
+
+static struct dri1_api nouveau_dri1_api = {
+       nouveau_dri1_front_surface,
+};
+
 static struct pipe_screen *
 nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg)
 {
-       struct pipe_winsys *ws;
+       struct dri1_create_screen_arg *dri1 = (void *)arg;
        struct nouveau_winsys *nvws;
+       struct pipe_winsys *ws;
        struct nouveau_device *dev = NULL;
        struct pipe_screen *(*init)(struct pipe_winsys *,
-                                   struct nouveau_winsys *);
+                                   struct nouveau_device *);
        int ret;
 
        ret = nouveau_device_open_existing(&dev, 0, fd, 0);
@@ -49,33 +112,54 @@ nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg)
                return NULL;
        }
 
-       ws = nouveau_pipe_winsys_new(dev);
-       if (!ws) {
+       nvws = CALLOC_STRUCT(nouveau_winsys);
+       if (!nvws) {
                nouveau_device_close(&dev);
                return NULL;
        }
+       ws = &nvws->base;
 
-       nvws = nouveau_winsys_new(ws);
-       if (!nvws) {
+       nvws->pscreen = init(ws, dev);
+       if (!nvws->pscreen) {
                ws->destroy(ws);
                return NULL;
        }
 
-       nouveau_pipe_winsys(ws)->pscreen = init(ws, nvws);
-       if (!nouveau_pipe_winsys(ws)->pscreen) {
-               ws->destroy(ws);
-               return NULL;
+       if (arg->mode == DRM_CREATE_DRI1) {
+               struct nouveau_dri *nvdri = dri1->ddx_info;
+               enum pipe_format format;
+
+               if (nvdri->bpp == 16)
+                       format = PIPE_FORMAT_R5G6B5_UNORM;
+               else
+                       format = PIPE_FORMAT_A8R8G8B8_UNORM;
+
+               nvws->front = dri_surface_from_handle(nvws->pscreen,
+                                                      nvdri->front_offset,
+                                                      format,
+                                                      nvdri->width,
+                                                      nvdri->height,
+                                                      nvdri->front_pitch *
+                                                      (nvdri->bpp / 8));
+               if (!nvws->front) {
+                       debug_printf("%s: error referencing front buffer\n",
+                                    __func__);
+                       ws->destroy(ws);
+                       return NULL;
+               }
+
+               dri1->api = &nouveau_dri1_api;
        }
 
-       return nouveau_pipe_winsys(ws)->pscreen;
+       return nvws->pscreen;
 }
 
 static struct pipe_context *
 nouveau_drm_create_context(struct pipe_screen *pscreen)
 {
-       struct nouveau_pipe_winsys *nvpws = nouveau_screen(pscreen);
+       struct nouveau_winsys *nvws = nouveau_winsys_screen(pscreen);
        struct pipe_context *(*init)(struct pipe_screen *, unsigned);
-       unsigned chipset = nvpws->channel->device->chipset;
+       unsigned chipset = nouveau_screen(pscreen)->device->chipset;
        int i;
 
        switch (chipset & 0xf0) {
@@ -106,19 +190,19 @@ nouveau_drm_create_context(struct pipe_screen *pscreen)
        }
 
        /* Find a free slot for a pipe context, allocate a new one if needed */
-       for (i = 0; i < nvpws->nr_pctx; i++) {
-               if (nvpws->pctx[i] == NULL)
+       for (i = 0; i < nvws->nr_pctx; i++) {
+               if (nvws->pctx[i] == NULL)
                        break;
        }
 
-       if (i == nvpws->nr_pctx) {
-               nvpws->nr_pctx++;
-               nvpws->pctx = realloc(nvpws->pctx,
-                                     sizeof(*nvpws->pctx) * nvpws->nr_pctx);
+       if (i == nvws->nr_pctx) {
+               nvws->nr_pctx++;
+               nvws->pctx = realloc(nvws->pctx,
+                                     sizeof(*nvws->pctx) * nvws->nr_pctx);
        }
 
-       nvpws->pctx[i] = init(pscreen, i);
-       return nvpws->pctx[i];
+       nvws->pctx[i] = init(pscreen, i);
+       return nvws->pctx[i];
 }
 
 static boolean
@@ -132,42 +216,41 @@ static struct pipe_buffer *
 nouveau_drm_pb_from_handle(struct pipe_screen *pscreen, const char *name,
                           unsigned handle)
 {
-       struct nouveau_pipe_winsys *nvpws = nouveau_screen(pscreen);
-       struct nouveau_device *dev = nvpws->channel->device;
-       struct nouveau_pipe_buffer *nvpb;
+       struct nouveau_device *dev = nouveau_screen(pscreen)->device;
+       struct pipe_buffer *pb;
        int ret;
 
-       nvpb = CALLOC_STRUCT(nouveau_pipe_buffer);
-       if (!nvpb)
+       pb = CALLOC(1, sizeof(struct pipe_buffer) + sizeof(struct nouveau_bo*));
+       if (!pb)
                return NULL;
 
-       ret = nouveau_bo_handle_ref(dev, handle, &nvpb->bo);
+       ret = nouveau_bo_handle_ref(dev, handle, (struct nouveau_bo**)(pb+1));
        if (ret) {
                debug_printf("%s: ref name 0x%08x failed with %d\n",
                             __func__, handle, ret);
-               FREE(nvpb);
+               FREE(pb);
                return NULL;
        }
 
-       pipe_reference_init(&nvpb->base.reference, 1);
-       nvpb->base.screen = pscreen;
-       nvpb->base.alignment = 0;
-       nvpb->base.usage = PIPE_BUFFER_USAGE_GPU_READ_WRITE |
-                          PIPE_BUFFER_USAGE_CPU_READ_WRITE;
-       nvpb->base.size = nvpb->bo->size;
-       return &nvpb->base;
+       pipe_reference_init(&pb->reference, 1);
+       pb->screen = pscreen;
+       pb->alignment = 0;
+       pb->usage = PIPE_BUFFER_USAGE_GPU_READ_WRITE |
+                   PIPE_BUFFER_USAGE_CPU_READ_WRITE;
+       pb->size = nouveau_bo(pb)->size;
+       return pb;
 }
 
 static boolean
 nouveau_drm_handle_from_pb(struct pipe_screen *pscreen, struct pipe_buffer *pb,
                           unsigned *handle)
 {
-       struct nouveau_pipe_buffer *nvpb = nouveau_pipe_buffer(pb);
+       struct nouveau_bo *bo = nouveau_bo(pb);
 
-       if (!nvpb)
+       if (!bo)
                return FALSE;
 
-       *handle = nvpb->bo->handle;
+       *handle = bo->handle;
        return TRUE;
 }
 
@@ -175,12 +258,12 @@ static boolean
 nouveau_drm_name_from_pb(struct pipe_screen *pscreen, struct pipe_buffer *pb,
                         unsigned *handle)
 {
-       struct nouveau_pipe_buffer *nvpb = nouveau_pipe_buffer(pb);
+       struct nouveau_bo *bo = nouveau_bo(pb);
 
-       if (!nvpb)
+       if (!bo)
                return FALSE;
 
-       return nouveau_bo_handle_get(nvpb->bo, handle) == 0;
+       return nouveau_bo_handle_get(bo, handle) == 0;
 }
 
 struct drm_api drm_api_hooks = {
index 2782c83c0e7390b5b98efd1f02a764bfc9008cb0..e61e0e0957a63dd6975f0c678d3eb9d1bd4e6755 100644 (file)
@@ -1,5 +1,34 @@
 #ifndef __NOUVEAU_DRM_API_H__
 #define __NOUVEAU_DRM_API_H__
+
 #include "state_tracker/drm_api.h"
+#include "state_tracker/dri1_api.h"
+
+#include "pipe/internal/p_winsys_screen.h"
+
+#include "nouveau_dri.h"
+
+struct nouveau_winsys {
+       struct pipe_winsys base;
+
+       struct pipe_screen *pscreen;
+
+       unsigned nr_pctx;
+       struct pipe_context **pctx;
+
+       struct pipe_surface *front;
+};
+
+static INLINE struct nouveau_winsys *
+nouveau_winsys(struct pipe_winsys *ws)
+{
+       return (struct nouveau_winsys *)ws;
+}
+
+static INLINE struct nouveau_winsys *
+nouveau_winsys_screen(struct pipe_screen *pscreen)
+{
+       return nouveau_winsys(pscreen->winsys);
+}
 
 #endif
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c
deleted file mode 100644 (file)
index e3175fd..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-#include "util/u_memory.h"
-
-#include "nouveau_winsys_pipe.h"
-
-static int
-nouveau_pipe_notifier_alloc(struct nouveau_winsys *nvws, int count,
-                           struct nouveau_notifier **notify)
-{
-       struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(nvws->ws);
-
-       return nouveau_notifier_alloc(nvpws->channel, nvpws->next_handle++,
-                                     count, notify);
-}
-
-static int
-nouveau_pipe_grobj_alloc(struct nouveau_winsys *nvws, int grclass,
-                        struct nouveau_grobj **grobj)
-{
-       struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(nvws->ws);
-       struct nouveau_channel *chan = nvpws->channel;
-       int ret;
-
-       ret = nouveau_grobj_alloc(chan, nvpws->next_handle++, grclass, grobj);
-       if (ret)
-               return ret;
-
-       BEGIN_RING(chan, *grobj, 0x0000, 1);
-       OUT_RING  (chan, (*grobj)->handle);
-       (*grobj)->bound = NOUVEAU_GROBJ_BOUND_EXPLICIT;
-       return 0;
-}
-
-static int
-nouveau_pipe_push_reloc(struct nouveau_winsys *nvws, void *ptr,
-                       struct pipe_buffer *buf, uint32_t data,
-                       uint32_t flags, uint32_t vor, uint32_t tor)
-{
-       struct nouveau_bo *bo = nouveau_pipe_buffer(buf)->bo;
-
-       return nouveau_pushbuf_emit_reloc(nvws->channel, ptr, bo,
-                                         data, flags, vor, tor);
-}
-
-static int
-nouveau_pipe_push_flush(struct nouveau_winsys *nvws, unsigned size,
-                       struct pipe_fence_handle **fence)
-{
-       if (fence)
-               *fence = NULL;
-
-       return nouveau_pushbuf_flush(nvws->channel, size);
-}
-
-static struct nouveau_bo *
-nouveau_pipe_get_bo(struct pipe_buffer *pb)
-{
-       return nouveau_pipe_buffer(pb)->bo;
-}
-
-struct nouveau_winsys *
-nouveau_winsys_new(struct pipe_winsys *ws)
-{
-       struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
-       struct nouveau_winsys *nvws;
-
-       nvws = CALLOC_STRUCT(nouveau_winsys);
-       if (!nvws)
-               return NULL;
-
-       nvws->ws                = ws;
-       nvws->channel           = nvpws->channel;
-
-       nvws->res_init          = nouveau_resource_init;
-       nvws->res_alloc         = nouveau_resource_alloc;
-       nvws->res_free          = nouveau_resource_free;
-
-       nvws->push_reloc        = nouveau_pipe_push_reloc;
-       nvws->push_flush        = nouveau_pipe_push_flush;
-
-       nvws->grobj_alloc       = nouveau_pipe_grobj_alloc;
-       nvws->grobj_free        = nouveau_grobj_free;
-
-       nvws->notifier_alloc    = nouveau_pipe_notifier_alloc;
-       nvws->notifier_free     = nouveau_notifier_free;
-       nvws->notifier_reset    = nouveau_notifier_reset;
-       nvws->notifier_status   = nouveau_notifier_status;
-       nvws->notifier_retval   = nouveau_notifier_return_val;
-       nvws->notifier_wait     = nouveau_notifier_wait_status;
-
-       nvws->get_bo            = nouveau_pipe_get_bo;
-
-       return nvws;
-}
-
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c
deleted file mode 100644 (file)
index 9e03a9f..0000000
+++ /dev/null
@@ -1,204 +0,0 @@
-#include "pipe/internal/p_winsys_screen.h"
-#include <pipe/p_defines.h>
-#include <pipe/p_inlines.h>
-#include <util/u_memory.h>
-
-#include "nouveau_winsys_pipe.h"
-
-#include "nouveau_drmif.h"
-#include "nouveau_bo.h"
-
-static const char *
-nouveau_get_name(struct pipe_winsys *pws)
-{
-       return "Nouveau/DRI";
-}
-
-static uint32_t
-nouveau_flags_from_usage(struct pipe_winsys *ws, unsigned usage)
-{
-       struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
-       struct pipe_screen *pscreen = nvpws->pscreen;
-       uint32_t flags = NOUVEAU_BO_LOCAL;
-
-       if (usage & NOUVEAU_BUFFER_USAGE_TRANSFER)
-               flags |= NOUVEAU_BO_GART;
-
-       if (usage & PIPE_BUFFER_USAGE_PIXEL) {
-               if (usage & NOUVEAU_BUFFER_USAGE_TEXTURE)
-                       flags |= NOUVEAU_BO_GART;
-               if (!(usage & PIPE_BUFFER_USAGE_CPU_READ_WRITE))
-                       flags |= NOUVEAU_BO_VRAM;
-
-               switch (nvpws->channel->device->chipset & 0xf0) {
-               case 0x50:
-               case 0x80:
-               case 0x90:
-                       flags |= NOUVEAU_BO_TILED;
-                       if (usage & NOUVEAU_BUFFER_USAGE_ZETA)
-                               flags |= NOUVEAU_BO_ZTILE;
-                       break;
-               default:
-                       break;
-               }
-       }
-
-       if (usage & PIPE_BUFFER_USAGE_VERTEX) {
-               if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_VTXBUF))
-                       flags |= NOUVEAU_BO_GART;
-       }
-
-       if (usage & PIPE_BUFFER_USAGE_INDEX) {
-               if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_IDXBUF))
-                       flags |= NOUVEAU_BO_GART;
-       }
-
-       return flags;
-}
-
-static struct pipe_buffer *
-nouveau_pipe_bo_create(struct pipe_winsys *ws, unsigned alignment,
-                      unsigned usage, unsigned size)
-{
-       struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
-       struct nouveau_device *dev = nvpws->channel->device;
-       struct nouveau_pipe_buffer *nvbuf;
-       uint32_t flags;
-
-       nvbuf = CALLOC_STRUCT(nouveau_pipe_buffer);
-       if (!nvbuf)
-               return NULL;
-       pipe_reference_init(&nvbuf->base.reference, 1);
-       nvbuf->base.alignment = alignment;
-       nvbuf->base.usage = usage;
-       nvbuf->base.size = size;
-
-       flags = nouveau_flags_from_usage(ws, usage);
-       if (nouveau_bo_new(dev, flags, alignment, size, &nvbuf->bo)) {
-               FREE(nvbuf);
-               return NULL;
-       }
-
-       return &nvbuf->base;
-}
-
-static struct pipe_buffer *
-nouveau_pipe_bo_user_create(struct pipe_winsys *ws, void *ptr, unsigned bytes)
-{
-       struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
-       struct nouveau_device *dev = nvpws->channel->device;
-       struct nouveau_pipe_buffer *nvbuf;
-
-       nvbuf = CALLOC_STRUCT(nouveau_pipe_buffer);
-       if (!nvbuf)
-               return NULL;
-       pipe_reference_init(&nvbuf->base.reference, 1);
-       nvbuf->base.size = bytes;
-
-       if (nouveau_bo_user(dev, ptr, bytes, &nvbuf->bo)) {
-               FREE(nvbuf);
-               return NULL;
-       }
-
-       return &nvbuf->base;
-}
-
-static void
-nouveau_pipe_bo_del(struct pipe_buffer *buf)
-{
-       struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf);
-
-       nouveau_bo_ref(NULL, &nvbuf->bo);
-       FREE(nvbuf);
-}
-
-static void *
-nouveau_pipe_bo_map(struct pipe_winsys *pws, struct pipe_buffer *buf,
-                   unsigned flags)
-{
-       struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf);
-       uint32_t map_flags = 0;
-
-       if (flags & PIPE_BUFFER_USAGE_CPU_READ)
-               map_flags |= NOUVEAU_BO_RD;
-       if (flags & PIPE_BUFFER_USAGE_CPU_WRITE)
-               map_flags |= NOUVEAU_BO_WR;
-
-       if (nouveau_bo_map(nvbuf->bo, map_flags))
-               return NULL;
-       return nvbuf->bo->map;
-}
-
-static void
-nouveau_pipe_bo_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf)
-{
-       struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf);
-
-       nouveau_bo_unmap(nvbuf->bo);
-}
-
-static void
-nouveau_pipe_fence_reference(struct pipe_winsys *ws,
-                            struct pipe_fence_handle **ptr,
-                            struct pipe_fence_handle *pfence)
-{
-       *ptr = pfence;
-}
-
-static int
-nouveau_pipe_fence_signalled(struct pipe_winsys *ws,
-                            struct pipe_fence_handle *pfence, unsigned flag)
-{
-       return 0;
-}
-
-static int
-nouveau_pipe_fence_finish(struct pipe_winsys *ws,
-                         struct pipe_fence_handle *pfence, unsigned flag)
-{
-       return 0;
-}
-
-static void
-nouveau_destroy(struct pipe_winsys *ws)
-{
-       struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
-
-       nouveau_device_close(&nvpws->channel->device);
-       FREE(nvpws);
-}
-
-struct pipe_winsys *
-nouveau_pipe_winsys_new(struct nouveau_device *dev)
-{
-       struct nouveau_pipe_winsys *nvpws;
-       int ret;
-
-       nvpws = CALLOC_STRUCT(nouveau_pipe_winsys);
-       if (!nvpws)
-               return NULL;
-
-       ret = nouveau_channel_alloc(dev, 0xbeef0201, 0xbeef0202,
-                                   &nvpws->channel);
-       if (ret) {
-               debug_printf("%s: error opening GPU channel: %d\n",
-                            __func__, ret);
-               FREE(nvpws);
-               return NULL;
-       }
-       nvpws->next_handle = 0x77000000;
-
-       nvpws->base.buffer_create = nouveau_pipe_bo_create;
-       nvpws->base.buffer_destroy = nouveau_pipe_bo_del;
-       nvpws->base.user_buffer_create = nouveau_pipe_bo_user_create;
-       nvpws->base.buffer_map = nouveau_pipe_bo_map;
-       nvpws->base.buffer_unmap = nouveau_pipe_bo_unmap;
-
-       nvpws->base.fence_reference = nouveau_pipe_fence_reference;
-       nvpws->base.fence_signalled = nouveau_pipe_fence_signalled;
-       nvpws->base.fence_finish = nouveau_pipe_fence_finish;
-
-       nvpws->base.get_name = nouveau_get_name;
-       nvpws->base.destroy = nouveau_destroy;
-       return &nvpws->base;
-}
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h
deleted file mode 100644 (file)
index 10e1e26..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef NOUVEAU_PIPE_WINSYS_H
-#define NOUVEAU_PIPE_WINSYS_H
-
-#include "pipe/internal/p_winsys_screen.h"
-#include "pipe/p_context.h"
-
-#include "nouveau/nouveau_winsys.h"
-
-#include "nouveau_device.h"
-
-struct nouveau_pipe_buffer {
-       struct pipe_buffer base;
-       struct nouveau_bo *bo;
-};
-
-static INLINE struct nouveau_pipe_buffer *
-nouveau_pipe_buffer(struct pipe_buffer *buf)
-{
-       return (struct nouveau_pipe_buffer *)buf;
-}
-
-struct nouveau_pipe_winsys {
-       struct pipe_winsys base;
-
-       struct pipe_screen *pscreen;
-
-       struct nouveau_channel *channel;
-       uint32_t next_handle;
-
-       unsigned nr_pctx;
-       struct pipe_context **pctx;
-};
-
-static INLINE struct nouveau_pipe_winsys *
-nouveau_pipe_winsys(struct pipe_winsys *ws)
-{
-       return (struct nouveau_pipe_winsys *)ws;
-}
-
-static INLINE struct nouveau_pipe_winsys *
-nouveau_screen(struct pipe_screen *pscreen)
-{
-       return nouveau_pipe_winsys(pscreen->winsys);
-}
-
-struct pipe_winsys *
-nouveau_pipe_winsys_new(struct nouveau_device *);
-
-struct nouveau_winsys *
-nouveau_winsys_new(struct pipe_winsys *ws);
-
-#endif
index a15487352b22dbce33c8125bb3c6430b4ac664fb..0d0fdc5bd86e17db44d4b6446ac2070e4cb2f007 100644 (file)
@@ -93,6 +93,29 @@ static struct pipe_buffer *radeon_buffer_user_create(struct pipe_winsys *ws,
     return &radeon_buffer->base;
 }
 
+static struct pipe_buffer *radeon_surface_buffer_create(struct pipe_winsys *ws,
+                                                        unsigned width,
+                                                        unsigned height,
+                                                        enum pipe_format format,
+                                                        unsigned usage,
+                                                        unsigned *stride)
+{
+    struct pipe_format_block block;
+    unsigned nblocksx, nblocksy, size;
+
+    pf_get_block(format, &block);
+
+    nblocksx = pf_get_nblocksx(&block, width);
+    nblocksy = pf_get_nblocksy(&block, height);
+
+    /* Radeons enjoy things in multiples of 32. */
+    /* XXX this can be 32 when POT */
+    *stride = (nblocksx * block.size + 63) & ~63;
+    size = *stride * nblocksy;
+
+    return radeon_buffer_create(ws, 64, usage, size);
+}
+
 static void radeon_buffer_del(struct pipe_buffer *buffer)
 {
     struct radeon_pipe_buffer *radeon_buffer =
@@ -180,10 +203,11 @@ struct radeon_winsys* radeon_pipe_winsys(int fd)
     radeon_ws->base.flush_frontbuffer = radeon_flush_frontbuffer;
 
     radeon_ws->base.buffer_create = radeon_buffer_create;
-    radeon_ws->base.buffer_destroy = radeon_buffer_del;
     radeon_ws->base.user_buffer_create = radeon_buffer_user_create;
+    radeon_ws->base.surface_buffer_create = radeon_surface_buffer_create;
     radeon_ws->base.buffer_map = radeon_buffer_map;
     radeon_ws->base.buffer_unmap = radeon_buffer_unmap;
+    radeon_ws->base.buffer_destroy = radeon_buffer_del;
 
     radeon_ws->base.fence_reference = radeon_fence_reference;
     radeon_ws->base.fence_signalled = radeon_fence_signalled;
index 428d3f65a169be009d8e00395b84e162bec203f1..5406d2bbea06b2545be6ffb328196560c553fb25 100644 (file)
 
 #include "radeon_drm.h"
 
+#ifdef DEBUG
+#include "trace/trace_drm.h"
+#endif
+
 /* Create a pipe_screen. */
 struct pipe_screen* radeon_create_screen(int drmFB,
                                         struct drm_create_screen_arg *arg)
@@ -112,7 +116,11 @@ boolean radeon_global_handle_from_buffer(struct pipe_screen* screen,
     return TRUE;
 }
 
+#ifdef DEBUG
+struct drm_api hooks = {
+#else
 struct drm_api drm_api_hooks = {
+#endif
     .create_screen = radeon_create_screen,
     .create_context = radeon_create_context,
     /* XXX fix this */
index da233203d7d8526183fd549f5741e389767dc99c..63aa3179ac88e80ebcc4d1240427996849ff5cac 100644 (file)
 
 #include "radeon_r300.h"
 
-static void radeon_r300_add_buffer(struct r300_winsys* winsys,
-                                   struct pipe_buffer* pbuffer,
-                                   uint32_t rd,
-                                   uint32_t wd)
+static boolean radeon_r300_add_buffer(struct r300_winsys* winsys,
+                                      struct pipe_buffer* pbuffer,
+                                      uint32_t rd,
+                                      uint32_t wd)
 {
     int i;
     struct radeon_winsys_priv* priv =
@@ -35,24 +35,30 @@ static void radeon_r300_add_buffer(struct r300_winsys* winsys,
 
     /* Check to see if this BO is already in line for validation;
      * find a slot for it otherwise. */
-    for (i = 0; i < RADEON_MAX_BOS; i++) {
+    for (i = 0; i < priv->bo_count; i++) {
         if (sc[i].bo == bo) {
-            return;
-        } else if (sc[i].bo == NULL) {
-            sc[i].bo = bo;
-            sc[i].read_domains = rd;
-            sc[i].write_domain = wd;
-            priv->bo_count = i + 1;
+            sc[i].read_domains |= rd;
+            sc[i].write_domain |= wd;
             return;
         }
     }
 
-    assert(FALSE && "Oh God too many BOs!");
+    if (priv->bo_count >= RADEON_MAX_BOS) {
+        /* Dohoho. Not falling for that one again. Request a flush. */
+        return FALSE;
+    }
+
+    sc[priv->bo_count].bo = bo;
+    sc[priv->bo_count].read_domains = rd;
+    sc[priv->bo_count].write_domain = wd;
+    priv->bo_count++;
+
+    return TRUE;
 }
 
 static boolean radeon_r300_validate(struct r300_winsys* winsys)
 {
-    int retval;
+    int retval, i;
     struct radeon_winsys_priv* priv =
         (struct radeon_winsys_priv*)winsys->radeon_winsys;
     struct radeon_cs_space_check* sc = priv->sc;
@@ -62,12 +68,23 @@ static boolean radeon_r300_validate(struct r300_winsys* winsys)
     if (retval == RADEON_CS_SPACE_OP_TO_BIG) {
         /* We might as well HCF, since this is not going to fit in the card,
          * period. */
+        /* XXX just drop it on the floor instead */
        exit(1);
     } else if (retval == RADEON_CS_SPACE_FLUSH) {
         /* We must flush before more rendering can commence. */
         return TRUE;
     }
 
+    /* XXX should probably be its own function */
+    for (i = 0; i < priv->bo_count; i++) {
+        if (sc[i].read_domains && sc[i].write_domain) {
+            /* Cute, cute. We need to flush first. */
+            debug_printf("radeon: BO %p can't be read and written; "
+                    "requesting flush.\n", sc[i].bo);
+            return TRUE;
+        }
+    }
+
     /* Things are fine, we can proceed as normal. */
     return FALSE;
 }
@@ -108,9 +125,15 @@ static void radeon_r300_write_cs_reloc(struct r300_winsys* winsys,
 {
     struct radeon_winsys_priv* priv =
         (struct radeon_winsys_priv*)winsys->radeon_winsys;
+    int retval = 0;
 
-    radeon_cs_write_reloc(priv->cs,
+    retval = radeon_cs_write_reloc(priv->cs,
             ((struct radeon_pipe_buffer*)pbuffer)->bo, rd, wd, flags);
+
+    if (retval) {
+        debug_printf("radeon: Relocation of %p (%d, %d, %d) failed!\n",
+                pbuffer, rd, wd, flags);
+    }
 }
 
 static void radeon_r300_end_cs(struct r300_winsys* winsys,
@@ -128,57 +151,63 @@ static void radeon_r300_flush_cs(struct r300_winsys* winsys)
 {
     struct radeon_winsys_priv* priv =
         (struct radeon_winsys_priv*)winsys->radeon_winsys;
-    int retval = 0;
+    struct radeon_cs_space_check* sc = priv->sc;
+    int retval = 1;
 
+    /* Emit the CS. */
     retval = radeon_cs_emit(priv->cs);
     if (retval) {
         debug_printf("radeon: Bad CS, dumping...\n");
         radeon_cs_print(priv->cs, stderr);
     }
     radeon_cs_erase(priv->cs);
+
+    /* Clean out BOs. */
+    memset(sc, 0, sizeof(struct radeon_cs_space_check) * RADEON_MAX_BOS);
+    priv->bo_count = 0;
 }
 
 /* Helper function to do the ioctls needed for setup and init. */
 static void do_ioctls(struct r300_winsys* winsys, int fd)
 {
-    struct drm_radeon_gem_info info;
-    drm_radeon_getparam_t gp;
-    int target;
+    struct drm_radeon_gem_info gem_info = {0};
+    drm_radeon_getparam_t gp = {0};
+    struct drm_radeon_info info = {0};
+    int target = 0;
     int retval;
 
+    info.value = &target;
     gp.value = &target;
 
-    /* First, get the number of pixel pipes */
-    gp.param = RADEON_PARAM_NUM_GB_PIPES;
-    retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp, sizeof(gp));
+    /* First, get PCI ID */
+    info.request = RADEON_INFO_DEVICE_ID;
+    retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
     if (retval) {
-        fprintf(stderr, "%s: Failed to get GB pipe count, error number %d\n",
+        fprintf(stderr, "%s: New ioctl for PCI ID failed "
+                "(error number %d), trying classic ioctl...\n",
                 __FUNCTION__, retval);
-        exit(1);
-    }
-    winsys->gb_pipes = target;
-
-    /* Then, get PCI ID */
-    gp.param = RADEON_PARAM_DEVICE_ID;
-    retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp, sizeof(gp));
-    if (retval) {
-        fprintf(stderr, "%s: Failed to get PCI ID, error number %d\n",
-                __FUNCTION__, retval);
-        exit(1);
+        gp.param = RADEON_PARAM_DEVICE_ID;
+        retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp,
+                sizeof(gp));
+        if (retval) {
+            fprintf(stderr, "%s: Failed to get PCI ID, "
+                    "error number %d\n", __FUNCTION__, retval);
+            exit(1);
+        }
     }
     winsys->pci_id = target;
 
-    /* Finally, retrieve MM info */
+    /* Then, retrieve MM info */
     retval = drmCommandWriteRead(fd, DRM_RADEON_GEM_INFO,
-            &info, sizeof(info));
+            &gem_info, sizeof(gem_info));
     if (retval) {
         fprintf(stderr, "%s: Failed to get MM info, error number %d\n",
                 __FUNCTION__, retval);
         exit(1);
     }
-    winsys->gart_size = info.gart_size;
+    winsys->gart_size = gem_info.gart_size;
     /* XXX */
-    winsys->vram_size = info.vram_visible;
+    winsys->vram_size = gem_info.vram_visible;
 }
 
 struct r300_winsys*
index 5c373cd0848594bbfda16133bbb0a33e8491a74d..a2e0e58248584f0b756363607f2d261191e970eb 100644 (file)
 
 #include "radeon_buffer.h"
 
+/* protect us from bonghits */
+#ifndef RADEON_INFO_DEVICE_ID
+#define RADEON_INFO_DEVICE_ID 0
+#endif
+#ifndef DRM_RADEON_INFO
+#define DRM_RADEON_INFO 0x1
+struct drm_radeon_info {
+       uint32_t                request;
+       uint32_t                pad;
+       uint64_t                value;
+};
+#endif
+
 struct r300_winsys*
 radeon_create_r300_winsys(int fd, struct radeon_winsys* old_winsys);
index c218ee9d0104eb3dcc568c552566c656345fd0d1..a9889444de8b47c1513275b3516f5343da47d8e9 100644 (file)
@@ -10,6 +10,7 @@ PIPE_DRIVERS = \
        $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \
        $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \
        $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
        $(TOP)/src/gallium/drivers/r300/libr300.a
 
 C_SOURCES = \
index d989b3aa935af48e63a59d7dca43ed4d30057181..6a1448d1b9ba0079f2a2d037401f41f1595cfa0a 100644 (file)
@@ -8,6 +8,7 @@ PIPE_DRIVERS = \
        $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \
        $(GALLIUMDIR)/winsys/drm/radeon/core/libradeonwinsys.a \
        $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
        $(TOP)/src/gallium/drivers/r300/libr300.a
 
 DRIVER_SOURCES =
index 6ffd4a3a541291c58702f1c2a02bcbb1bee5589a..0241625f69bf9343bc34ce2a64aed07235933fb6 100644 (file)
@@ -37,6 +37,6 @@ clean:
 
 install:
        $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
-       $(INSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+       $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
 
 .PHONY = all clean install
index 8646ee3b527c3b873c7074f7ed4639b104b94ef2..a33a50ec22bbefce8c9601012f16af190e89b649 100644 (file)
@@ -74,7 +74,7 @@ depend: $(ALL_SOURCES)
 install: default
        $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
        @if [ -e $(TOP)/$(LIB_DIR) ]; then \
-               $(INSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(INSTALL_DIR)/$(LIB_DIR); \
+               $(MINSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(INSTALL_DIR)/$(LIB_DIR); \
        fi
 
 
index b52f427e4a78797ff97d80b84e34a3cb888954cb..c10e3c00ffcaccfa9856a081d116c128203aacea 100644 (file)
@@ -588,7 +588,9 @@ find_supported_apis(void)
    EGLint mask = 0;
    void *handle;
 
-   handle = dlopen(NULL, 0);
+   handle = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL);
+   if(!handle)
+      return mask;
 
    if (dlsym(handle, "st_api_OpenGL_ES1"))
       mask |= EGL_OPENGL_ES_BIT;
index aabab95f3a8070cf1e4454e6d7022b673d4795b5..86eb9ef55ed7c261d4ffd31f60bea777bedad3a7 100644 (file)
@@ -15,6 +15,7 @@ if env['platform'] == 'windows':
                'gdi32',
                'user32',
                'kernel32',
+               'ws2_32',
        ])
 
        sources = [
index 04309e67eea5e75366a3f0e0a5e0a80d62ca6ee2..522f6dc5aee0991cba36a4de45bfb91a70008f01 100644 (file)
@@ -90,7 +90,7 @@ install: default
        $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
        $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(INSTALL_DIR)/include/GL
        @if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \
-               $(INSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \
+               $(MINSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \
        fi
 
 
index 5c26ead1bb9b8208b3bdd7ff96153873d0547f5a..b268265976f68137970654a08adf7943786cb918 100644 (file)
@@ -30,7 +30,7 @@ glu.pc: glu.pc.in
 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)
+       $(MINSTALL) $(TOP)/$(LIB_DIR)/$(GLU_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR)
        $(INSTALL) -m 644 glu.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
 
 clean:
index 199d8c390a6398f3276cd099d1b5c766b4130e96..c150ea88dc1af1f50c8ff2140c300c59228260b7 100644 (file)
@@ -72,7 +72,7 @@ install:
        $(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)
+       $(MINSTALL) $(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.
index 1b072906c74111d3dea4777ba3d9c746b61f5d5c..6889cd4b402f561706ef79b46962a7358f08523a 100644 (file)
@@ -117,7 +117,7 @@ install: glut.pc
        $(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)
+       $(MINSTALL) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR)
        $(INSTALL) -m 644 glut.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
 
 
index 0e42436133d97d8e928b13c3ff1cbbb49204d4bf..b82a758d2ca2fa67786eff2db4b28e8cd94ad131 100644 (file)
@@ -91,7 +91,7 @@ install: glut.pc
        $(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)
+       $(MINSTALL) $(TOP)/$(LIB_DIR)/libglut* $(DESTDIR)$(INSTALL_LIB_DIR)
        $(INSTALL) -m 644 glut.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
 
 
index d88d7733131183fcd91386479eaae0d31d0d470d..1fb3d3c320223402ddb137a17646b6cba11f4b16 100644 (file)
@@ -43,7 +43,7 @@ install: glw.pc
        $(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)
+       $(MINSTALL) $(TOP)/$(LIB_DIR)/$(GLW_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR)
        $(INSTALL) -m 644 glw.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
 
 clean:
index 90c3d8c7d9d3fa2310c53da28577a2985613137a..6de41111134399c948fa226c33acf9d28b18da9b 100644 (file)
@@ -345,7 +345,9 @@ driBindExtensions(__GLXscreenConfigs *psc, int dri2)
 #endif
 
 #ifdef __DRI_SWAP_CONTROL
-       if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0) {
+       /* No DRI2 support for swap_control at the moment, since SwapBuffers
+        * is done by the X server */
+       if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0 && !dri2) {
            psc->swapControl = (__DRIswapControlExtension *) extensions[i];
            __glXEnableDirectExtension(psc, "GLX_SGI_swap_control");
            __glXEnableDirectExtension(psc, "GLX_MESA_swap_control");
index aea117ec32dceacf612de52357f495e3a7ff51c4..e0cafd43bcb80a18225eedddf54735f9c1d26d07 100644 (file)
@@ -5201,10 +5201,9 @@ glDeleteTexturesEXT(GLsizei n, const GLuint * textures)
 #ifdef GLX_DIRECT_RENDERING
     if (gc->driContext) {
         CALL_DeleteTextures(GET_DISPATCH(), (n, textures));
-    } else {
-#else
-    {
+    } else
 #endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
@@ -5270,13 +5269,12 @@ glGenTexturesEXT(GLsizei n, GLuint * textures)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-#ifdef GLX_DIRECT_RENDERING    
+#ifdef GLX_DIRECT_RENDERING
     if (gc->driContext) {
         CALL_GenTextures(GET_DISPATCH(), (n, textures));
-    } else {
-#else 
-    {
+    } else
 #endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         const GLuint cmdlen = 4;
@@ -5336,13 +5334,12 @@ glIsTextureEXT(GLuint texture)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-#ifdef GLX_DIRECT_RENDERING    
+#ifdef GLX_DIRECT_RENDERING
     if (gc->driContext) {
         return CALL_IsTexture(GET_DISPATCH(), (texture));
-    } else {
-#else 
-    {
+    } else
 #endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         GLboolean retval = (GLboolean) 0;
@@ -5653,13 +5650,12 @@ glGetColorTableEXT(GLenum target, GLenum format, GLenum type, GLvoid * table)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-#ifdef GLX_DIRECT_RENDERING    
+#ifdef GLX_DIRECT_RENDERING
     if (gc->driContext) {
         CALL_GetColorTable(GET_DISPATCH(), (target, format, type, table));
-    } else {
-#else 
-    {
+    } else
 #endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         const __GLXattribute *const state = gc->client_state_private;
         Display *const dpy = gc->currentDpy;
@@ -5730,14 +5726,13 @@ glGetColorTableParameterfvEXT(GLenum target, GLenum pname, GLfloat * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-#ifdef GLX_DIRECT_RENDERING    
+#ifdef GLX_DIRECT_RENDERING
     if (gc->driContext) {
         CALL_GetColorTableParameterfv(GET_DISPATCH(),
                                       (target, pname, params));
-    } else {
-#else 
-    {
+    } else
 #endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         const GLuint cmdlen = 8;
@@ -5804,14 +5799,13 @@ glGetColorTableParameterivEXT(GLenum target, GLenum pname, GLint * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-#ifdef GLX_DIRECT_RENDERING    
+#ifdef GLX_DIRECT_RENDERING
     if (gc->driContext) {
         CALL_GetColorTableParameteriv(GET_DISPATCH(),
                                       (target, pname, params));
-    } else {
-#else 
-    {
+    } else
 #endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         const GLuint cmdlen = 8;
@@ -6131,14 +6125,13 @@ gl_dispatch_stub_356(GLenum target, GLenum format, GLenum type,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-#ifdef GLX_DIRECT_RENDERING    
+#ifdef GLX_DIRECT_RENDERING
     if (gc->driContext) {
         CALL_GetConvolutionFilter(GET_DISPATCH(),
                                   (target, format, type, image));
-    } else {
-#else 
-    {
+    } else
 #endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         const __GLXattribute *const state = gc->client_state_private;
         Display *const dpy = gc->currentDpy;
@@ -6210,14 +6203,13 @@ gl_dispatch_stub_357(GLenum target, GLenum pname, GLfloat * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-#ifdef GLX_DIRECT_RENDERING    
+#ifdef GLX_DIRECT_RENDERING
     if (gc->driContext) {
         CALL_GetConvolutionParameterfv(GET_DISPATCH(),
                                        (target, pname, params));
-    } else {
-#else 
-    {
+    } else
 #endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         const GLuint cmdlen = 8;
@@ -6284,14 +6276,13 @@ gl_dispatch_stub_358(GLenum target, GLenum pname, GLint * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-#ifdef GLX_DIRECT_RENDERING    
+#ifdef GLX_DIRECT_RENDERING
     if (gc->driContext) {
         CALL_GetConvolutionParameteriv(GET_DISPATCH(),
                                        (target, pname, params));
-    } else {
-#else 
-    {
+    } else
 #endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         const GLuint cmdlen = 8;
@@ -6365,14 +6356,13 @@ gl_dispatch_stub_361(GLenum target, GLboolean reset, GLenum format,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-#ifdef GLX_DIRECT_RENDERING    
+#ifdef GLX_DIRECT_RENDERING
     if (gc->driContext) {
         CALL_GetHistogram(GET_DISPATCH(),
                           (target, reset, format, type, values));
-    } else {
-#else 
-    {
+    } else
 #endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         const __GLXattribute *const state = gc->client_state_private;
         Display *const dpy = gc->currentDpy;
@@ -6443,13 +6433,12 @@ gl_dispatch_stub_362(GLenum target, GLenum pname, GLfloat * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-#ifdef GLX_DIRECT_RENDERING    
+#ifdef GLX_DIRECT_RENDERING
     if (gc->driContext) {
         CALL_GetHistogramParameterfv(GET_DISPATCH(), (target, pname, params));
-    } else {
-#else 
-    {
+    } else
 #endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         const GLuint cmdlen = 8;
@@ -6515,13 +6504,12 @@ gl_dispatch_stub_363(GLenum target, GLenum pname, GLint * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-#ifdef GLX_DIRECT_RENDERING    
+#ifdef GLX_DIRECT_RENDERING
     if (gc->driContext) {
         CALL_GetHistogramParameteriv(GET_DISPATCH(), (target, pname, params));
-    } else {
-#else 
-    {
+    } else
 #endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         const GLuint cmdlen = 8;
@@ -6591,13 +6579,12 @@ gl_dispatch_stub_364(GLenum target, GLboolean reset, GLenum format,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-#ifdef GLX_DIRECT_RENDERING    
+#ifdef GLX_DIRECT_RENDERING
     if (gc->driContext) {
         CALL_GetMinmax(GET_DISPATCH(), (target, reset, format, type, values));
-    } else {
-#else 
-    {
+    } else
 #endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         const __GLXattribute *const state = gc->client_state_private;
         Display *const dpy = gc->currentDpy;
@@ -6666,13 +6653,12 @@ gl_dispatch_stub_365(GLenum target, GLenum pname, GLfloat * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-#ifdef GLX_DIRECT_RENDERING    
+#ifdef GLX_DIRECT_RENDERING
     if (gc->driContext) {
         CALL_GetMinmaxParameterfv(GET_DISPATCH(), (target, pname, params));
-    } else {
-#else 
-    {
+    } else
 #endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         const GLuint cmdlen = 8;
@@ -6735,13 +6721,12 @@ gl_dispatch_stub_366(GLenum target, GLenum pname, GLint * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-#ifdef GLX_DIRECT_RENDERING    
+#ifdef GLX_DIRECT_RENDERING
     if (gc->driContext) {
         CALL_GetMinmaxParameteriv(GET_DISPATCH(), (target, pname, params));
-    } else {
-#else 
-    {
+    } else
 #endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         const GLuint cmdlen = 8;
index bb18bee8eaf189f07d940f5cd4c0987ddf92e747..8300b3014416f4a51b24dcdcab6e95f93851ec25 100644 (file)
@@ -129,14 +129,14 @@ install-headers:
 install-libgl: default gl.pc install-headers
        $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
        $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
-       $(INSTALL) $(TOP)/$(LIB_DIR)/$(GL_LIB_GLOB) \
+       $(MINSTALL) $(TOP)/$(LIB_DIR)/$(GL_LIB_GLOB) \
                $(DESTDIR)$(INSTALL_LIB_DIR)
        $(INSTALL) -m 644 gl.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
 
 install-osmesa: default osmesa.pc
        $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
        $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
-       $(INSTALL) $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_GLOB) \
+       $(MINSTALL) $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_GLOB) \
                $(DESTDIR)$(INSTALL_LIB_DIR)
        $(INSTALL) -m 644 osmesa.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
 
index 6a98c29a3d16f3372b5bf877cfdd21d79da84a73..edc069deeeb3e3decb1167fcfb03fe3f808d6083 100644 (file)
@@ -213,6 +213,11 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
    driver->UnmapBuffer = _mesa_buffer_unmap;
 #endif
 
+#if FEATURE_ARB_map_buffer_range
+   driver->MapBufferRange = _mesa_buffer_map_range;
+   driver->FlushMappedBufferRange = _mesa_buffer_flush_mapped_range;
+#endif
+
 #if FEATURE_EXT_framebuffer_object
    driver->NewFramebuffer = _mesa_new_framebuffer;
    driver->NewRenderbuffer = _mesa_new_soft_renderbuffer;
@@ -238,6 +243,9 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
    driver->DeleteArrayObject = _mesa_delete_array_object;
    driver->BindArrayObject = NULL;
 
+   /* GL_ARB_copy_buffer */
+   driver->CopyBufferSubData = _mesa_copy_buffer_subdata;
+
    /* T&L stuff */
    driver->NeedValidate = GL_FALSE;
    driver->ValidateTnlModule = NULL;
index 5c01d233c134ca5b7b961302629ba097e6287cdf..bd38e3be47ccb79812e69fa6f47e5579e135471d 100644 (file)
@@ -92,7 +92,7 @@ clean:
 
 install: $(LIBNAME)
        $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
-       $(INSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
+       $(MINSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
 
 
 -include depend
index e112720471879f97c93551a995b017969a6c8604..ae0e61e515b77d90b37ffb59eff1f3d4beb96fd9 100644 (file)
@@ -37,6 +37,9 @@
 typedef GLboolean ( * PFNGLXGETMSCRATEOMLPROC) (__DRIdrawable *drawable, int32_t *numerator, int32_t *denominator);
 #endif
 
+static void dri_get_drawable(__DRIdrawable *pdp);
+static void dri_put_drawable(__DRIdrawable *pdp);
+
 /**
  * This is just a token extension used to signal that the driver
  * supports setting a read drawable.
@@ -127,7 +130,7 @@ static int driUnbindContext(__DRIcontext *pcp)
        return GL_FALSE;
     }
 
-    pdp->refcount--;
+    dri_put_drawable(pdp);
 
     if (prp != pdp) {
         if (prp->refcount == 0) {
@@ -135,7 +138,7 @@ static int driUnbindContext(__DRIcontext *pcp)
            return GL_FALSE;
        }
 
-       prp->refcount--;
+       dri_put_drawable(prp);
     }
 
 
@@ -170,10 +173,10 @@ static int driBindContext(__DRIcontext *pcp,
        pcp->driReadablePriv = prp;
        if (pdp) {
            pdp->driContextPriv = pcp;
-           pdp->refcount++;
+           dri_get_drawable(pdp);
        }
        if ( prp && pdp != prp ) {
-           prp->refcount++;
+           dri_get_drawable(prp);
        }
     }
 
@@ -430,7 +433,7 @@ driCreateNewDrawable(__DRIscreen *psp, const __DRIconfig *config,
 
     pdp->loaderPrivate = data;
     pdp->hHWDrawable = hwDrawable;
-    pdp->refcount = 0;
+    pdp->refcount = 1;
     pdp->pStamp = NULL;
     pdp->lastStamp = 0;
     pdp->index = 0;
@@ -483,12 +486,19 @@ dri2CreateNewDrawable(__DRIscreen *screen,
     return pdraw;
 }
 
-
-static void
-driDestroyDrawable(__DRIdrawable *pdp)
+static void dri_get_drawable(__DRIdrawable *pdp)
+{
+    pdp->refcount++;
+}
+       
+static void dri_put_drawable(__DRIdrawable *pdp)
 {
     __DRIscreenPrivate *psp;
 
+    pdp->refcount--;
+    if (pdp->refcount)
+       return;
+
     if (pdp) {
        psp = pdp->driScreenPriv;
         (*psp->DriverAPI.DestroyBuffer)(pdp);
@@ -504,6 +514,12 @@ driDestroyDrawable(__DRIdrawable *pdp)
     }
 }
 
+static void
+driDestroyDrawable(__DRIdrawable *pdp)
+{
+    dri_put_drawable(pdp);
+}
+
 /*@}*/
 
 
index 8dcaaee3079f408b2d15df5faf1944eb2665c8a6..261b5f6067b57082ab3620d98a68fac439ba17f8 100644 (file)
@@ -1763,6 +1763,13 @@ 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 */
@@ -2766,10 +2773,10 @@ static const char Uniform4fARB_names[] =
     "";
 #endif
 
-#if defined(need_GL_IBM_multimode_draw_arrays)
-static const char MultiModeDrawArraysIBM_names[] = 
-    "pppii\0" /* Parameter signature */
-    "glMultiModeDrawArraysIBM\0"
+#if defined(need_GL_ARB_map_buffer_range)
+static const char FlushMappedBufferRange_names[] = 
+    "iii\0" /* Parameter signature */
+    "glFlushMappedBufferRange\0"
     "";
 #endif
 
@@ -3897,6 +3904,13 @@ static const char VertexAttribs4dvNV_names[] =
     "";
 #endif
 
+#if defined(need_GL_IBM_multimode_draw_arrays)
+static const char MultiModeDrawArraysIBM_names[] = 
+    "pppii\0" /* Parameter signature */
+    "glMultiModeDrawArraysIBM\0"
+    "";
+#endif
+
 #if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program)
 static const char VertexAttrib4dARB_names[] = 
     "idddd\0" /* Parameter signature */
@@ -4048,6 +4062,13 @@ static const char IsVertexArrayAPPLE_names[] =
     "";
 #endif
 
+#if defined(need_GL_ARB_map_buffer_range)
+static const char MapBufferRange_names[] = 
+    "iiii\0" /* Parameter signature */
+    "glMapBufferRange\0"
+    "";
+#endif
+
 #if defined(need_GL_NV_vertex_program)
 static const char ProgramParameters4dvNV_names[] = 
     "iiip\0" /* Parameter signature */
@@ -4396,6 +4417,13 @@ static const char WindowPos3ivMESA_names[] =
     "";
 #endif
 
+#if defined(need_GL_ARB_copy_buffer)
+static const char CopyBufferSubData_names[] = 
+    "iiiii\0" /* Parameter signature */
+    "glCopyBufferSubData\0"
+    "";
+#endif
+
 #if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
 static const char IsBufferARB_names[] = 
     "i\0" /* Parameter signature */
@@ -4560,13 +4588,6 @@ 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 */
@@ -4939,6 +4960,13 @@ static const struct dri_extension_function GL_APPLE_vertex_array_object_function
 };
 #endif
 
+#if defined(need_GL_ARB_copy_buffer)
+static const struct dri_extension_function GL_ARB_copy_buffer_functions[] = {
+    { CopyBufferSubData_names, CopyBufferSubData_remap_index, -1 },
+    { NULL, 0, 0 }
+};
+#endif
+
 #if defined(need_GL_ARB_draw_buffers)
 static const struct dri_extension_function GL_ARB_draw_buffers_functions[] = {
     { DrawBuffersARB_names, DrawBuffersARB_remap_index, -1 },
@@ -4972,6 +5000,14 @@ static const struct dri_extension_function GL_ARB_framebuffer_object_functions[]
 };
 #endif
 
+#if defined(need_GL_ARB_map_buffer_range)
+static const struct dri_extension_function GL_ARB_map_buffer_range_functions[] = {
+    { FlushMappedBufferRange_names, FlushMappedBufferRange_remap_index, -1 },
+    { MapBufferRange_names, MapBufferRange_remap_index, -1 },
+    { NULL, 0, 0 }
+};
+#endif
+
 #if defined(need_GL_ARB_matrix_palette)
 static const struct dri_extension_function GL_ARB_matrix_palette_functions[] = {
     { MatrixIndexusvARB_names, MatrixIndexusvARB_remap_index, -1 },
@@ -6055,9 +6091,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 9f4bd1699f9167dcae571c5eddf8d1eab175a29b..beaf9a4b129cb24d4fcbdf2eefea00a9411c471a 100644 (file)
@@ -19,6 +19,7 @@ DRIVER_SOURCES = \
        intel_batchbuffer.c \
        intel_clear.c \
        intel_extensions.c \
+       intel_generatemipmap.c \
        intel_mipmap_tree.c \
        intel_tex_layout.c \
        intel_tex_image.c \
index d210c2d08e4aa6b0c55250174fa634fd2ac7078d..db16871001d93571d416ca9b828f0c226b0c50aa 100644 (file)
 #define AA_LINE_ENABLE                 ((1<<1) | 1)
 #define AA_LINE_DISABLE                        (1<<1)
 
-#define _3DSTATE_BUF_INFO_CMD  (CMD_3D | (0x1d<<24) | (0x8e<<16) | 1)
-/* Dword 1 */
-#define BUF_3D_ID_COLOR_BACK   (0x3<<24)
-#define BUF_3D_ID_DEPTH        (0x7<<24)
-#define BUF_3D_USE_FENCE       (1<<23)
-#define BUF_3D_TILED_SURFACE   (1<<22)
-#define BUF_3D_TILE_WALK_X     0
-#define BUF_3D_TILE_WALK_Y     (1<<21)
-#define BUF_3D_PITCH(x)         (((x)/4)<<2)
-/* Dword 2 */
-#define BUF_3D_ADDR(x)         ((x) & ~0x3)
-
-
 #define _3DSTATE_COLOR_FACTOR_CMD      (CMD_3D | (0x1d<<24) | (0x1<<16))
 
 #define _3DSTATE_COLOR_FACTOR_N_CMD(stage)     (CMD_3D | (0x1d<<24) | \
index d9cad0c4bf815b46ef648c765708c2f4e253b028..8ef6c9144f168fa5d0ab1bd6dd9eccf58128ab47 100644 (file)
@@ -39,6 +39,7 @@
 #include "intel_screen.h"
 #include "intel_batchbuffer.h"
 #include "intel_fbo.h"
+#include "intel_buffers.h"
 
 #include "i830_context.h"
 #include "i830_reg.h"
@@ -446,6 +447,24 @@ i830DepthMask(GLcontext * ctx, GLboolean flag)
       i830->state.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_DEPTH_WRITE;
 }
 
+/** Called from ctx->Driver.Viewport() */
+static void
+i830Viewport(GLcontext * ctx,
+              GLint x, GLint y, GLsizei width, GLsizei height)
+{
+   intelCalcViewport(ctx);
+
+   intel_viewport(ctx, x, y, width, height);
+}
+
+
+/** Called from ctx->Driver.DepthRange() */
+static void
+i830DepthRange(GLcontext * ctx, GLclampd nearval, GLclampd farval)
+{
+   intelCalcViewport(ctx);
+}
+
 /* =============================================================
  * Polygon stipple
  *
@@ -1064,6 +1083,8 @@ i830InitStateFuncs(struct dd_function_table *functions)
    functions->StencilFuncSeparate = i830StencilFuncSeparate;
    functions->StencilMaskSeparate = i830StencilMaskSeparate;
    functions->StencilOpSeparate = i830StencilOpSeparate;
+   functions->DepthRange = i830DepthRange;
+   functions->Viewport = i830Viewport;
 }
 
 void
index 753c25b57ed9528f32ba305d5d7b98167851b68c..6f998fa6f773826eae70dcba0f9f476370cb72e4 100644 (file)
@@ -174,14 +174,16 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
    state[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
                                (LOAD_TEXTURE_MAP0 << unit) | 4);
 
-/*    state[I830_TEXREG_TM0S0] = (TM0S0_USE_FENCE | */
-/*                            t->intel.TextureOffset); */
-
-
    state[I830_TEXREG_TM0S1] =
       (((firstImage->Height - 1) << TM0S1_HEIGHT_SHIFT) |
        ((firstImage->Width - 1) << TM0S1_WIDTH_SHIFT) | format);
 
+   if (intelObj->mt->region->tiling != I915_TILING_NONE) {
+      state[I830_TEXREG_TM0S1] |= TM0S1_TILED_SURFACE;
+      if (intelObj->mt->region->tiling == I915_TILING_Y)
+        state[I830_TEXREG_TM0S1] |= TM0S1_TILE_WALK;
+   }
+
    state[I830_TEXREG_TM0S2] =
       ((((pitch / 4) - 1) << TM0S2_PITCH_SHIFT) | TM0S2_CUBE_FACE_ENA_MASK);
 
index 3bf02de61f8d29263a43cf9697a360271650535b..cbee9f9efe9a859a2fe838f9ca84b9c1e46a399b 100644 (file)
@@ -552,7 +552,7 @@ i830_emit_state(struct intel_context *intel)
          if (state->tex_buffer[i]) {
             OUT_RELOC(state->tex_buffer[i],
                      I915_GEM_DOMAIN_SAMPLER, 0,
-                      state->tex_offset[i] | TM0S0_USE_FENCE);
+                      state->tex_offset[i]);
          }
         else if (state == &i830->meta) {
            assert(i == 0);
@@ -634,21 +634,11 @@ i830_state_draw_region(struct intel_context *intel,
    /*
     * 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);
-   }
+   i915_set_buf_info_for_region(&state->Buffer[I830_DESTREG_CBUFADDR0],
+                               color_region, BUF_3D_ID_COLOR_BACK);
 
-   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);
-   }
+   i915_set_buf_info_for_region(&state->Buffer[I830_DESTREG_DBUFADDR0],
+                               depth_region, BUF_3D_ID_DEPTH);
 
    /*
     * Compute/set I830_DESTREG_DV1 value
@@ -718,26 +708,6 @@ i830_set_draw_region(struct intel_context *intel,
    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)
-{
-   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);
-   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
index 1f9f363df926b87e27adcf008bbffcc81028db3c..367d2a3b6486d8903468126cefe91cf80c5abbef 100644 (file)
@@ -73,7 +73,7 @@ i915InvalidateState(GLcontext * ctx, GLuint new_state)
          p->params_uptodate = 0;
    }
 
-   if (new_state & (_NEW_FOG | _NEW_HINT | _NEW_PROGRAM))
+   if (new_state & (_NEW_FOG | _NEW_HINT | _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS))
       i915_update_fog(ctx);
 }
 
index 8891e11c6fd22ee0101712eef7d082443f78ccbc..84db58ea9507d4982f79b20674dbb6c6a784d1bf 100644 (file)
 
 /* 3DSTATE_BIN_CONTROL p141 */
 
-/* p143 */
-#define _3DSTATE_BUF_INFO_CMD  (CMD_3D | (0x1d<<24) | (0x8e<<16) | 1)
-/* Dword 1 */
-#define BUF_3D_ID_COLOR_BACK   (0x3<<24)
-#define BUF_3D_ID_DEPTH        (0x7<<24)
-#define BUF_3D_USE_FENCE       (1<<23)
-#define BUF_3D_TILED_SURFACE   (1<<22)
-#define BUF_3D_TILE_WALK_X     0
-#define BUF_3D_TILE_WALK_Y     (1<<21)
-#define BUF_3D_PITCH(x)         (((x)/4)<<2)
-/* Dword 2 */
-#define BUF_3D_ADDR(x)         ((x) & ~0x3)
-
-
 /* 3DSTATE_CHROMA_KEY */
 
 /* 3DSTATE_CLEAR_PARAMETERS, p150 */
 /* p161 */
 #define _3DSTATE_DST_BUF_VARS_CMD      (CMD_3D | (0x1d<<24) | (0x85<<16))
 /* Dword 1 */
+#define CLASSIC_EARLY_DEPTH            (1<<31)
 #define TEX_DEFAULT_COLOR_OGL           (0<<30)
 #define TEX_DEFAULT_COLOR_D3D           (1<<30)
 #define ZR_EARLY_DEPTH                  (1<<29)
index d44a2f47b3731fd0390fec8401429d9abe1edc4c..d9588e5b56da655e89d8dbca5c4b190cd68bf295 100644 (file)
@@ -55,6 +55,17 @@ static GLint step_offsets[6][2] = {
    [FACE_NEG_Z] = {-1, 1},
 };
 
+
+static GLint bottom_offsets[6] = {
+   [FACE_POS_X] = 16 + 0 * 8,
+   [FACE_POS_Y] = 16 + 1 * 8,
+   [FACE_POS_Z] = 16 + 2 * 8,
+   [FACE_NEG_X] = 16 + 3 * 8,
+   [FACE_NEG_Y] = 16 + 4 * 8,
+   [FACE_NEG_Z] = 16 + 5 * 8,
+};
+
+
 /**
  * Cube texture map layout for i830M-GM915.
  *
@@ -101,7 +112,8 @@ static GLint step_offsets[6][2] = {
  */
 static void
 i915_miptree_layout_cube(struct intel_context *intel,
-                        struct intel_mipmap_tree * mt)
+                        struct intel_mipmap_tree * mt,
+                        uint32_t tiling)
 {
    const GLuint dim = mt->width0;
    GLuint face;
@@ -111,7 +123,7 @@ i915_miptree_layout_cube(struct intel_context *intel,
    assert(lvlWidth == lvlHeight); /* cubemap images are square */
 
    /* double pitch for cube layouts */
-   mt->pitch = intel_miptree_pitch_align (intel, mt, dim * 2);
+   mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, dim * 2);
    mt->total_height = dim * 4;
 
    for (level = mt->first_level; level <= mt->last_level; level++) {
@@ -145,7 +157,8 @@ i915_miptree_layout_cube(struct intel_context *intel,
 
 static void
 i915_miptree_layout_3d(struct intel_context *intel,
-                      struct intel_mipmap_tree * mt)
+                      struct intel_mipmap_tree * mt,
+                      uint32_t tiling)
 {
    GLuint width = mt->width0;
    GLuint height = mt->height0;
@@ -154,7 +167,7 @@ i915_miptree_layout_3d(struct intel_context *intel,
    GLint level;
 
    /* Calculate the size of a single slice. */
-   mt->pitch = intel_miptree_pitch_align (intel, mt, mt->width0);
+   mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, mt->width0);
 
    /* XXX: hardware expects/requires 9 levels at minimum. */
    for (level = mt->first_level; level <= MAX2(8, mt->last_level); level++) {
@@ -189,14 +202,15 @@ i915_miptree_layout_3d(struct intel_context *intel,
 
 static void
 i915_miptree_layout_2d(struct intel_context *intel,
-                      struct intel_mipmap_tree * mt)
+                      struct intel_mipmap_tree * mt,
+                      uint32_t tiling)
 {
    GLuint width = mt->width0;
    GLuint height = mt->height0;
    GLuint img_height;
    GLint level;
 
-   mt->pitch = intel_miptree_pitch_align (intel, mt, mt->width0);
+   mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, mt->width0);
    mt->total_height = 0;
 
    for (level = mt->first_level; level <= mt->last_level; level++) {
@@ -217,19 +231,20 @@ i915_miptree_layout_2d(struct intel_context *intel,
 }
 
 GLboolean
-i915_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree * mt)
+i915_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree * mt,
+                   uint32_t tiling)
 {
    switch (mt->target) {
    case GL_TEXTURE_CUBE_MAP:
-      i915_miptree_layout_cube(intel, mt);
+      i915_miptree_layout_cube(intel, mt, tiling);
       break;
    case GL_TEXTURE_3D:
-      i915_miptree_layout_3d(intel, mt);
+      i915_miptree_layout_3d(intel, mt, tiling);
       break;
    case GL_TEXTURE_1D:
    case GL_TEXTURE_2D:
    case GL_TEXTURE_RECTANGLE_ARB:
-      i915_miptree_layout_2d(intel, mt);
+      i915_miptree_layout_2d(intel, mt, tiling);
       break;
    default:
       _mesa_problem(NULL, "Unexpected tex target in i915_miptree_layout()");
@@ -297,7 +312,7 @@ i915_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree * mt)
  * +---+   +---+   +---+   +---+   +---+   +---+
  *
  * 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
+ * in order, with each of them aligned to a 8x8 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
@@ -306,7 +321,8 @@ i915_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree * mt)
 
 static void
 i945_miptree_layout_cube(struct intel_context *intel,
-                        struct intel_mipmap_tree * mt)
+                        struct intel_mipmap_tree * mt,
+                        uint32_t tiling)
 {
    const GLuint dim = mt->width0;
    GLuint face;
@@ -320,9 +336,9 @@ i945_miptree_layout_cube(struct intel_context *intel,
     * 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);
+      mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, dim * 2);
    else
-      mt->pitch = intel_miptree_pitch_align (intel, mt, 14 * 8);
+      mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, 14 * 8);
 
    if (dim >= 4)
       mt->total_height = dim * 4 + 4;
@@ -375,10 +391,11 @@ i945_miptree_layout_cube(struct intel_context *intel,
               x = (face - 4) * 8;
               break;
            }
+           break;
 
         case 2:
            y = mt->total_height - 4;
-           x = 16 + face * 8;
+           x = bottom_offsets[face];
            break;
 
         case 1:
@@ -396,7 +413,8 @@ i945_miptree_layout_cube(struct intel_context *intel,
 
 static void
 i945_miptree_layout_3d(struct intel_context *intel,
-                      struct intel_mipmap_tree * mt)
+                      struct intel_mipmap_tree * mt,
+                      uint32_t tiling)
 {
    GLuint width = mt->width0;
    GLuint height = mt->height0;
@@ -405,7 +423,7 @@ i945_miptree_layout_3d(struct intel_context *intel,
    GLuint pack_y_pitch;
    GLuint level;
 
-   mt->pitch = intel_miptree_pitch_align (intel, mt, mt->width0);
+   mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, mt->width0);
    mt->total_height = 0;
 
    pack_y_pitch = MAX2(mt->height0, 2);
@@ -450,19 +468,23 @@ i945_miptree_layout_3d(struct intel_context *intel,
 }
 
 GLboolean
-i945_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree * mt)
+i945_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree * mt,
+                   uint32_t tiling)
 {
    switch (mt->target) {
    case GL_TEXTURE_CUBE_MAP:
-      i945_miptree_layout_cube(intel, mt);
+      if (mt->compressed)
+        i945_miptree_layout_cube(intel, mt, tiling);
+      else
+        i915_miptree_layout_cube(intel, mt, tiling);
       break;
    case GL_TEXTURE_3D:
-      i945_miptree_layout_3d(intel, mt);
+      i945_miptree_layout_3d(intel, mt, tiling);
       break;
    case GL_TEXTURE_1D:
    case GL_TEXTURE_2D:
    case GL_TEXTURE_RECTANGLE_ARB:
-      i945_miptree_layout_2d(intel, mt);
+      i945_miptree_layout_2d(intel, mt, tiling);
       break;
    default:
       _mesa_problem(NULL, "Unexpected tex target in i945_miptree_layout()");
index a37dd7f4fb50426d73152fa6af25308d3d507c19..32d4b30cf9a610ea02bb1e7f96790ab60c30f399 100644 (file)
@@ -185,8 +185,13 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
 
    state[I915_TEXREG_MS3] =
       (((firstImage->Height - 1) << MS3_HEIGHT_SHIFT) |
-       ((firstImage->Width - 1) << MS3_WIDTH_SHIFT) | format |
-       MS3_USE_FENCE_REGS);
+       ((firstImage->Width - 1) << MS3_WIDTH_SHIFT) | format);
+
+   if (intelObj->mt->region->tiling != I915_TILING_NONE) {
+      state[I915_TEXREG_MS3] |= MS3_TILED_SURFACE;
+      if (intelObj->mt->region->tiling == I915_TILING_Y)
+        state[I915_TEXREG_MS3] |= MS3_TILE_WALK;
+   }
 
    state[I915_TEXREG_MS4] =
      ((((pitch / 4) - 1) << MS4_PITCH_SHIFT) | MS4_CUBE_FACE_ENA_MASK |
index 115004616ff5cf74a49833ad23c7cfd843c28128..2fca247af198a741d9e7451a98ef7fe2026c4848 100644 (file)
@@ -42,6 +42,7 @@
 #include "intel_regions.h"
 #include "intel_tris.h"
 #include "intel_fbo.h"
+#include "intel_chipset.h"
 
 #include "i915_reg.h"
 #include "i915_context.h"
@@ -529,6 +530,23 @@ i915_destroy_context(struct intel_context *intel)
    _tnl_free_vertices(&intel->ctx);
 }
 
+void
+i915_set_buf_info_for_region(uint32_t *state, struct intel_region *region,
+                            uint32_t buffer_id)
+{
+   state[0] = _3DSTATE_BUF_INFO_CMD;
+   state[1] = buffer_id;
+
+   if (region != NULL) {
+      state[1] |= BUF_3D_PITCH(region->pitch * region->cpp);
+
+      if (region->tiling != I915_TILING_NONE) {
+        state[1] |= BUF_3D_TILED_SURFACE;
+        if (region->tiling == I915_TILING_Y)
+           state[1] |= BUF_3D_TILE_WALK_Y;
+      }
+   }
+}
 
 /**
  * Set the drawing regions for the color and depth/stencil buffers.
@@ -562,21 +580,11 @@ i915_state_draw_region(struct intel_context *intel,
    /*
     * 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);
-   }
+   i915_set_buf_info_for_region(&state->Buffer[I915_DESTREG_CBUFADDR0],
+                               color_region, BUF_3D_ID_COLOR_BACK);
 
-   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);
-   }
+   i915_set_buf_info_for_region(&state->Buffer[I915_DESTREG_DBUFADDR0],
+                               depth_region, BUF_3D_ID_DEPTH);
 
    /*
     * Compute/set I915_DESTREG_DV1 value
@@ -604,6 +612,14 @@ i915_state_draw_region(struct intel_context *intel,
       }
    }
 
+   /* This isn't quite safe, thus being hidden behind an option.  When changing
+    * the value of this bit, the pipeline needs to be MI_FLUSHed.  And it
+    * can only be set when a depth buffer is already defined.
+    */
+   if (IS_945(intel->intelScreen->deviceID) && intel->use_early_z &&
+       depth_region->tiling != I915_TILING_NONE)
+      value |= CLASSIC_EARLY_DEPTH;
+
    if (depth_region && depth_region->cpp == 4) {
       value |= DEPTH_FRMT_24_FIXED_8_OTHER;
    }
diff --git a/src/mesa/drivers/dri/i915/intel_generatemipmap.c b/src/mesa/drivers/dri/i915/intel_generatemipmap.c
new file mode 120000 (symlink)
index 0000000..4c6b37a
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_generatemipmap.c
\ No newline at end of file
index 2934414d99a885a9f8744b70451e854dcca99f2a..9712c3872543b2897c2e8c5840cb31f649d9dbc0 100644 (file)
@@ -14,6 +14,7 @@ DRIVER_SOURCES = \
        intel_decode.c \
        intel_extensions.c \
        intel_fbo.c \
+       intel_generatemipmap.c \
        intel_mipmap_tree.c \
        intel_regions.c \
        intel_screen.c \
@@ -69,6 +70,7 @@ DRIVER_SOURCES = \
        brw_vs_constval.c \
        brw_vs_emit.c \
        brw_vs_state.c \
+       brw_vs_surface_state.c \
        brw_vtbl.c \
        brw_wm.c \
        brw_wm_debug.c \
index 577497bf6b0cb88729576280f7e9237718b4e39a..13fece44b8de0d130d52bbd334b2f509d84ba086 100644 (file)
@@ -131,6 +131,7 @@ struct brw_context;
 #define BRW_NEW_WM_INPUT_DIMENSIONS     0x100
 #define BRW_NEW_INPUT_VARYING           0x200
 #define BRW_NEW_PSP                     0x800
+#define BRW_NEW_WM_SURFACES            0x1000
 #define BRW_NEW_FENCE                   0x2000
 #define BRW_NEW_INDICES                        0x4000
 #define BRW_NEW_VERTICES               0x8000
@@ -245,6 +246,9 @@ struct brw_vs_ouput_sizes {
 };
 
 
+/** Number of general purpose registers (VS, WM, etc) */
+#define BRW_MAX_GRF 128
+
 /** Number of texture sampler units */
 #define BRW_MAX_TEX_UNIT 16
 
@@ -450,8 +454,6 @@ struct brw_context
 
    struct {
       struct brw_state_flags dirty;
-      struct brw_tracked_state **atoms;
-      GLuint nr_atoms;
 
       GLuint nr_color_regions;
       struct intel_region *color_regions[MAX_DRAW_BUFFERS];
@@ -471,7 +473,8 @@ struct brw_context
       int validated_bo_count;
    } state;
 
-   struct brw_cache cache;
+   struct brw_cache cache;  /** non-surface items */
+   struct brw_cache surface_cache;  /* surface items */
    struct brw_cached_batch_item *cached_batch_items;
 
    struct {
@@ -555,11 +558,6 @@ struct brw_context
       GLuint vs_size;
       GLuint total_size;
 
-      /* Dynamic tracker which changes to reflect the state referenced
-       * by active fp and vp program parameters:
-       */
-      struct brw_tracked_state tracked_state;
-
       dri_bo *curbe_bo;
       /** Offset within curbe_bo of space for current curbe entry */
       GLuint curbe_offset;
index 9197fede2d85dd147fa918edab76ae82ab2049b3..a1a6c53d0e0de8a39f7cf2fe2c65ad37458958e1 100644 (file)
@@ -36,6 +36,7 @@
 #include "main/macros.h"
 #include "main/enums.h"
 #include "shader/prog_parameter.h"
+#include "shader/prog_print.h"
 #include "shader/prog_statevars.h"
 #include "intel_batchbuffer.h"
 #include "intel_regions.h"
@@ -188,13 +189,6 @@ static void prepare_constant_buffer(struct brw_context *brw)
    GLfloat *buf;
    GLuint i;
 
-   /* Update our own dependency flags.  This works because this
-    * function will also be called whenever fp or vp changes.
-    */
-   brw->curbe.tracked_state.dirty.mesa = (_NEW_TRANSFORM|_NEW_PROJECTION);
-   brw->curbe.tracked_state.dirty.mesa |= vp->program.Base.Parameters->StateFlags;
-   brw->curbe.tracked_state.dirty.mesa |= fp->program.Base.Parameters->StateFlags;
-
    if (sz == 0) {
       if (brw->curbe.last_buf) {
         free(brw->curbe.last_buf);
@@ -335,78 +329,11 @@ static void prepare_constant_buffer(struct brw_context *brw)
     */
 }
 
-
-/**
- * Copy Mesa program parameters into given constant buffer.
- */
-static void
-update_constant_buffer(struct brw_context *brw,
-                       const struct gl_program_parameter_list *params,
-                       dri_bo *const_buffer)
-{
-   struct intel_context *intel = &brw->intel;
-   const int size = params->NumParameters * 4 * sizeof(GLfloat);
-
-   /* copy Mesa program constants into the buffer */
-   if (const_buffer && size > 0) {
-
-      assert(const_buffer);
-      assert(const_buffer->size >= size);
-
-      if (intel->intelScreen->kernel_exec_fencing) {
-         drm_intel_gem_bo_map_gtt(const_buffer);
-         memcpy(const_buffer->virtual, params->ParameterValues, size);
-         drm_intel_gem_bo_unmap_gtt(const_buffer);
-      }
-      else {
-         dri_bo_subdata(const_buffer, 0, size, params->ParameterValues);
-      }
-
-      if (0) {
-         int i;
-         for (i = 0; i < params->NumParameters; i++) {
-            float *p = params->ParameterValues[i];
-            printf("%d: %f %f %f %f\n", i, p[0], p[1], p[2], p[3]);
-         }
-      }
-   }
-}
-
-
-/** Copy current vertex program's parameters into the constant buffer */
-static void
-update_vertex_constant_buffer(struct brw_context *brw)
-{
-   struct brw_vertex_program *vp =
-      (struct brw_vertex_program *) brw->vertex_program;
-   if (0) {
-      printf("update VS constants in buffer %p\n", vp->const_buffer);
-      printf("program %u\n", vp->program.Base.Id);
-   }
-   if (vp->use_const_buffer)
-      update_constant_buffer(brw, vp->program.Base.Parameters, vp->const_buffer);
-}
-
-
-/** Copy current fragment program's parameters into the constant buffer */
-static void
-update_fragment_constant_buffer(struct brw_context *brw)
-{
-   struct brw_fragment_program *fp =
-      (struct brw_fragment_program *) brw->fragment_program;
-   if (fp->use_const_buffer)
-      update_constant_buffer(brw, fp->program.Base.Parameters, fp->const_buffer);
-}
-
-
 static void emit_constant_buffer(struct brw_context *brw)
 {
    struct intel_context *intel = &brw->intel;
    GLuint sz = brw->curbe.total_size;
 
-   update_vertex_constant_buffer(brw);
-   update_fragment_constant_buffer(brw);
-
    BEGIN_BATCH(2, IGNORE_CLIPRECTS);
    if (sz == 0) {
       OUT_BATCH((CMD_CONST_BUFFER << 16) | (2 - 2));
@@ -428,7 +355,7 @@ static void emit_constant_buffer(struct brw_context *brw)
  */
 const struct brw_tracked_state brw_constant_buffer = {
    .dirty = {
-      .mesa = (_NEW_TRANSFORM|_NEW_PROJECTION),      /* plus fp and vp flags */
+      .mesa = _NEW_PROGRAM_CONSTANTS,
       .brw  = (BRW_NEW_FRAGMENT_PROGRAM |
               BRW_NEW_VERTEX_PROGRAM |
               BRW_NEW_URB_FENCE | /* Implicit - hardware requires this, not used above */
index b91b20bec6f09908e78dc365e2429ea99ffc855f..1b8bcc14ec0b56db94d948cb31fb181a3ab74a20 100644 (file)
@@ -343,7 +343,7 @@ 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; 
+   GLbitfield vs_inputs = brw->vs.prog_data->inputs_read; 
    GLuint i;
    const unsigned char *ptr = NULL;
    GLuint interleave = 0;
@@ -362,11 +362,11 @@ static void brw_prepare_vertices(struct brw_context *brw)
       _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;
+   while (vs_inputs) {
+      GLuint i = _mesa_ffsll(vs_inputs) - 1;
       struct brw_vertex_element *input = &brw->vb.inputs[i];
 
-      tmp &= ~(1<<i);
+      vs_inputs &= ~(1 << i);
       enabled[nr_enabled++] = input;
    }
 
@@ -477,17 +477,17 @@ 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;
+   GLbitfield vs_inputs = 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;
+   while (vs_inputs) {
+      i = _mesa_ffsll(vs_inputs) - 1;
       struct brw_vertex_element *input = &brw->vb.inputs[i];
 
-      tmp &= ~(1<<i);
+      vs_inputs &= ~(1 << i);
       enabled[nr_enabled++] = input;
    }
 
index 62c98bd8bb364f703283848ad5827dbd32ebae4c..bc7756ceab46b71102e2f3bca02c9e25b1afc520 100644 (file)
@@ -97,7 +97,7 @@ struct brw_glsl_call;
 
 
 #define BRW_EU_MAX_INSN_STACK 5
-#define BRW_EU_MAX_INSN 4000
+#define BRW_EU_MAX_INSN 10000
 
 struct brw_compile {
    struct brw_instruction store[BRW_EU_MAX_INSN];
index 9bc5c35139cabd23e01bf7a1c9d0cb65dd9ac6fa..4784254bc7da1b11ec92a56309d5ead14acd06ab 100644 (file)
@@ -118,7 +118,10 @@ static void upload_binding_table_pointers(struct brw_context *brw)
 
    BEGIN_BATCH(6, IGNORE_CLIPRECTS);
    OUT_BATCH(CMD_BINDING_TABLE_PTRS << 16 | (6 - 2));
-   OUT_RELOC(brw->vs.bind_bo, I915_GEM_DOMAIN_SAMPLER, 0, 0); /* vs */
+   if (brw->vs.bind_bo != NULL)
+      OUT_RELOC(brw->vs.bind_bo, I915_GEM_DOMAIN_SAMPLER, 0, 0); /* vs */
+   else
+      OUT_BATCH(0);
    OUT_BATCH(0); /* gs */
    OUT_BATCH(0); /* clip */
    OUT_BATCH(0); /* sf */
index c3c85978f4d012d7f1ed8807bf177badfafb0e2c..e1c2c7777b518b0875d4c0e4274d703f024403a0 100644 (file)
@@ -166,6 +166,9 @@ static void upload_sf_prog(struct brw_context *brw)
    key.do_flat_shading = (ctx->Light.ShadeModel == GL_FLAT);
    key.do_twoside_color = (ctx->Light.Enabled && ctx->Light.Model.TwoSide);
 
+   /* _NEW_HINT */
+   key.linear_color = (ctx->Hint.PerspectiveCorrection == GL_FASTEST);
+
    /* _NEW_POLYGON */
    if (key.do_twoside_color) {
       /* If we're rendering to a FBO, we have to invert the polygon
@@ -188,7 +191,7 @@ static void upload_sf_prog(struct brw_context *brw)
 
 const struct brw_tracked_state brw_sf_prog = {
    .dirty = {
-      .mesa  = (_NEW_LIGHT|_NEW_POLYGON|_NEW_POINT),
+      .mesa  = (_NEW_HINT | _NEW_LIGHT | _NEW_POLYGON | _NEW_POINT),
       .brw   = (BRW_NEW_REDUCED_PRIMITIVE),
       .cache = CACHE_NEW_VS_PROG
    },
index 1c0fb70fe069218c1ceeef991172be301dbcc52d..6426b6df9ffa38d207feb5074333200aea6b5e74 100644 (file)
@@ -51,7 +51,8 @@ struct brw_sf_prog_key {
    GLuint do_flat_shading:1;
    GLuint frontface_ccw:1;
    GLuint do_point_sprite:1;
-   GLuint pad:10;
+   GLuint linear_color:1;  /**< linear interp vs. perspective interp */
+   GLuint pad:25;
    GLenum SpriteOrigin;
 };
 
index 862835f157a4f856dabc96d73aa40b081892699f..2f63610425006213b91274b9d82de49287f46453 100644 (file)
@@ -295,9 +295,6 @@ static void invert_det( struct brw_sf_compile *c)
 
 }
 
-#define NON_PERPECTIVE_ATTRS  (FRAG_BIT_WPOS | \
-                               FRAG_BIT_COL0 | \
-                              FRAG_BIT_COL1)
 
 static GLboolean calculate_masks( struct brw_sf_compile *c,
                                  GLuint reg,
@@ -306,9 +303,16 @@ static GLboolean calculate_masks( struct brw_sf_compile *c,
                                  GLushort *pc_linear)
 {
    GLboolean is_last_attr = (reg == c->nr_setup_regs - 1);
-   GLuint persp_mask = c->key.attrs & ~NON_PERPECTIVE_ATTRS;
+   GLuint persp_mask;
    GLuint linear_mask;
 
+   if (c->key.do_flat_shading || c->key.linear_color)
+      persp_mask = c->key.attrs & ~(FRAG_BIT_WPOS |
+                                    FRAG_BIT_COL0 |
+                                    FRAG_BIT_COL1);
+   else
+      persp_mask = c->key.attrs & ~(FRAG_BIT_WPOS);
+
    if (c->key.do_flat_shading)
       linear_mask = c->key.attrs & ~(FRAG_BIT_COL0|FRAG_BIT_COL1);
    else
index 68fa9820b6fba3a82926abaa8911ef38965720f3..c99918724b36b8964b021c74cf82563bab12a34e 100644 (file)
@@ -66,7 +66,9 @@ static void upload_sf_vp(struct brw_context *brw)
    sfv.viewport.m31 = v[MAT_TY] * y_scale + y_bias;
    sfv.viewport.m32 = v[MAT_TZ] * depth_scale;
 
-   /* _NEW_SCISSOR */
+   /* _NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT
+    * for DrawBuffer->_[XY]{min,max}
+    */
 
    /* The scissor only needs to handle the intersection of drawable and
     * scissor rect.  Clipping to the boundaries of static shared buffers
@@ -97,7 +99,8 @@ static void upload_sf_vp(struct brw_context *brw)
 const struct brw_tracked_state brw_sf_vp = {
    .dirty = {
       .mesa  = (_NEW_VIEWPORT | 
-               _NEW_SCISSOR),
+               _NEW_SCISSOR |
+               _NEW_BUFFERS),
       .brw   = 0,
       .cache = 0
    },
index 81b0a45998f05c41b950728bea2c2078c67df79a..bf9f6cae55e5af2836dffb3aff2db26ba2b375b1 100644 (file)
@@ -72,11 +72,13 @@ const struct brw_tracked_state brw_sf_vp;
 const struct brw_tracked_state brw_state_base_address;
 const struct brw_tracked_state brw_urb_fence;
 const struct brw_tracked_state brw_vertex_state;
+const struct brw_tracked_state brw_vs_surfaces;
 const struct brw_tracked_state brw_vs_prog;
 const struct brw_tracked_state brw_vs_unit;
 const struct brw_tracked_state brw_wm_input_sizes;
 const struct brw_tracked_state brw_wm_prog;
 const struct brw_tracked_state brw_wm_samplers;
+const struct brw_tracked_state brw_wm_constant_surface;
 const struct brw_tracked_state brw_wm_surfaces;
 const struct brw_tracked_state brw_wm_unit;
 
@@ -91,6 +93,20 @@ const struct brw_tracked_state brw_drawing_rect;
 const struct brw_tracked_state brw_indices;
 const struct brw_tracked_state brw_vertices;
 
+/**
+ * Use same key for WM and VS surfaces.
+ */
+struct brw_surface_key {
+   GLenum target, depthmode;
+   dri_bo *bo;
+   GLint format, internal_format;
+   GLint first_level, last_level;
+   GLint width, height, depth;
+   GLint pitch, cpp;
+   uint32_t tiling;
+   GLuint offset;
+};
+
 /***********************************************************************
  * brw_state.c
  */
@@ -135,8 +151,8 @@ dri_bo *brw_search_cache( struct brw_cache *cache,
                          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 );
+void brw_init_caches( struct brw_context *brw );
+void brw_destroy_caches( struct brw_context *brw );
 
 /***********************************************************************
  * brw_state_batch.c
@@ -150,4 +166,9 @@ GLboolean brw_cached_batch_struct( struct brw_context *brw,
 void brw_destroy_batch_cache( struct brw_context *brw );
 void brw_clear_batch_cache_flush( struct brw_context *brw );
 
+/* brw_wm_surface_state.c */
+dri_bo *
+brw_create_constant_surface( struct brw_context *brw,
+                             struct brw_surface_key *key );
+
 #endif
index d5b51664066a0da6a8e861d105926e51fa5af23b..e40d7a04164f50110f8070bedb4d60b6f7c01cb5 100644 (file)
@@ -56,9 +56,9 @@
  * incorrect program is run for the other instance.
  */
 
+#include "main/imports.h"
 #include "brw_state.h"
 #include "intel_batchbuffer.h"
-#include "main/imports.h"
 
 /* XXX: Fixme - have to include these to get the sizes of the prog_key
  * structs:
 #include "brw_sf.h"
 #include "brw_gs.h"
 
-static GLuint hash_key( const void *key, GLuint key_size,
-                       dri_bo **reloc_bufs, GLuint nr_reloc_bufs)
+
+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;
@@ -95,6 +97,7 @@ static GLuint hash_key( const void *key, GLuint key_size,
    return hash;
 }
 
+
 /**
  * Marks a new buffer as being chosen for the given cache id.
  */
@@ -111,6 +114,7 @@ update_cache_last(struct brw_cache *cache, enum brw_cache_id 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,
@@ -143,7 +147,8 @@ search_cache(struct brw_cache *cache, enum brw_cache_id cache_id,
 }
 
 
-static void rehash( struct brw_cache *cache )
+static void
+rehash(struct brw_cache *cache)
 {
    struct brw_cache_item **items;
    struct brw_cache_item *c, *next;
@@ -164,15 +169,17 @@ static void rehash( struct brw_cache *cache )
    cache->size = size;
 }
 
+
 /**
  * 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 )
+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 hash = hash_key(key, key_size, reloc_bufs, nr_reloc_bufs);
@@ -192,6 +199,7 @@ dri_bo *brw_search_cache( struct brw_cache *cache,
    return item->bo;
 }
 
+
 dri_bo *
 brw_upload_cache( struct brw_cache *cache,
                  enum brw_cache_id cache_id,
@@ -265,7 +273,9 @@ brw_upload_cache( struct brw_cache *cache,
    return bo;
 }
 
-/* This doesn't really work with aux data.  Use search/upload instead
+
+/**
+ * This doesn't really work with aux data.  Use search/upload instead
  */
 dri_bo *
 brw_cache_data_sz(struct brw_cache *cache,
@@ -296,6 +306,7 @@ brw_cache_data_sz(struct brw_cache *cache,
    return bo;
 }
 
+
 /**
  * Wrapper around brw_cache_data_sz using the cache_id's canonical key size.
  *
@@ -319,21 +330,22 @@ enum pool_type {
    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)
+brw_init_cache_id(struct brw_cache *cache,
+                  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;
 }
 
-void brw_init_cache( struct brw_context *brw )
+
+static void
+brw_init_non_surface_cache(struct brw_context *brw)
 {
    struct brw_cache *cache = &brw->cache;
 
@@ -342,114 +354,136 @@ void brw_init_cache( struct brw_context *brw )
    cache->size = 7;
    cache->n_items = 0;
    cache->items = (struct brw_cache_item **)
-      _mesa_calloc(cache->size * 
-                  sizeof(struct brw_cache_item));
+      _mesa_calloc(cache->size * sizeof(struct brw_cache_item));
 
-   brw_init_cache_id(brw,
+   brw_init_cache_id(cache,
                     "CC_VP",
                     BRW_CC_VP,
                     sizeof(struct brw_cc_viewport),
                     0);
 
-   brw_init_cache_id(brw,
+   brw_init_cache_id(cache,
                     "CC_UNIT",
                     BRW_CC_UNIT,
                     sizeof(struct brw_cc_unit_state),
                     0);
 
-   brw_init_cache_id(brw,
+   brw_init_cache_id(cache,
                     "WM_PROG",
                     BRW_WM_PROG,
                     sizeof(struct brw_wm_prog_key),
                     sizeof(struct brw_wm_prog_data));
 
-   brw_init_cache_id(brw,
+   brw_init_cache_id(cache,
                     "SAMPLER_DEFAULT_COLOR",
                     BRW_SAMPLER_DEFAULT_COLOR,
                     sizeof(struct brw_sampler_default_color),
                     0);
 
-   brw_init_cache_id(brw,
+   brw_init_cache_id(cache,
                     "SAMPLER",
                     BRW_SAMPLER,
                     0,         /* variable key/data size */
                     0);
 
-   brw_init_cache_id(brw,
+   brw_init_cache_id(cache,
                     "WM_UNIT",
                     BRW_WM_UNIT,
                     sizeof(struct brw_wm_unit_state),
                     0);
 
-   brw_init_cache_id(brw,
+   brw_init_cache_id(cache,
                     "SF_PROG",
                     BRW_SF_PROG,
                     sizeof(struct brw_sf_prog_key),
                     sizeof(struct brw_sf_prog_data));
 
-   brw_init_cache_id(brw,
+   brw_init_cache_id(cache,
                     "SF_VP",
                     BRW_SF_VP,
                     sizeof(struct brw_sf_viewport),
                     0);
 
-   brw_init_cache_id(brw,
+   brw_init_cache_id(cache,
                     "SF_UNIT",
                     BRW_SF_UNIT,
                     sizeof(struct brw_sf_unit_state),
                     0);
 
-   brw_init_cache_id(brw,
+   brw_init_cache_id(cache,
                     "VS_UNIT",
                     BRW_VS_UNIT,
                     sizeof(struct brw_vs_unit_state),
                     0);
 
-   brw_init_cache_id(brw,
+   brw_init_cache_id(cache,
                     "VS_PROG",
                     BRW_VS_PROG,
                     sizeof(struct brw_vs_prog_key),
                     sizeof(struct brw_vs_prog_data));
 
-   brw_init_cache_id(brw,
+   brw_init_cache_id(cache,
                     "CLIP_UNIT",
                     BRW_CLIP_UNIT,
                     sizeof(struct brw_clip_unit_state),
                     0);
 
-   brw_init_cache_id(brw,
+   brw_init_cache_id(cache,
                     "CLIP_PROG",
                     BRW_CLIP_PROG,
                     sizeof(struct brw_clip_prog_key),
                     sizeof(struct brw_clip_prog_data));
 
-   brw_init_cache_id(brw,
+   brw_init_cache_id(cache,
                     "GS_UNIT",
                     BRW_GS_UNIT,
                     sizeof(struct brw_gs_unit_state),
                     0);
 
-   brw_init_cache_id(brw,
+   brw_init_cache_id(cache,
                     "GS_PROG",
                     BRW_GS_PROG,
                     sizeof(struct brw_gs_prog_key),
                     sizeof(struct brw_gs_prog_data));
+}
+
+
+static void
+brw_init_surface_cache(struct brw_context *brw)
+{
+   struct brw_cache *cache = &brw->surface_cache;
+
+   cache->brw = brw;
 
-   brw_init_cache_id(brw,
+   cache->size = 7;
+   cache->n_items = 0;
+   cache->items = (struct brw_cache_item **)
+      _mesa_calloc(cache->size * sizeof(struct brw_cache_item));
+
+   brw_init_cache_id(cache,
                     "SS_SURFACE",
                     BRW_SS_SURFACE,
                     sizeof(struct brw_surface_state),
                     0);
 
-   brw_init_cache_id(brw,
+   brw_init_cache_id(cache,
                     "SS_SURF_BIND",
                     BRW_SS_SURF_BIND,
                     0,
                     0);
 }
 
+
+void
+brw_init_caches(struct brw_context *brw)
+{
+   brw_init_non_surface_cache(brw);
+   brw_init_surface_cache(brw);
+}
+
+
 static void
-brw_clear_cache( struct brw_context *brw )
+brw_clear_cache(struct brw_context *brw, struct brw_cache *cache)
 {
    struct brw_cache_item *c, *next;
    GLuint i;
@@ -457,8 +491,8 @@ brw_clear_cache( struct brw_context *brw )
    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) {
+   for (i = 0; i < cache->size; i++) {
+      for (c = cache->items[i]; c; c = next) {
         int j;
 
         next = c->next;
@@ -468,10 +502,10 @@ brw_clear_cache( struct brw_context *brw )
         free((void *)c->key);
         free(c);
       }
-      brw->cache.items[i] = NULL;
+      cache->items[i] = NULL;
    }
 
-   brw->cache.n_items = 0;
+   cache->n_items = 0;
 
    if (brw->curbe.last_buf) {
       _mesa_free(brw->curbe.last_buf);
@@ -483,25 +517,46 @@ brw_clear_cache( struct brw_context *brw )
    brw->state.dirty.cache |= ~0;
 }
 
-void brw_state_cache_check_size( struct brw_context *brw )
+
+void
+brw_state_cache_check_size(struct brw_context *brw)
 {
+   if (INTEL_DEBUG & DEBUG_STATE)
+      _mesa_printf("%s (n_items=%d)\n", __FUNCTION__, brw->cache.n_items);
+
    /* 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);
+      brw_clear_cache(brw, &brw->cache);
+
+   if (brw->surface_cache.n_items > 1000)
+      brw_clear_cache(brw, &brw->surface_cache);
 }
 
-void brw_destroy_cache( struct brw_context *brw )
+
+static void
+brw_destroy_cache(struct brw_context *brw, struct brw_cache *cache)
 {
    GLuint i;
 
-   brw_clear_cache(brw);
+   if (INTEL_DEBUG & DEBUG_STATE)
+      _mesa_printf("%s\n", __FUNCTION__);
+
+   brw_clear_cache(brw, cache);
    for (i = 0; i < BRW_MAX_CACHE; i++) {
-      dri_bo_unreference(brw->cache.last_bo[i]);
-      free(brw->cache.name[i]);
+      dri_bo_unreference(cache->last_bo[i]);
+      free(cache->name[i]);
    }
-   free(brw->cache.items);
-   brw->cache.items = NULL;
-   brw->cache.size = 0;
+   free(cache->items);
+   cache->items = NULL;
+   cache->size = 0;
+}
+
+
+void
+brw_destroy_caches(struct brw_context *brw)
+{
+   brw_destroy_cache(brw, &brw->cache);
+   brw_destroy_cache(brw, &brw->surface_cache);
 }
index 5de1450e6122e1e8d7e84da6640cbea4c18ffc6a..c6dfea4743cb8e7a30f709baccf5d2fd8200df5f 100644 (file)
@@ -59,11 +59,12 @@ const struct brw_tracked_state *atoms[] =
    &brw_curbe_offsets,
    &brw_recalculate_urb_fence,
 
-
    &brw_cc_vp,
    &brw_cc_unit,
 
-   &brw_wm_surfaces,           /* must do before samplers */
+   &brw_vs_surfaces,           /* must do before unit */
+   &brw_wm_constant_surface,   /* must do before wm surfaces/bind bo */
+   &brw_wm_surfaces,           /* must do before samplers and unit */
    &brw_wm_samplers,
 
    &brw_wm_unit,
@@ -88,54 +89,26 @@ const struct brw_tracked_state *atoms[] =
 
    &brw_line_stipple,
    &brw_aa_line_parameters,
-   /* Ordering of the commands below is documented as fixed.  
-    */
-#if 0
-   &brw_pipelined_state_pointers,
-   &brw_urb_fence,
-   &brw_constant_buffer_state,
-#else
+
    &brw_psp_urb_cbs,
-#endif
 
    &brw_drawing_rect,
    &brw_indices,
    &brw_vertices,
 
-   NULL,                       /* brw_constant_buffer */
+   &brw_constant_buffer
 };
 
 
 void brw_init_state( struct brw_context *brw )
 {
-   GLuint i;
-
-   brw_init_cache(brw);
-
-   brw->state.atoms = _mesa_malloc(sizeof(atoms));
-   brw->state.nr_atoms = sizeof(atoms)/sizeof(*atoms);
-   _mesa_memcpy(brw->state.atoms, atoms, sizeof(atoms));
-
-   /* Patch in a pointer to the dynamic state atom:
-    */
-   for (i = 0; i < brw->state.nr_atoms; i++)
-      if (brw->state.atoms[i] == NULL)
-        brw->state.atoms[i] = &brw->curbe.tracked_state;
-
-   _mesa_memcpy(&brw->curbe.tracked_state, 
-               &brw_constant_buffer,
-               sizeof(brw_constant_buffer));
+   brw_init_caches(brw);
 }
 
 
 void brw_destroy_state( struct brw_context *brw )
 {
-   if (brw->state.atoms) {
-      _mesa_free(brw->state.atoms);
-      brw->state.atoms = NULL;
-   }
-
-   brw_destroy_cache(brw);
+   brw_destroy_caches(brw);
    brw_destroy_batch_cache(brw);
 }
 
@@ -218,6 +191,7 @@ static struct dirty_bit_map mesa_bits[] = {
    DEFINE_BIT(_NEW_MULTISAMPLE),
    DEFINE_BIT(_NEW_TRACK_MATRIX),
    DEFINE_BIT(_NEW_PROGRAM),
+   DEFINE_BIT(_NEW_PROGRAM_CONSTANTS),
    {0, 0, 0}
 };
 
@@ -336,7 +310,7 @@ void brw_validate_state( struct brw_context *brw )
 
    /* do prepare stage for all atoms */
    for (i = 0; i < Elements(atoms); i++) {
-      const struct brw_tracked_state *atom = brw->state.atoms[i];
+      const struct brw_tracked_state *atom = atoms[i];
 
       if (brw->intel.Fallback)
          break;
@@ -367,8 +341,8 @@ void brw_upload_state(struct brw_context *brw)
       _mesa_memset(&examined, 0, sizeof(examined));
       prev = *state;
 
-      for (i = 0; i < brw->state.nr_atoms; i++) {       
-        const struct brw_tracked_state *atom = brw->state.atoms[i];
+      for (i = 0; i < Elements(atoms); i++) {   
+        const struct brw_tracked_state *atom = atoms[i];
         struct brw_state_flags generated;
 
         assert(atom->dirty.mesa ||
@@ -397,7 +371,7 @@ void brw_upload_state(struct brw_context *brw)
    }
    else {
       for (i = 0; i < Elements(atoms); i++) {   
-        const struct brw_tracked_state *atom = brw->state.atoms[i];
+        const struct brw_tracked_state *atom = atoms[i];
 
         if (brw->intel.Fallback)
            break;
index 51a617fcb400efb722eaa1b1ed6645dfc36fbe85..5c5455813a4500b4f4ac5e1e6ee4b4fc5af8e432 100644 (file)
@@ -28,7 +28,6 @@
   * Authors:
   *   Keith Whitwell <keith@tungstengraphics.com>
   */
-        
 
 /* Code to layout images in a mipmap tree for i965.
  */
 
 #define FILE_DEBUG_FLAG DEBUG_MIPTREE
 
-GLboolean brw_miptree_layout( struct intel_context *intel, struct intel_mipmap_tree *mt )
+GLboolean brw_miptree_layout(struct intel_context *intel,
+                            struct intel_mipmap_tree *mt,
+                            uint32_t tiling)
 {
-   /* XXX: these vary depending on image format: 
-    */
-/*    GLint align_w = 4; */
+   /* XXX: these vary depending on image format: */
+   /* GLint align_w = 4; */
 
    switch (mt->target) {
-   case GL_TEXTURE_CUBE_MAP: 
+   case GL_TEXTURE_CUBE_MAP:
    case GL_TEXTURE_3D: {
       GLuint width  = mt->width0;
       GLuint height = mt->height0;
@@ -59,25 +59,25 @@ GLboolean brw_miptree_layout( struct intel_context *intel, struct intel_mipmap_t
       GLuint align_w = 4;
 
       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);
+        mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, mt->width0);
+        pack_y_pitch = ALIGN(mt->height0, align_h);
       }
 
       pack_x_pitch = mt->pitch;
       pack_x_nr = 1;
 
-      for ( level = mt->first_level ; level <= mt->last_level ; level++ ) {
+      for (level = mt->first_level ; level <= mt->last_level ; level++) {
         GLuint nr_images = mt->target == GL_TEXTURE_3D ? depth : 6;
         GLint x = 0;
         GLint y = 0;
         GLint q, j;
-           
+
         intel_miptree_set_level_info(mt, level, nr_images,
                                      0, mt->total_height,
                                      width, height, depth);
@@ -89,7 +89,7 @@ GLboolean brw_miptree_layout( struct intel_context *intel, struct intel_mipmap_t
            }
 
            x = 0;
-           y += pack_y_pitch;      
+           y += pack_y_pitch;
         }
 
 
@@ -98,40 +98,40 @@ GLboolean brw_miptree_layout( struct intel_context *intel, struct intel_mipmap_t
         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);
-        }
-    }
+        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(intel, mt);
+      i945_miptree_layout_2d(intel, mt, tiling);
       break;
    }
-   DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__, 
-               mt->pitch, 
+   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;
 }
 
index b69616d6e5217b106e4cd0e240cac213e686588d..d7f75e3685e28ce22bbb0607c9e71da7f5be998e 100644 (file)
@@ -69,13 +69,18 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c )
 {
    GLuint i, reg = 0, mrf;
 
-#if 0
-   if (c->vp->program.Base.Parameters->NumParameters >= 6)
-      c->vp->use_const_buffer = 1;
+   /* Determine whether to use a real constant buffer or use a block
+    * of GRF registers for constants.  The later is faster but only
+    * works if everything fits in the GRF.
+    * XXX this heuristic/check may need some fine tuning...
+    */
+   if (c->vp->program.Base.Parameters->NumParameters +
+       c->vp->program.Base.NumTemporaries + 20 > BRW_MAX_GRF)
+      c->vp->use_const_buffer = GL_TRUE;
    else
-#endif
       c->vp->use_const_buffer = GL_FALSE;
-   /*printf("use_const_buffer = %d\n", c->use_const_buffer);*/
+
+   /*printf("use_const_buffer = %d\n", c->vp->use_const_buffer);*/
 
    /* r0 -- reserved as usual
     */
@@ -709,10 +714,11 @@ get_constant(struct brw_vs_compile *c,
    struct brw_compile *p = &c->func;
    struct brw_reg const_reg;
    struct brw_reg const2_reg;
+   const GLboolean relAddr = src->RelAddr;
 
    assert(argIndex < 3);
 
-   if (c->current_const[argIndex].index != src->Index || src->RelAddr) {
+   if (c->current_const[argIndex].index != src->Index || relAddr) {
       struct brw_reg addrReg = c->regs[PROGRAM_ADDRESS][0];
 
       c->current_const[argIndex].index = src->Index;
@@ -725,13 +731,13 @@ get_constant(struct brw_vs_compile *c,
       brw_dp_READ_4_vs(p,
                        c->current_const[argIndex].reg,/* writeback dest */
                        0,                             /* oword */
-                       src->RelAddr,                  /* relative indexing? */
+                       relAddr,                       /* relative indexing? */
                        addrReg,                       /* address register */
                        16 * src->Index,               /* byte offset */
                        SURF_INDEX_VERT_CONST_BUFFER   /* binding table index */
                        );
 
-      if (src->RelAddr) {
+      if (relAddr) {
          /* second read */
          const2_reg = get_tmp(c);
 
@@ -742,7 +748,7 @@ get_constant(struct brw_vs_compile *c,
          brw_dp_READ_4_vs(p,
                           const2_reg,              /* writeback dest */
                           1,                       /* oword */
-                          src->RelAddr,            /* relative indexing? */
+                          relAddr,                 /* relative indexing? */
                           addrReg,                 /* address register */
                           16 * src->Index,         /* byte offset */
                           SURF_INDEX_VERT_CONST_BUFFER
@@ -752,7 +758,7 @@ get_constant(struct brw_vs_compile *c,
 
    const_reg = c->current_const[argIndex].reg;
 
-   if (src->RelAddr) {
+   if (relAddr) {
       /* merge the two Owords into the constant register */
       /* const_reg[7..4] = const2_reg[7..4] */
       brw_MOV(p,
@@ -1219,7 +1225,7 @@ void brw_vs_emit(struct brw_vs_compile *c )
 
    for (insn = 0; insn < nr_insns; insn++) {
 
-      struct prog_instruction *inst = &c->vp->program.Base.Instructions[insn];
+      const struct prog_instruction *inst = &c->vp->program.Base.Instructions[insn];
       struct brw_reg args[3], dst;
       GLuint i;
       
@@ -1232,7 +1238,7 @@ void brw_vs_emit(struct brw_vs_compile *c )
        */
       if (inst->Opcode != OPCODE_SWZ)
          for (i = 0; i < 3; i++) {
-             struct prog_src_register *src = &inst->SrcReg[i];
+             const 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)
diff --git a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
new file mode 100644 (file)
index 0000000..89f4752
--- /dev/null
@@ -0,0 +1,226 @@
+/*
+ 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 "main/mtypes.h"
+#include "main/texformat.h"
+#include "main/texstore.h"
+#include "shader/prog_parameter.h"
+
+#include "brw_context.h"
+#include "brw_state.h"
+#include "brw_defines.h"
+
+/* Creates a new VS constant buffer reflecting the current VS program's
+ * constants, if needed by the VS program.
+ *
+ * Otherwise, constants go through the CURBEs using the brw_constant_buffer
+ * state atom.
+ */
+static drm_intel_bo *
+brw_vs_update_constant_buffer(struct brw_context *brw)
+{
+   struct intel_context *intel = &brw->intel;
+   struct brw_vertex_program *vp =
+      (struct brw_vertex_program *) brw->vertex_program;
+   const struct gl_program_parameter_list *params = vp->program.Base.Parameters;
+   const int size = params->NumParameters * 4 * sizeof(GLfloat);
+   drm_intel_bo *const_buffer;
+
+   /* BRW_NEW_VERTEX_PROGRAM */
+   if (!vp->use_const_buffer)
+      return NULL;
+
+   const_buffer = drm_intel_bo_alloc(intel->bufmgr, "vp_const_buffer",
+                                    size, 64);
+
+   /* _NEW_PROGRAM_CONSTANTS */
+   dri_bo_subdata(const_buffer, 0, size, params->ParameterValues);
+
+   return const_buffer;
+}
+
+/**
+ * Update the surface state for a VS constant buffer.
+ *
+ * Sets brw->vs.surf_bo[surf] and brw->vp->const_buffer.
+ */
+static void
+brw_update_vs_constant_surface( GLcontext *ctx,
+                                GLuint surf)
+{
+   struct brw_context *brw = brw_context(ctx);
+   struct brw_surface_key key;
+   struct brw_vertex_program *vp =
+      (struct brw_vertex_program *) brw->vertex_program;
+   const struct gl_program_parameter_list *params = vp->program.Base.Parameters;
+
+   assert(surf == 0);
+
+   /* If we're in this state update atom, we need to update VS constants, so
+    * free the old buffer and create a new one for the new contents.
+    */
+   dri_bo_unreference(vp->const_buffer);
+   vp->const_buffer = brw_vs_update_constant_buffer(brw);
+
+   /* If there's no constant buffer, then no surface BO is needed to point at
+    * it.
+    */
+   if (vp->const_buffer == 0) {
+      drm_intel_bo_unreference(brw->vs.surf_bo[surf]);
+      brw->vs.surf_bo[surf] = NULL;
+      return;
+   }
+
+   memset(&key, 0, sizeof(key));
+
+   key.format = MESA_FORMAT_RGBA_FLOAT32;
+   key.internal_format = GL_RGBA;
+   key.bo = vp->const_buffer;
+   key.depthmode = GL_NONE;
+   key.pitch = params->NumParameters;
+   key.width = params->NumParameters;
+   key.height = 1;
+   key.depth = 1;
+   key.cpp = 16;
+
+   /*
+   printf("%s:\n", __FUNCTION__);
+   printf("  width %d  height %d  depth %d  cpp %d  pitch %d\n",
+          key.width, key.height, key.depth, key.cpp, key.pitch);
+   */
+
+   drm_intel_bo_unreference(brw->vs.surf_bo[surf]);
+   brw->vs.surf_bo[surf] = brw_search_cache(&brw->surface_cache,
+                                            BRW_SS_SURFACE,
+                                            &key, sizeof(key),
+                                            &key.bo, key.bo ? 1 : 0,
+                                            NULL);
+   if (brw->vs.surf_bo[surf] == NULL) {
+      brw->vs.surf_bo[surf] = brw_create_constant_surface(brw, &key);
+   }
+}
+
+
+/**
+ * Constructs the binding table for the VS surface state.
+ */
+static dri_bo *
+brw_vs_get_binding_table(struct brw_context *brw)
+{
+   dri_bo *bind_bo;
+
+   bind_bo = brw_search_cache(&brw->surface_cache, BRW_SS_SURF_BIND,
+                             NULL, 0,
+                             brw->vs.surf_bo, BRW_VS_MAX_SURF,
+                             NULL);
+
+   if (bind_bo == NULL) {
+      GLuint data_size = BRW_VS_MAX_SURF * sizeof(GLuint);
+      uint32_t *data = malloc(data_size);
+      int i;
+
+      for (i = 0; i < BRW_VS_MAX_SURF; i++)
+         if (brw->vs.surf_bo[i])
+            data[i] = brw->vs.surf_bo[i]->offset;
+         else
+            data[i] = 0;
+
+      bind_bo = brw_upload_cache( &brw->surface_cache, BRW_SS_SURF_BIND,
+                                 NULL, 0,
+                                 brw->vs.surf_bo, BRW_VS_MAX_SURF,
+                                 data, data_size,
+                                 NULL, NULL);
+
+      /* Emit binding table relocations to surface state */
+      for (i = 0; i < BRW_VS_MAX_SURF; i++) {
+        if (brw->vs.surf_bo[i] != NULL) {
+           /* The presumed offsets were set in the data values for
+            * brw_upload_cache.
+            */
+           drm_intel_bo_emit_reloc(bind_bo, i * 4,
+                                   brw->vs.surf_bo[i], 0,
+                                   I915_GEM_DOMAIN_INSTRUCTION, 0);
+        }
+      }
+
+      free(data);
+   }
+
+   return bind_bo;
+}
+
+/**
+ * Vertex shader surfaces (constant buffer).
+ *
+ * This consumes the state updates for the constant buffer needing
+ * to be updated, and produces BRW_NEW_NR_VS_SURFACES for the VS unit and
+ * CACHE_NEW_SURF_BIND for the binding table upload.
+ */
+static void prepare_vs_surfaces(struct brw_context *brw )
+{
+   GLcontext *ctx = &brw->intel.ctx;
+   int i;
+   int nr_surfaces = 0;
+
+   brw_update_vs_constant_surface(ctx, SURF_INDEX_VERT_CONST_BUFFER);
+
+   for (i = 0; i < BRW_VS_MAX_SURF; i++) {
+      if (brw->vs.surf_bo[i] != NULL) {
+        nr_surfaces = i + 1;
+      }
+   }
+
+   if (brw->vs.nr_surfaces != nr_surfaces) {
+      brw->state.dirty.brw |= BRW_NEW_NR_VS_SURFACES;
+      brw->vs.nr_surfaces = nr_surfaces;
+   }
+
+   /* Note that we don't end up updating the bind_bo if we don't have a
+    * surface to be pointing at.  This should be relatively harmless, as it
+    * just slightly increases our working set size.
+    */
+   if (brw->vs.nr_surfaces != 0) {
+      dri_bo_unreference(brw->vs.bind_bo);
+      brw->vs.bind_bo = brw_vs_get_binding_table(brw);
+   }
+}
+
+const struct brw_tracked_state brw_vs_surfaces = {
+   .dirty = {
+      .mesa = (_NEW_PROGRAM_CONSTANTS),
+      .brw = (BRW_NEW_VERTEX_PROGRAM),
+      .cache = 0
+   },
+   .prepare = prepare_vs_surfaces,
+};
+
+
+
index c0b07da63b1d82b22d7b5f2e8aaba0999470077d..14e05be4f6c042eea668eaad9dcba294f513a442 100644 (file)
@@ -146,6 +146,13 @@ static void do_wm_prog( struct brw_context *brw,
    if (c == NULL) {
       brw->wm.compile_data = calloc(1, sizeof(*brw->wm.compile_data));
       c = brw->wm.compile_data;
+      if (c == NULL) {
+         /* Ouch - big out of memory problem.  Can't continue
+          * without triggering a segfault, no way to signal,
+          * so just return.
+          */
+         return;
+      }
    } else {
       memset(c, 0, sizeof(*brw->wm.compile_data));
    }
@@ -265,6 +272,9 @@ static void brw_wm_populate_key( struct brw_context *brw,
    /* _NEW_LIGHT */
    key->flat_shade = (ctx->Light.ShadeModel == GL_FLAT);
 
+   /* _NEW_HINT */
+   key->linear_color = (ctx->Hint.PerspectiveCorrection == GL_FASTEST);
+
    /* _NEW_TEXTURE */
    for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
       const struct gl_texture_unit *unit = &ctx->Texture.Unit[i];
@@ -312,6 +322,9 @@ static void brw_wm_populate_key( struct brw_context *brw,
       key->drawable_height = brw->intel.driDrawable->h;
    }
 
+   /* CACHE_NEW_VS_PROG */
+   key->vp_outputs_written = brw->vs.prog_data->outputs_written & DO_SETUP_BITS;
+
    /* The unique fragment program ID */
    key->program_string_id = fp->id;
 }
@@ -341,6 +354,7 @@ const struct brw_tracked_state brw_wm_prog = {
    .dirty = {
       .mesa  = (_NEW_COLOR |
                _NEW_DEPTH |
+                _NEW_HINT |
                _NEW_STENCIL |
                _NEW_POLYGON |
                _NEW_LINE |
@@ -350,7 +364,7 @@ const struct brw_tracked_state brw_wm_prog = {
       .brw   = (BRW_NEW_FRAGMENT_PROGRAM |
                BRW_NEW_WM_INPUT_DIMENSIONS |
                BRW_NEW_REDUCED_PRIMITIVE),
-      .cache = 0
+      .cache = CACHE_NEW_VS_PROG,
    },
    .prepare = brw_prepare_wm_prog
 };
index 0408034c38a6ce322df51e42328e51353d0b10dc..ba497432c601a8282d912dace18dc0a34f80bd9e 100644 (file)
@@ -63,6 +63,7 @@ struct brw_wm_prog_key {
    GLuint computes_depth:1;    /* could be derived from program string */
    GLuint source_depth_to_render_target:1;
    GLuint flat_shade:1;
+   GLuint linear_color:1;  /**< linear interpolation vs perspective interp */
    GLuint runtime_check_aads_emit:1;
    
    GLbitfield proj_attrib_mask; /**< one bit per fragment program attribute */
@@ -75,6 +76,7 @@ struct brw_wm_prog_key {
    GLuint program_string_id:32;
    GLuint origin_x, origin_y;
    GLuint drawable_height;
+   GLuint vp_outputs_written;
 };
 
 
@@ -240,15 +242,20 @@ struct brw_wm_compile {
    GLuint max_wm_grf;
    GLuint last_scratch;
 
+   GLuint cur_inst;  /**< index of current instruction */
+
+   GLboolean out_of_regs;  /**< ran out of GRF registers? */
+
    /** Mapping from Mesa registers to hardware registers */
    struct {
       GLboolean inited;
       struct brw_reg reg;
    } wm_regs[PROGRAM_PAYLOAD+1][256][4];
 
+   GLboolean used_grf[BRW_WM_MAX_GRF];
+   GLuint first_free_grf;
    struct brw_reg stack;
    struct brw_reg emit_mask_reg;
-   GLuint reg_index;  /**< Index of next free GRF register */
    GLuint tmp_regs[BRW_WM_MAX_GRF];
    GLuint tmp_index;
    GLuint tmp_max;
index 72fc21d2ebaae36371f4aca967fedff5802fd40b..14ab9042de7f2f3ca9a90ae75071f2ce047b8c2d 100644 (file)
@@ -353,6 +353,19 @@ static void emit_mad( struct brw_compile *p,
    }
 }
 
+static void emit_trunc( struct brw_compile *p,
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0)
+{
+   GLuint i;
+
+   for (i = 0; i < 4; i++) {
+      if (mask & (1<<i)) {
+        brw_RNDZ(p, dst[i], arg0[i]);
+      }
+   }
+}
 
 static void emit_lrp( struct brw_compile *p, 
                      const struct brw_reg *dst,
@@ -1224,6 +1237,10 @@ void brw_wm_emit( struct brw_wm_compile *c )
         emit_dph(p, dst, dst_flags, args[0], args[1]);
         break;
 
+      case OPCODE_TRUNC:
+        emit_trunc(p, dst, dst_flags, args[0]);
+        break;
+
       case OPCODE_LRP:
         emit_lrp(p, dst, dst_flags, args[0], args[1], args[2]);
         break;
index 49aad281d7a8d8751c7e617b7db57935a2102c77..b9e8dd2e96e6ea0172b1276bb2393031aab2e653 100644 (file)
@@ -354,13 +354,25 @@ static void emit_interp( struct brw_wm_compile *c,
                 src_undef());
       }
       else {
-        emit_op(c,
-                WM_LINTERP,
-                dst,
-                0,
-                interp,
-                deltas,
-                src_undef());
+         if (c->key.linear_color) {
+            emit_op(c,
+                    WM_LINTERP,
+                    dst,
+                    0,
+                    interp,
+                    deltas,
+                    src_undef());
+         }
+         else {
+            /* perspective-corrected color interpolation */
+            emit_op(c,
+                    WM_PINTERP,
+                    dst,
+                    0,
+                    interp,
+                    deltas,
+                    get_pixel_w(c));
+         }
       }
       break;
    case FRAG_ATTRIB_FOGC:
index 117460842a30fcaf71ff8ac026c342e042a367f8..24832276f4d8602a4236463bf95944a4174b4644 100644 (file)
@@ -1,5 +1,7 @@
 #include "main/macros.h"
 #include "shader/prog_parameter.h"
+#include "shader/prog_print.h"
+#include "shader/prog_optimize.h"
 #include "brw_context.h"
 #include "brw_eu.h"
 #include "brw_wm.h"
@@ -21,7 +23,6 @@ GLboolean brw_wm_is_glsl(const struct gl_fragment_program *fp)
        const struct prog_instruction *inst = &fp->Base.Instructions[i];
        switch (inst->Opcode) {
            case OPCODE_IF:
-           case OPCODE_TRUNC:
            case OPCODE_ENDIF:
            case OPCODE_CAL:
            case OPCODE_BRK:
@@ -42,6 +43,83 @@ GLboolean brw_wm_is_glsl(const struct gl_fragment_program *fp)
 }
 
 
+
+static void
+reclaim_temps(struct brw_wm_compile *c);
+
+
+/** Mark GRF register as used. */
+static void
+prealloc_grf(struct brw_wm_compile *c, int r)
+{
+   c->used_grf[r] = GL_TRUE;
+}
+
+
+/** Mark given GRF register as not in use. */
+static void
+release_grf(struct brw_wm_compile *c, int r)
+{
+   /*assert(c->used_grf[r]);*/
+   c->used_grf[r] = GL_FALSE;
+   c->first_free_grf = MIN2(c->first_free_grf, r);
+}
+
+
+/** Return index of a free GRF, mark it as used. */
+static int
+alloc_grf(struct brw_wm_compile *c)
+{
+   GLuint r;
+   for (r = c->first_free_grf; r < BRW_WM_MAX_GRF; r++) {
+      if (!c->used_grf[r]) {
+         c->used_grf[r] = GL_TRUE;
+         c->first_free_grf = r + 1;  /* a guess */
+         return r;
+      }
+   }
+
+   /* no free temps, try to reclaim some */
+   reclaim_temps(c);
+   c->first_free_grf = 0;
+
+   /* try alloc again */
+   for (r = c->first_free_grf; r < BRW_WM_MAX_GRF; r++) {
+      if (!c->used_grf[r]) {
+         c->used_grf[r] = GL_TRUE;
+         c->first_free_grf = r + 1;  /* a guess */
+         return r;
+      }
+   }
+
+   for (r = 0; r < BRW_WM_MAX_GRF; r++) {
+      assert(c->used_grf[r]);
+   }
+
+   /* really, no free GRF regs found */
+   if (!c->out_of_regs) {
+      /* print warning once per compilation */
+      _mesa_warning(NULL, "i965: ran out of registers for fragment program");
+      c->out_of_regs = GL_TRUE;
+   }
+
+   return -1;
+}
+
+
+/** Return number of GRF registers used */
+static int
+num_grf_used(const struct brw_wm_compile *c)
+{
+   int r;
+   for (r = BRW_WM_MAX_GRF - 1; r >= 0; r--)
+      if (c->used_grf[r])
+         return r + 1;
+   return 0;
+}
+
+
+
 /**
  * Record the mapping of a Mesa register to a hardware register.
  */
@@ -68,11 +146,23 @@ static int get_scalar_dst_index(const struct prog_instruction *inst)
 static struct brw_reg alloc_tmp(struct brw_wm_compile *c)
 {
     struct brw_reg reg;
-    if(c->tmp_index == c->tmp_max)
-       c->tmp_regs[ c->tmp_max++ ] = c->reg_index++;
-    
+
+    /* if we need to allocate another temp, grow the tmp_regs[] array */
+    if (c->tmp_index == c->tmp_max) {
+       int r = alloc_grf(c);
+       if (r < 0) {
+          /*printf("Out of temps in %s\n", __FUNCTION__);*/
+          r = 50; /* XXX random register! */
+       }
+       c->tmp_regs[ c->tmp_max++ ] = r;
+    }
+
+    /* form the GRF register */
     reg = brw_vec8_grf(c->tmp_regs[ c->tmp_index++ ], 0);
+    /*printf("alloc_temp %d\n", reg.nr);*/
+    assert(reg.nr < BRW_WM_MAX_GRF);
     return reg;
+
 }
 
 /**
@@ -130,35 +220,29 @@ get_reg(struct brw_wm_compile *c, int file, int index, int component,
            return brw_null_reg();
     }
 
+    assert(index < 256);
+    assert(component < 4);
+
     /* see if we've already allocated a HW register for this Mesa register */
     if (c->wm_regs[file][index][component].inited) {
-       /* yes, re-use */
-       reg = c->wm_regs[file][index][component].reg;
+       /* yes, re-use */
+       reg = c->wm_regs[file][index][component].reg;
     }
     else {
        /* no, allocate new register */
-       reg = brw_vec8_grf(c->reg_index, 0);
-    }
+       int grf = alloc_grf(c);
+       /*printf("alloc grf %d for reg %d:%d.%d\n", grf, file, index, component);*/
+       if (grf < 0) {
+          /* totally out of temps */
+          grf = 51; /* XXX random register! */
+       }
 
-    /* if this is a new register allocation, record it in the table */
-    if (!c->wm_regs[file][index][component].inited) {
-       set_reg(c, file, index, component, reg);
-       c->reg_index++;
-    }
+       reg = brw_vec8_grf(grf, 0);
+       /*printf("Alloc new grf %d for %d.%d\n", reg.nr, index, component);*/
 
-    if (c->reg_index >= BRW_WM_MAX_GRF - 12) {
-       /* ran out of temporary registers! */
-#if 1
-        /* This is a big hack for now.
-         * Return bad register index, just don't hang the GPU.
-         */
-        _mesa_fprintf(stderr, "out of regs %d\n", c->reg_index);
-        c->reg_index = BRW_WM_MAX_GRF - 13;
-#else
-       return brw_null_reg();
-#endif
+       set_reg(c, file, index, component, reg);
     }
+
     if (neg & (1 << component)) {
        reg = negate(reg);
     }
@@ -168,6 +252,46 @@ get_reg(struct brw_wm_compile *c, int file, int index, int component,
 }
 
 
+
+/**
+ * This is called if we run out of GRF registers.  Examine the live intervals
+ * of temp regs in the program and free those which won't be used again.
+ */
+static void
+reclaim_temps(struct brw_wm_compile *c)
+{
+   GLint intBegin[MAX_PROGRAM_TEMPS];
+   GLint intEnd[MAX_PROGRAM_TEMPS];
+   int index;
+
+   /*printf("Reclaim temps:\n");*/
+
+   _mesa_find_temp_intervals(c->prog_instructions, c->nr_fp_insns,
+                             intBegin, intEnd);
+
+   for (index = 0; index < MAX_PROGRAM_TEMPS; index++) {
+      if (intEnd[index] != -1 && intEnd[index] < c->cur_inst) {
+         /* program temp[i] can be freed */
+         int component;
+         /*printf("  temp[%d] is dead\n", index);*/
+         for (component = 0; component < 4; component++) {
+            if (c->wm_regs[PROGRAM_TEMPORARY][index][component].inited) {
+               int r = c->wm_regs[PROGRAM_TEMPORARY][index][component].reg.nr;
+               release_grf(c, r);
+               /*
+               printf("  Reclaim temp %d, reg %d at inst %d\n",
+                      index, r, c->cur_inst);
+               */
+               c->wm_regs[PROGRAM_TEMPORARY][index][component].inited = GL_FALSE;
+            }
+         }
+      }
+   }
+}
+
+
+
+
 /**
  * Preallocate registers.  This sets up the Mesa to hardware register
  * mapping for certain registers, such as constants (uniforms/state vars)
@@ -177,8 +301,12 @@ static void prealloc_reg(struct brw_wm_compile *c)
 {
     int i, j;
     struct brw_reg reg;
-    int nr_interp_regs = 0;
+    int urb_read_length = 0;
     GLuint inputs = FRAG_BIT_WPOS | c->fp_interp_emitted | c->fp_deriv_emitted;
+    GLuint reg_index = 0;
+
+    memset(c->used_grf, GL_FALSE, sizeof(c->used_grf));
+    c->first_free_grf = 0;
 
     for (i = 0; i < 4; i++) {
         if (i < c->key.nr_depth_regs) 
@@ -187,14 +315,20 @@ static void prealloc_reg(struct brw_wm_compile *c)
             reg = brw_vec8_grf(0, 0);
        set_reg(c, PROGRAM_PAYLOAD, PAYLOAD_DEPTH, i, reg);
     }
-    c->reg_index += 2 * c->key.nr_depth_regs;
+    reg_index += 2 * c->key.nr_depth_regs;
 
     /* constants */
     {
-        const int nr_params = c->fp->program.Base.Parameters->NumParameters;
+        const GLuint nr_params = c->fp->program.Base.Parameters->NumParameters;
+        const GLuint nr_temps = c->fp->program.Base.NumTemporaries;
 
         /* use a real constant buffer, or just use a section of the GRF? */
-        c->fp->use_const_buffer = GL_FALSE; /* (nr_params > 8);*/
+        /* XXX this heuristic may need adjustment... */
+        if ((nr_params + nr_temps) * 4 + reg_index > 80)
+           c->fp->use_const_buffer = GL_TRUE;
+        else
+           c->fp->use_const_buffer = GL_FALSE;
+        /*printf("WM use_const_buffer = %d\n", c->fp->use_const_buffer);*/
 
         if (c->fp->use_const_buffer) {
            /* We'll use a real constant buffer and fetch constants from
@@ -216,7 +350,7 @@ static void prealloc_reg(struct brw_wm_compile *c)
            for (i = 0; i < nr_params; i++) {
               /* loop over XYZW channels */
               for (j = 0; j < 4; j++, index++) {
-                 reg = brw_vec1_grf(c->reg_index + index / 8, index % 8);
+                 reg = brw_vec1_grf(reg_index + index / 8, index % 8);
                  /* Save pointer to parameter/constant value.
                   * Constants will be copied in prepare_constant_buffer()
                   */
@@ -226,28 +360,47 @@ static void prealloc_reg(struct brw_wm_compile *c)
            }
            /* number of constant regs used (each reg is float[8]) */
            c->nr_creg = 2 * ((4 * nr_params + 15) / 16);
-           c->reg_index += c->nr_creg;
+           reg_index += c->nr_creg;
         }
     }
 
     /* fragment shader inputs */
-    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;
-       }
+    for (i = 0; i < VERT_RESULT_MAX; i++) {
+       int fp_input;
+
+       if (i >= VERT_RESULT_VAR0)
+         fp_input = i - VERT_RESULT_VAR0 + FRAG_ATTRIB_VAR0;
+       else if (i <= VERT_RESULT_TEX7)
+         fp_input = i;
+       else
+         fp_input = -1;
+
+       if (fp_input >= 0 && inputs & (1 << fp_input)) {
+         urb_read_length = reg_index;
+         reg = brw_vec8_grf(reg_index, 0);
+         for (j = 0; j < 4; j++)
+            set_reg(c, PROGRAM_PAYLOAD, fp_input, j, reg);
+       }
+       if (c->key.vp_outputs_written & (1 << i)) {
+         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.urb_read_length = urb_read_length;
     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;
+    c->emit_mask_reg = brw_uw1_reg(BRW_GENERAL_REGISTER_FILE, reg_index, 0);
+    reg_index++;
+    c->stack =  brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, reg_index, 0);
+    reg_index += 2;
+
+    /* mark GRF regs [0..reg_index-1] as in-use */
+    for (i = 0; i < reg_index; i++)
+       prealloc_grf(c, i);
+
+    /* Don't use GRF 126, 127.  Using them seems to lead to GPU lock-ups */
+    prealloc_grf(c, 126);
+    prealloc_grf(c, 127);
 
     /* An instruction may reference up to three constants.
      * They'll be found in these registers.
@@ -256,12 +409,12 @@ static void prealloc_reg(struct brw_wm_compile *c)
     if (c->fp->use_const_buffer) {
        for (i = 0; i < 3; i++) {
           c->current_const[i].index = -1;
-          c->current_const[i].reg = alloc_tmp(c);
+          c->current_const[i].reg = brw_vec8_grf(alloc_grf(c), 0);
        }
     }
 #if 0
     printf("USE CONST BUFFER? %d\n", c->fp->use_const_buffer);
-    printf("AFTER PRE_ALLOC, reg_index = %d\n", c->reg_index);
+    printf("AFTER PRE_ALLOC, reg_index = %d\n", reg_index);
 #endif
 }
 
@@ -283,23 +436,21 @@ static void fetch_constants(struct brw_wm_compile *c,
       if (src->File == PROGRAM_STATE_VAR ||
           src->File == PROGRAM_CONSTANT ||
           src->File == PROGRAM_UNIFORM) {
-         if (c->current_const[i].index != src->Index) {
-            c->current_const[i].index = src->Index;
+        c->current_const[i].index = src->Index;
 
 #if 0
-            printf("  fetch const[%d] for arg %d into reg %d\n",
-                   src->Index, i, c->current_const[i].reg.nr);
+        printf("  fetch const[%d] for arg %d into reg %d\n",
+               src->Index, i, c->current_const[i].reg.nr);
 #endif
 
-            /* need to fetch the constant now */
-            brw_dp_READ_4(p,
-                          c->current_const[i].reg,  /* writeback dest */
-                          1,                        /* msg_reg */
-                          src->RelAddr,             /* relative indexing? */
-                          16 * src->Index,          /* byte offset */
-                          SURF_INDEX_FRAG_CONST_BUFFER/* binding table index */
-                          );
-         }
+        /* need to fetch the constant now */
+        brw_dp_READ_4(p,
+                      c->current_const[i].reg,  /* writeback dest */
+                      1,                        /* msg_reg */
+                      src->RelAddr,             /* relative indexing? */
+                      16 * src->Index,          /* byte offset */
+                      SURF_INDEX_FRAG_CONST_BUFFER/* binding table index */
+                      );
       }
    }
 }
@@ -368,6 +519,14 @@ static struct brw_reg get_src_reg(struct brw_wm_compile *c,
     const GLuint nr = 1;
     const GLuint component = GET_SWZ(src->Swizzle, channel);
 
+    /* Extended swizzle terms */
+    if (component == SWIZZLE_ZERO) {
+       return brw_imm_f(0.0F);
+    }
+    else if (component == SWIZZLE_ONE) {
+       return brw_imm_f(1.0F);
+    }
+
     if (c->fp->use_const_buffer &&
         (src->File == PROGRAM_STATE_VAR ||
          src->File == PROGRAM_CONSTANT ||
@@ -665,27 +824,26 @@ static void emit_fb_write(struct brw_wm_compile *c,
     }
 
     if (c->key.dest_depth_reg) {
-        GLuint comp = c->key.dest_depth_reg / 2;
-        GLuint off = c->key.dest_depth_reg % 2;
+        const GLuint comp = c->key.dest_depth_reg / 2;
+        const GLuint off = c->key.dest_depth_reg % 2;
 
-        assert(comp == 1);
-        assert(off == 0);
-#if 0
-        /* XXX do we need this code?   comp always 1, off always 0, it seems */
         if (off != 0) {
+            /* XXX this code needs review/testing */
+            struct brw_reg arg1_0 = get_src_reg(c, inst, 1, comp);
+            struct brw_reg arg1_1 = get_src_reg(c, inst, 1, comp+1);
+
             brw_push_insn_state(p);
             brw_set_compression_control(p, BRW_COMPRESSION_NONE);
 
-            brw_MOV(p, brw_message_reg(nr), offset(arg1[comp],1));
+            brw_MOV(p, brw_message_reg(nr), offset(arg1_0, 1));
             /* 2nd half? */
-            brw_MOV(p, brw_message_reg(nr+1), arg1[comp+1]);
+            brw_MOV(p, brw_message_reg(nr+1), arg1_1);
             brw_pop_insn_state(p);
         }
         else
-#endif
         {
-           struct brw_reg src =  get_src_reg(c, inst, 1, 1);
-           brw_MOV(p, brw_message_reg(nr), src);
+            struct brw_reg src =  get_src_reg(c, inst, 1, 1);
+            brw_MOV(p, brw_message_reg(nr), src);
         }
         nr += 2;
    }
@@ -2595,7 +2753,8 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c)
     struct brw_compile *p = &c->func;
     struct brw_indirect stack_index = brw_indirect(0, 0);
 
-    c->reg_index = 0;
+    c->out_of_regs = GL_FALSE;
+
     prealloc_reg(c);
     brw_set_compression_control(p, BRW_COMPRESSION_NONE);
     brw_MOV(p, get_addr_reg(stack_index), brw_address(c->stack));
@@ -2603,6 +2762,8 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c)
     for (i = 0; i < c->nr_fp_insns; i++) {
         const struct prog_instruction *inst = &c->prog_instructions[i];
 
+        c->cur_inst = i;
+
 #if 0
         _mesa_printf("Inst %d: ", i);
         _mesa_print_instruction(inst);
@@ -2670,6 +2831,7 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c)
                emit_trunc(c, inst);
                break;
            case OPCODE_MOV:
+           case OPCODE_SWZ:
                emit_mov(c, inst);
                break;
            case OPCODE_DP3:
@@ -2833,17 +2995,13 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c)
                _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);
-
-    if (c->reg_index >= BRW_WM_MAX_GRF) {
-        _mesa_problem(NULL, "Ran out of registers in brw_wm_emit_glsl()");
-        /* XXX we need to do some proper error recovery here */
-    }
 }
 
 
@@ -2867,6 +3025,6 @@ void brw_wm_glsl_emit(struct brw_context *brw, struct brw_wm_compile *c)
         brw_wm_print_program(c, "brw_wm_glsl_emit done");
     }
 
-    c->prog_data.total_grf = c->reg_index;
+    c->prog_data.total_grf = num_grf_used(c);
     c->prog_data.total_scratch = 0;
 }
index bd60ac9b3159542012e953d824057031a9318499..8fd067abe7d52b77ffc48fbf00fe0d6bd1f20067 100644 (file)
@@ -116,6 +116,10 @@ const struct {
  { C, 0, 1, 1, 1 } 
 };
 
+/**
+ * \param line_aa  AA_NEVER, AA_ALWAYS or AA_SOMETIMES
+ * \param lookup  bitmask of IZ_* flags
+ */
 void brw_wm_lookup_iz( GLuint line_aa,
                       GLuint lookup,
                       struct brw_wm_prog_key *key )
index ab9aa2f10d0b6df36ed71cc97b87f8fd2efbe8e6..3436a2471709fddf3ff15e1c472343322cc4209a 100644 (file)
@@ -159,6 +159,7 @@ void brw_wm_pass1( struct brw_wm_compile *c )
       case OPCODE_FRC:
       case OPCODE_MOV:
       case OPCODE_SWZ:
+      case OPCODE_TRUNC:
         read0 = writemask;
         break;
 
index 780edbc42e67a30fa95fc8c597b025c66cc0b8a8..6faea018fbcddfa09c354c14845bd2848aa26a61 100644 (file)
@@ -69,8 +69,6 @@ static void prealloc_reg(struct brw_wm_compile *c,
  */
 static void init_registers( struct brw_wm_compile *c )
 {
-   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,16 +83,19 @@ static void init_registers( struct brw_wm_compile *c )
       prealloc_reg(c, &c->creg[j], i++);
 
    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);
+      if (c->key.vp_outputs_written & (1<<j)) {
+        int fp_index;
+
+        if (j >= VERT_RESULT_VAR0)
+           fp_index = j - (VERT_RESULT_VAR0 - FRAG_ATTRIB_VAR0);
+        else if (j <= VERT_RESULT_TEX7)
+           fp_index = j;
         else
-            index = j;
+           fp_index = -1;
+
         nr_interp_regs++;
-        prealloc_reg(c, &c->payload.input_interp[index], i++);
+        if (fp_index >= 0)
+           prealloc_reg(c, &c->payload.input_interp[fp_index], i++);
       }
    }
 
index c604ef0162a75c209adc7af476a7b675262c76fb..3fc18ff1f3a3cfbc2de60736a96bb59c90d52839 100644 (file)
@@ -178,6 +178,16 @@ static void brw_update_sampler_state(struct wm_sampler_entry *key,
       sampler->ss1.s_wrap_mode = BRW_TEXCOORDMODE_CUBE;
       sampler->ss1.t_wrap_mode = BRW_TEXCOORDMODE_CUBE;
    }
+   else if (key->tex_target == GL_TEXTURE_1D) {
+      /* There's a bug in 1D texture sampling - it actually pays
+       * attention to the wrap_t value, though it should not.
+       * Override the wrap_t value here to GL_REPEAT to keep
+       * any nonexistent border pixels from floating in.
+       */
+      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 = BRW_TEXCOORDMODE_WRAP;
+   }
    else {
       sampler->ss1.r_wrap_mode = translate_wrap_mode(key->wrap_r);
       sampler->ss1.s_wrap_mode = translate_wrap_mode(key->wrap_s);
index 805df8a4af421e5873cc3b708d079956330bfb04..c49a5f6b4ec502b385d69dded35e8dd9c16f7e78 100644 (file)
@@ -176,22 +176,6 @@ static GLuint translate_tex_format( GLuint mesa_format, GLenum internal_format,
    }
 }
 
-
-/**
- * Use same key for WM and VS surfaces.
- */
-struct brw_surface_key {
-   GLenum target, depthmode;
-   dri_bo *bo;
-   GLint format, internal_format;
-   GLint first_level, last_level;
-   GLint width, height, depth;
-   GLint pitch, cpp;
-   uint32_t tiling;
-   GLuint offset;
-};
-
-
 static void
 brw_set_surface_tiling(struct brw_surface_state *surf, uint32_t tiling)
 {
@@ -268,7 +252,7 @@ brw_create_texture_surface( struct brw_context *brw,
       surf.ss0.cube_neg_z = 1;
    }
 
-   bo = brw_upload_cache(&brw->cache, BRW_SS_SURFACE,
+   bo = brw_upload_cache(&brw->surface_cache, BRW_SS_SURFACE,
                         key, sizeof(*key),
                         &key->bo, key->bo ? 1 : 0,
                         &surf, sizeof(surf),
@@ -321,10 +305,11 @@ brw_update_texture_surface( GLcontext *ctx, GLuint unit )
    key.tiling = intelObj->mt->region->tiling;
 
    dri_bo_unreference(brw->wm.surf_bo[surf]);
-   brw->wm.surf_bo[surf] = brw_search_cache(&brw->cache, BRW_SS_SURFACE,
-                                         &key, sizeof(key),
-                                         &key.bo, key.bo ? 1 : 0,
-                                         NULL);
+   brw->wm.surf_bo[surf] = brw_search_cache(&brw->surface_cache,
+                                            BRW_SS_SURFACE,
+                                            &key, sizeof(key),
+                                            &key.bo, key.bo ? 1 : 0,
+                                            NULL);
    if (brw->wm.surf_bo[surf] == NULL) {
       brw->wm.surf_bo[surf] = brw_create_texture_surface(brw, &key);
    }
@@ -336,7 +321,7 @@ brw_update_texture_surface( GLcontext *ctx, GLuint unit )
  * Create the constant buffer surface.  Vertex/fragment shader constants will be
  * read from this buffer with Data Port Read instructions/messages.
  */
-static dri_bo *
+dri_bo *
 brw_create_constant_surface( struct brw_context *brw,
                              struct brw_surface_key *key )
 {
@@ -362,7 +347,7 @@ brw_create_constant_surface( struct brw_context *brw,
    surf.ss3.pitch = (key->pitch * key->cpp) - 1; /* ignored?? */
    brw_set_surface_tiling(&surf, key->tiling); /* tiling now allowed */
  
-   bo = brw_upload_cache(&brw->cache, BRW_SS_SURFACE,
+   bo = brw_upload_cache(&brw->surface_cache, BRW_SS_SURFACE,
                         key, sizeof(*key),
                         &key->bo, key->bo ? 1 : 0,
                         &surf, sizeof(surf),
@@ -380,39 +365,70 @@ brw_create_constant_surface( struct brw_context *brw,
    return bo;
 }
 
+/* Creates a new WM constant buffer reflecting the current fragment program's
+ * constants, if needed by the fragment program.
+ *
+ * Otherwise, constants go through the CURBEs using the brw_constant_buffer
+ * state atom.
+ */
+static drm_intel_bo *
+brw_wm_update_constant_buffer(struct brw_context *brw)
+{
+   struct intel_context *intel = &brw->intel;
+   struct brw_fragment_program *fp =
+      (struct brw_fragment_program *) brw->fragment_program;
+   const struct gl_program_parameter_list *params = fp->program.Base.Parameters;
+   const int size = params->NumParameters * 4 * sizeof(GLfloat);
+   drm_intel_bo *const_buffer;
+
+   /* BRW_NEW_FRAGMENT_PROGRAM */
+   if (!fp->use_const_buffer)
+      return NULL;
+
+   const_buffer = drm_intel_bo_alloc(intel->bufmgr, "fp_const_buffer",
+                                    size, 64);
+
+   /* _NEW_PROGRAM_CONSTANTS */
+   dri_bo_subdata(const_buffer, 0, size, params->ParameterValues);
+
+   return const_buffer;
+}
 
 /**
  * Update the surface state for a WM constant buffer.
  * The constant buffer will be (re)allocated here if needed.
  */
-static dri_bo *
+static void
 brw_update_wm_constant_surface( GLcontext *ctx,
-                                GLuint surf,
-                                dri_bo *const_buffer,
-                                const struct gl_program_parameter_list *params)
+                                GLuint surf)
 {
    struct brw_context *brw = brw_context(ctx);
    struct brw_surface_key key;
-   struct intel_context *intel = &brw->intel;
-   const int size = params->NumParameters * 4 * sizeof(GLfloat);
+   struct brw_fragment_program *fp =
+      (struct brw_fragment_program *) brw->fragment_program;
+   const struct gl_program_parameter_list *params =
+      fp->program.Base.Parameters;
 
-   /* free old const buffer if too small */
-   if (const_buffer && const_buffer->size < size) {
-      dri_bo_unreference(const_buffer);
-      const_buffer = NULL;
-   }
+   /* If we're in this state update atom, we need to update WM constants, so
+    * free the old buffer and create a new one for the new contents.
+    */
+   dri_bo_unreference(fp->const_buffer);
+   fp->const_buffer = brw_wm_update_constant_buffer(brw);
 
-   /* alloc new buffer if needed */
-   if (!const_buffer) {
-      const_buffer =
-         drm_intel_bo_alloc(intel->bufmgr, "fp_const_buffer", size, 64);
+   /* If there's no constant buffer, then no surface BO is needed to point at
+    * it.
+    */
+   if (fp->const_buffer == 0) {
+      drm_intel_bo_unreference(brw->wm.surf_bo[surf]);
+      brw->wm.surf_bo[surf] = NULL;
+      return;
    }
 
    memset(&key, 0, sizeof(key));
 
    key.format = MESA_FORMAT_RGBA_FLOAT32;
    key.internal_format = GL_RGBA;
-   key.bo = const_buffer;
+   key.bo = fp->const_buffer;
    key.depthmode = GL_NONE;
    key.pitch = params->NumParameters;
    key.width = params->NumParameters;
@@ -427,77 +443,59 @@ brw_update_wm_constant_surface( GLcontext *ctx,
    */
 
    dri_bo_unreference(brw->wm.surf_bo[surf]);
-   brw->wm.surf_bo[surf] = brw_search_cache(&brw->cache, BRW_SS_SURFACE,
+   brw->wm.surf_bo[surf] = brw_search_cache(&brw->surface_cache,
+                                            BRW_SS_SURFACE,
                                             &key, sizeof(key),
                                             &key.bo, key.bo ? 1 : 0,
                                             NULL);
    if (brw->wm.surf_bo[surf] == NULL) {
       brw->wm.surf_bo[surf] = brw_create_constant_surface(brw, &key);
    }
-
-   return const_buffer;
+   brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;
 }
 
-
 /**
- * Update the surface state for a VS constant buffer.
- * The constant buffer will be (re)allocated here if needed.
+ * Updates surface / buffer for fragment shader constant buffer, if
+ * one is required.
+ *
+ * This consumes the state updates for the constant buffer, and produces
+ * BRW_NEW_WM_SURFACES to get picked up by brw_prepare_wm_surfaces for
+ * inclusion in the binding table.
  */
-static dri_bo *
-brw_update_vs_constant_surface( GLcontext *ctx,
-                                GLuint surf,
-                                dri_bo *const_buffer,
-                                const struct gl_program_parameter_list *params)
+static void prepare_wm_constant_surface(struct brw_context *brw )
 {
-   struct brw_context *brw = brw_context(ctx);
-   struct brw_surface_key key;
-   struct intel_context *intel = &brw->intel;
-   const int size = params->NumParameters * 4 * sizeof(GLfloat);
-
-   assert(surf == 0);
-
-   /* free old const buffer if too small */
-   if (const_buffer && const_buffer->size < size) {
-      dri_bo_unreference(const_buffer);
-      const_buffer = NULL;
-   }
-
-   /* alloc new buffer if needed */
-   if (!const_buffer) {
-      const_buffer =
-         drm_intel_bo_alloc(intel->bufmgr, "vp_const_buffer", size, 64);
-   }
-
-   memset(&key, 0, sizeof(key));
-
-   key.format = MESA_FORMAT_RGBA_FLOAT32;
-   key.internal_format = GL_RGBA;
-   key.bo = const_buffer;
-   key.depthmode = GL_NONE;
-   key.pitch = params->NumParameters;
-   key.width = params->NumParameters;
-   key.height = 1;
-   key.depth = 1;
-   key.cpp = 16;
+   GLcontext *ctx = &brw->intel.ctx;
+   struct brw_fragment_program *fp =
+      (struct brw_fragment_program *) brw->fragment_program;
+   GLuint surf = SURF_INDEX_FRAG_CONST_BUFFER;
 
-   /*
-   printf("%s:\n", __FUNCTION__);
-   printf("  width %d  height %d  depth %d  cpp %d  pitch %d\n",
-          key.width, key.height, key.depth, key.cpp, key.pitch);
-   */
+   drm_intel_bo_unreference(fp->const_buffer);
+   fp->const_buffer = brw_wm_update_constant_buffer(brw);
 
-   dri_bo_unreference(brw->vs.surf_bo[surf]);
-   brw->vs.surf_bo[surf] = brw_search_cache(&brw->cache, BRW_SS_SURFACE,
-                                            &key, sizeof(key),
-                                            &key.bo, key.bo ? 1 : 0,
-                                            NULL);
-   if (brw->vs.surf_bo[surf] == NULL) {
-      brw->vs.surf_bo[surf] = brw_create_constant_surface(brw, &key);
+   /* If there's no constant buffer, then no surface BO is needed to point at
+    * it.
+    */
+   if (fp->const_buffer == 0) {
+      if (brw->wm.surf_bo[surf] != NULL) {
+        drm_intel_bo_unreference(brw->wm.surf_bo[surf]);
+        brw->wm.surf_bo[surf] = NULL;
+        brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;
+      }
+      return;
    }
 
-   return const_buffer;
+   brw_update_wm_constant_surface(ctx, surf);
 }
 
+const struct brw_tracked_state brw_wm_constant_surface = {
+   .dirty = {
+      .mesa = (_NEW_PROGRAM_CONSTANTS),
+      .brw = (BRW_NEW_FRAGMENT_PROGRAM),
+      .cache = 0
+   },
+   .prepare = prepare_wm_constant_surface,
+};
+
 
 /**
  * Sets up a surface state structure to point at the given region.
@@ -507,7 +505,7 @@ brw_update_vs_constant_surface( GLcontext *ctx,
 static void
 brw_update_renderbuffer_surface(struct brw_context *brw,
                                struct gl_renderbuffer *rb,
-                               unsigned int unit, GLboolean cached)
+                               unsigned int unit)
 {
    GLcontext *ctx = &brw->intel.ctx;
    dri_bo *region_bo = NULL;
@@ -567,12 +565,11 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
                      ctx->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);
+   brw->wm.surf_bo[unit] = brw_search_cache(&brw->surface_cache,
+                                           BRW_SS_SURFACE,
+                                           &key, sizeof(key),
+                                           &region_bo, 1,
+                                           NULL);
 
    if (brw->wm.surf_bo[unit] == NULL) {
       struct brw_surface_state surf;
@@ -598,7 +595,8 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
       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,
+      brw->wm.surf_bo[unit] = brw_upload_cache(&brw->surface_cache,
+                                               BRW_SS_SURFACE,
                                                &key, sizeof(key),
                                               &region_bo, 1,
                                               &surf, sizeof(surf),
@@ -630,7 +628,7 @@ brw_wm_get_binding_table(struct brw_context *brw)
 
    assert(brw->wm.nr_surfaces <= BRW_WM_MAX_SURF);
 
-   bind_bo = brw_search_cache(&brw->cache, BRW_SS_SURF_BIND,
+   bind_bo = brw_search_cache(&brw->surface_cache, BRW_SS_SURF_BIND,
                              NULL, 0,
                              brw->wm.surf_bo, brw->wm.nr_surfaces,
                              NULL);
@@ -646,7 +644,7 @@ brw_wm_get_binding_table(struct brw_context *brw)
          else
             data[i] = 0;
 
-      bind_bo = brw_upload_cache( &brw->cache, BRW_SS_SURF_BIND,
+      bind_bo = brw_upload_cache( &brw->surface_cache, BRW_SS_SURF_BIND,
                                  NULL, 0,
                                  brw->wm.surf_bo, brw->wm.nr_surfaces,
                                  data, data_size,
@@ -682,27 +680,17 @@ static void prepare_wm_surfaces(struct brw_context *brw )
       for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
          brw_update_renderbuffer_surface(brw,
                                         ctx->DrawBuffer->_ColorDrawBuffers[i],
-                                        i,
-                                        GL_FALSE);
+                                        i);
       }
    } else {
-      brw_update_renderbuffer_surface(brw, NULL, 0, GL_TRUE);
+      brw_update_renderbuffer_surface(brw, NULL, 0);
    }
 
    old_nr_surfaces = brw->wm.nr_surfaces;
    brw->wm.nr_surfaces = MAX_DRAW_BUFFERS;
 
-   /* Update surface / buffer for fragment shader constant buffer */
-   {
-      const GLuint surf = SURF_INDEX_FRAG_CONST_BUFFER;
-      struct brw_fragment_program *fp =
-         (struct brw_fragment_program *) brw->fragment_program;
-      fp->const_buffer =
-         brw_update_wm_constant_surface(ctx, surf, fp->const_buffer,
-                                     fp->program.Base.Parameters);
-
-      brw->wm.nr_surfaces = surf + 1;
-   }
+   if (brw->wm.surf_bo[SURF_INDEX_FRAG_CONST_BUFFER] != NULL)
+       brw->wm.nr_surfaces = SURF_INDEX_FRAG_CONST_BUFFER + 1;
 
    /* Update surfaces for textures */
    for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
@@ -735,100 +723,16 @@ static void prepare_wm_surfaces(struct brw_context *brw )
       brw->state.dirty.brw |= BRW_NEW_NR_WM_SURFACES;
 }
 
-
-/**
- * Constructs the binding table for the VS surface state.
- */
-static dri_bo *
-brw_vs_get_binding_table(struct brw_context *brw)
-{
-   dri_bo *bind_bo;
-
-   assert(brw->vs.nr_surfaces <= BRW_VS_MAX_SURF);
-
-   bind_bo = brw_search_cache(&brw->cache, BRW_SS_SURF_BIND,
-                             NULL, 0,
-                             brw->vs.surf_bo, brw->vs.nr_surfaces,
-                             NULL);
-
-   if (bind_bo == NULL) {
-      GLuint data_size = brw->vs.nr_surfaces * sizeof(GLuint);
-      uint32_t *data = malloc(data_size);
-      int i;
-
-      for (i = 0; i < brw->vs.nr_surfaces; i++)
-         if (brw->vs.surf_bo[i])
-            data[i] = brw->vs.surf_bo[i]->offset;
-         else
-            data[i] = 0;
-
-      bind_bo = brw_upload_cache( &brw->cache, BRW_SS_SURF_BIND,
-                                 NULL, 0,
-                                 brw->vs.surf_bo, brw->vs.nr_surfaces,
-                                 data, data_size,
-                                 NULL, NULL);
-
-      /* Emit binding table relocations to surface state */
-      for (i = 0; i < BRW_VS_MAX_SURF; i++) {
-        if (brw->vs.surf_bo[i] != NULL) {
-           dri_bo_emit_reloc(bind_bo,
-                             I915_GEM_DOMAIN_INSTRUCTION, 0,
-                             0,
-                             i * sizeof(GLuint),
-                             brw->vs.surf_bo[i]);
-        }
-      }
-
-      free(data);
-   }
-
-   return bind_bo;
-}
-
-
-/**
- * Vertex shader surfaces.  Just constant buffer for now.  Could add vertex 
- * shader textures in the future.
- */
-static void prepare_vs_surfaces(struct brw_context *brw )
-{
-   GLcontext *ctx = &brw->intel.ctx;
-
-   /* Update surface / buffer for vertex shader constant buffer */
-   {
-      const GLuint surf = SURF_INDEX_VERT_CONST_BUFFER;
-      struct brw_vertex_program *vp =
-         (struct brw_vertex_program *) brw->vertex_program;
-      vp->const_buffer =
-         brw_update_vs_constant_surface(ctx, surf, vp->const_buffer,
-                                        vp->program.Base.Parameters);
-
-      brw->vs.nr_surfaces = 1;
-   }
-
-   dri_bo_unreference(brw->vs.bind_bo);
-   brw->vs.bind_bo = brw_vs_get_binding_table(brw);
-
-   if (1)
-      brw->state.dirty.brw |= BRW_NEW_NR_VS_SURFACES;
-}
-
-
-static void
-prepare_surfaces(struct brw_context *brw)
-{
-   prepare_wm_surfaces(brw);
-   prepare_vs_surfaces(brw);
-}
-
-
 const struct brw_tracked_state brw_wm_surfaces = {
    .dirty = {
-      .mesa = _NEW_COLOR | _NEW_TEXTURE | _NEW_BUFFERS | _NEW_PROGRAM,
-      .brw = BRW_NEW_CONTEXT,
+      .mesa = (_NEW_COLOR |
+               _NEW_TEXTURE |
+               _NEW_BUFFERS),
+      .brw = (BRW_NEW_CONTEXT |
+             BRW_NEW_WM_SURFACES),
       .cache = 0
    },
-   .prepare = prepare_surfaces,
+   .prepare = prepare_wm_surfaces,
 };
 
 
diff --git a/src/mesa/drivers/dri/i965/intel_generatemipmap.c b/src/mesa/drivers/dri/i965/intel_generatemipmap.c
new file mode 120000 (symlink)
index 0000000..4c6b37a
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_generatemipmap.c
\ No newline at end of file
index c849e4869e5f55482ef05c3b5f101acab888f271..23ba3b9ef677e8be3b1f2f63ec3c10494cff7282 100644 (file)
@@ -35,6 +35,9 @@
 #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
@@ -100,8 +103,15 @@ intel_bufferobj_free(GLcontext * ctx, struct gl_buffer_object *obj)
    struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
 
    assert(intel_obj);
-   assert(!obj->Pointer); /* Mesa should have unmapped it */
 
+   /* Buffer objects are automatically unmapped when deleting according
+    * to the spec, but Mesa doesn't do UnmapBuffer for us at context destroy
+    * (though it does if you call glDeleteBuffers)
+    */
+   if (obj->Pointer)
+      intel_bufferobj_unmap(ctx, 0, obj);
+
+   _mesa_free(intel_obj->sys_buffer);
    if (intel_obj->region) {
       intel_bufferobj_release_region(intel, intel_obj);
    }
@@ -142,7 +152,23 @@ intel_bufferobj_data(GLcontext * ctx,
       dri_bo_unreference(intel_obj->buffer);
       intel_obj->buffer = NULL;
    }
+   _mesa_free(intel_obj->sys_buffer);
+   intel_obj->sys_buffer = NULL;
+
    if (size != 0) {
+#ifdef I915
+      /* On pre-965, stick VBOs in system memory, as we're always doing swtnl
+       * with their contents anyway.
+       */
+      if (target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER) {
+        intel_obj->sys_buffer = _mesa_malloc(size);
+        if (intel_obj->sys_buffer != NULL) {
+           if (data != NULL)
+              memcpy(intel_obj->sys_buffer, data, size);
+           return;
+        }
+      }
+#endif
       intel_bufferobj_alloc_buffer(intel, intel_obj);
 
       if (data != NULL)
@@ -172,7 +198,10 @@ intel_bufferobj_subdata(GLcontext * ctx,
    if (intel_obj->region)
       intel_bufferobj_cow(intel, intel_obj);
 
-   dri_bo_subdata(intel_obj->buffer, offset, size, data);
+   if (intel_obj->sys_buffer)
+      memcpy((char *)intel_obj->sys_buffer + offset, data, size);
+   else
+      dri_bo_subdata(intel_obj->buffer, offset, size, data);
 }
 
 
@@ -205,9 +234,15 @@ intel_bufferobj_map(GLcontext * ctx,
    struct intel_context *intel = intel_context(ctx);
    struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
    GLboolean read_only = (access == GL_READ_ONLY_ARB);
+   GLboolean write_only = (access == GL_WRITE_ONLY_ARB);
 
    assert(intel_obj);
 
+   if (intel_obj->sys_buffer) {
+      obj->Pointer = intel_obj->sys_buffer;
+      return obj->Pointer;
+   }
+
    if (intel_obj->region)
       intel_bufferobj_cow(intel, intel_obj);
 
@@ -216,7 +251,14 @@ intel_bufferobj_map(GLcontext * ctx,
       return NULL;
    }
 
-   dri_bo_map(intel_obj->buffer, !read_only);
+   if (write_only && intel->intelScreen->kernel_exec_fencing) {
+      drm_intel_gem_bo_map_gtt(intel_obj->buffer);
+      intel_obj->mapped_gtt = GL_TRUE;
+   } else {
+      drm_intel_bo_map(intel_obj->buffer, !read_only);
+      intel_obj->mapped_gtt = GL_FALSE;
+   }
+
    obj->Pointer = intel_obj->buffer->virtual;
    return obj->Pointer;
 }
@@ -234,7 +276,11 @@ intel_bufferobj_unmap(GLcontext * ctx,
    assert(intel_obj);
    if (intel_obj->buffer != NULL) {
       assert(obj->Pointer);
-      dri_bo_unmap(intel_obj->buffer);
+      if (intel_obj->mapped_gtt) {
+        drm_intel_gem_bo_unmap_gtt(intel_obj->buffer);
+      } else {
+        drm_intel_bo_unmap(intel_obj->buffer);
+      }
       obj->Pointer = NULL;
    }
    return GL_TRUE;
@@ -253,6 +299,18 @@ intel_bufferobj_buffer(struct intel_context *intel,
       }
    }
 
+   if (intel_obj->buffer == NULL) {
+      intel_bufferobj_alloc_buffer(intel, intel_obj);
+      intel_bufferobj_subdata(&intel->ctx,
+                             GL_ARRAY_BUFFER_ARB,
+                             0,
+                             intel_obj->Base.Size,
+                             intel_obj->sys_buffer,
+                             &intel_obj->Base);
+      _mesa_free(intel_obj->sys_buffer);
+      intel_obj->sys_buffer = NULL;
+   }
+
    return intel_obj->buffer;
 }
 
index bf6dbd58f27adc9c234d80f7039cdf7b21174cda..0431015631976276604b79836a38cb9ef0495246 100644 (file)
@@ -42,10 +42,13 @@ struct intel_buffer_object
 {
    struct gl_buffer_object Base;
    dri_bo *buffer;     /* the low-level buffer manager's buffer handle */
+   /** System memory buffer data, if not using a BO to store the data. */
+   void *sys_buffer;
 
    struct intel_region *region; /* Is there a zero-copy texture
                                    associated with this (pixel)
                                    buffer object? */
+   GLboolean mapped_gtt;
 };
 
 
index b86cafea241a81ec0f5e0f4bb2443e0f0ffd3302..df5c3fc1766f40cbb3487fea397db96bb1b79d0a 100644 (file)
@@ -157,7 +157,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
    /* Do this here, not core Mesa, since this function is called from
     * many places within the driver.
     */
-   if (ctx->NewState & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL)) {
+   if (ctx->NewState & _NEW_BUFFERS) {
       /* this updates the DrawBuffer->_NumColorDrawBuffers fields, etc */
       _mesa_update_framebuffer(ctx);
       /* this updates the DrawBuffer's Width/Height if it's a FBO */
@@ -276,7 +276,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
       ctx->Driver.Enable(ctx, GL_DEPTH_TEST,
                          (ctx->Depth.Test && fb->Visual.depthBits > 0));
       ctx->Driver.Enable(ctx, GL_STENCIL_TEST,
-                         (ctx->Stencil._Enabled && fb->Visual.stencilBits > 0));
+                         (ctx->Stencil.Enabled && fb->Visual.stencilBits > 0));
    }
    else {
       /* Mesa's Stencil._Enabled field is updated when
index eb0d890f477d68d9f5daf1cc399928629e9531ca..21f534d090b589ff67197de4aeb554cbf018ea06 100644 (file)
@@ -53,6 +53,7 @@
 #include "intel_clear.h"
 #include "intel_fbo.h"
 #include "intel_pixel.h"
+#include "intel_regions.h"
 
 #define FILE_DEBUG_FLAG DEBUG_BLIT
 
@@ -133,7 +134,6 @@ intel_clear_tris(GLcontext *ctx, GLbitfield mask)
                    BUFFER_BIT_STENCIL)) == 0);
 
    _mesa_PushAttrib(GL_COLOR_BUFFER_BIT |
-                   GL_CURRENT_BIT |
                    GL_DEPTH_BUFFER_BIT |
                    GL_ENABLE_BIT |
                    GL_POLYGON_BIT |
@@ -255,8 +255,10 @@ intel_clear_tris(GLcontext *ctx, GLbitfield mask)
       /* Control writing of the stencil clear value to stencil. */
       if (this_mask & BUFFER_BIT_STENCIL) {
         _mesa_Enable(GL_STENCIL_TEST);
-        _mesa_StencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
-        _mesa_StencilFuncSeparate(GL_FRONT, GL_ALWAYS, ctx->Stencil.Clear,
+        _mesa_StencilOpSeparate(GL_FRONT_AND_BACK,
+                                GL_REPLACE, GL_REPLACE, GL_REPLACE);
+        _mesa_StencilFuncSeparate(GL_FRONT_AND_BACK, GL_ALWAYS,
+                                  ctx->Stencil.Clear,
                                   ctx->Stencil.WriteMask[0]);
       } else {
         _mesa_Disable(GL_STENCIL_TEST);
@@ -310,7 +312,6 @@ static const char *buffer_names[] = {
 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;
@@ -338,7 +339,7 @@ intelClear(GLcontext *ctx, GLbitfield mask)
          = intel_get_rb_region(fb, BUFFER_STENCIL);
       if (stencilRegion) {
          /* have hw stencil */
-         if (IS_965(intel->intelScreen->deviceID) ||
+         if (stencilRegion->tiling == I915_TILING_Y ||
             (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
@@ -355,9 +356,10 @@ intelClear(GLcontext *ctx, GLbitfield mask)
 
    /* HW depth */
    if (mask & BUFFER_BIT_DEPTH) {
+      const struct intel_region *irb = intel_get_rb_region(fb, BUFFER_DEPTH);
+
       /* clear depth with whatever method is used for stencil (see above) */
-      if (IS_965(intel->intelScreen->deviceID) ||
-         tri_mask & BUFFER_BIT_STENCIL)
+      if (irb->tiling == I915_TILING_Y || tri_mask & BUFFER_BIT_STENCIL)
          tri_mask |= BUFFER_BIT_DEPTH;
       else
          blit_mask |= BUFFER_BIT_DEPTH;
index 5dc3df395d18f4a887b29dca32dce0b2789e1580..f88b37d0f3a368b22f60bd323b5094153fc6e8c0 100644 (file)
@@ -394,7 +394,7 @@ intel_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
     if (!driContext->driScreenPriv->dri2.enabled)
        return;
 
-    if (!intel->internal_viewport_call) {
+    if (!intel->internal_viewport_call && ctx->DrawBuffer->Name == 0) {
        intel_update_renderbuffers(driContext, driContext->driDrawablePriv);
        if (driContext->driDrawablePriv != driContext->driReadablePriv)
          intel_update_renderbuffers(driContext, driContext->driReadablePriv);
@@ -550,6 +550,9 @@ intelInitDriverFunctions(struct dd_function_table *functions)
    functions->CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
 
    intelInitTextureFuncs(functions);
+   intelInitTextureImageFuncs(functions);
+   intelInitTextureSubImageFuncs(functions);
+   intelInitTextureCopyImageFuncs(functions);
    intelInitStateFuncs(functions);
    intelInitClearFuncs(functions);
    intelInitBufferFuncs(functions);
@@ -650,6 +653,13 @@ intelInitContext(struct intel_context *intel,
    _mesa_init_point(ctx);
 
    ctx->Const.MaxColorAttachments = 4;  /* XXX FBO: review this */
+   if (IS_965(intelScreen->deviceID)) {
+      if (MAX_WIDTH > 8192)
+        ctx->Const.MaxRenderbufferSize = 8192;
+   } else {
+      if (MAX_WIDTH > 2048)
+        ctx->Const.MaxRenderbufferSize = 2048;
+   }
 
    /* Initialize the software rasterizer and helper modules. */
    _swrast_CreateContext(ctx);
@@ -717,6 +727,9 @@ intelInitContext(struct intel_context *intel,
    else if (driQueryOptionb(&intel->optionCache, "force_s3tc_enable")) {
       _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
    }
+   intel->use_texture_tiling = driQueryOptionb(&intel->optionCache,
+                                              "texture_tiling");
+   intel->use_early_z = driQueryOptionb(&intel->optionCache, "early_z");
 
    intel->prim.primitive = ~0;
 
@@ -778,13 +791,64 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv)
       intel->prim.vb_bo = NULL;
 
       if (release_texture_heaps) {
-         /* This share group is about to go away, free our private
-          * texture object data.
+         /* Nothing is currently done here to free texture heaps;
+          * but we're not using the texture heap utilities, so I
+          * rather think we shouldn't.  I've taken a look, and can't
+          * find any private texture data hanging around anywhere, but
+          * I'm not yet certain there isn't any at all...
           */
-         if (INTEL_DEBUG & DEBUG_TEXTURE)
+         /* if (INTEL_DEBUG & DEBUG_TEXTURE)
             fprintf(stderr, "do something to free texture heaps\n");
+          */
       }
 
+      /* XXX In intelMakeCurrent() below, the context's static regions are 
+       * referenced inside the frame buffer; it's listed as a hack,
+       * with a comment of "XXX FBO temporary fix-ups!", but
+       * as long as it's there, we should release the regions here.
+       * The do/while loop around the block is used to allow the
+       * "continue" statements inside the block to exit the block,
+       * to avoid many layers of "if" constructs.
+       */
+      do {
+         __DRIdrawablePrivate * driDrawPriv = intel->driDrawable;
+         struct intel_framebuffer *intel_fb;
+         struct intel_renderbuffer *irbDepth, *irbStencil;
+         if (!driDrawPriv) {
+            /* We're already detached from the drawable; exit this block. */
+            continue;
+         }
+         intel_fb = (struct intel_framebuffer *) driDrawPriv->driverPrivate;
+         if (!intel_fb) {
+            /* The frame buffer is already gone; exit this block. */
+            continue;
+         }
+         irbDepth = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
+         irbStencil = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
+
+         /* If the regions of the frame buffer still match the regions
+          * of the context, release them.  If they've changed somehow,
+          * leave them alone.
+          */
+         if (intel_fb->color_rb[0] && intel_fb->color_rb[0]->region == intel->front_region) {
+           intel_renderbuffer_set_region(intel_fb->color_rb[0], NULL);
+         }
+         if (intel_fb->color_rb[1] && intel_fb->color_rb[1]->region == intel->back_region) {
+           intel_renderbuffer_set_region(intel_fb->color_rb[1], NULL);
+         }
+
+         if (irbDepth && irbDepth->region == intel->depth_region) {
+           intel_renderbuffer_set_region(irbDepth, NULL);
+         }
+         /* Usually, the stencil buffer is the same as the depth buffer;
+          * but they're handled separately in MakeCurrent, so we'll
+          * handle them separately here.
+          */
+         if (irbStencil && irbStencil->region == intel->depth_region) {
+           intel_renderbuffer_set_region(irbStencil, NULL);
+         }
+      } while (0);
+
       intel_region_release(&intel->front_region);
       intel_region_release(&intel->back_region);
       intel_region_release(&intel->depth_region);
@@ -793,6 +857,8 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv)
 
       /* free the Mesa context */
       _mesa_free_context_data(&intel->ctx);
+
+      
    }
 }
 
@@ -821,7 +887,10 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
           if (driDrawPriv != driReadPriv)
               intel_update_renderbuffers(driContextPriv, driReadPriv);
       } else {
-          /* XXX FBO temporary fix-ups! */
+          /* XXX FBO temporary fix-ups!  These are released in 
+           * intelDextroyContext(), above.  Changes here should be
+           * reflected there.
+           */
           /* if the renderbuffers don't have regions, init them from the context */
          struct intel_renderbuffer *irbDepth
             = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
index f45e24ca3a19377b6f2df3ba390dcc55ddaea907..7d3c80bb21cce1385eb0238c987c2f7f4c21b6f8 100644 (file)
@@ -161,12 +161,22 @@ struct intel_context
    struct {
       struct gl_fragment_program *bitmap_fp;
       struct gl_vertex_program *passthrough_vp;
+      struct gl_buffer_object *texcoord_vbo;
 
       struct gl_fragment_program *saved_fp;
       GLboolean saved_fp_enable;
       struct gl_vertex_program *saved_vp;
       GLboolean saved_vp_enable;
 
+      struct gl_fragment_program *tex2d_fp;
+
+      GLboolean saved_texcoord_enable;
+      struct gl_buffer_object *saved_array_vbo, *saved_texcoord_vbo;
+      GLenum saved_texcoord_type;
+      GLsizei saved_texcoord_size, saved_texcoord_stride;
+      const void *saved_texcoord_ptr;
+      int saved_active_texture;
+
       GLint saved_vp_x, saved_vp_y;
       GLsizei saved_vp_width, saved_vp_height;
       GLenum saved_matrix_mode;
@@ -295,6 +305,9 @@ struct intel_context
     */
    GLboolean is_front_buffer_rendering;
 
+   GLboolean use_texture_tiling;
+   GLboolean use_early_z;
+
    drm_clip_rect_t fboRect;     /**< cliprect for FBO rendering */
 
    int perf_boxes;
@@ -549,6 +562,9 @@ void intel_viewport(GLcontext * ctx, GLint x, GLint y,
 void intel_update_renderbuffers(__DRIcontext *context,
                                __DRIdrawable *drawable);
 
+void i915_set_buf_info_for_region(uint32_t *state, struct intel_region *region,
+                                 uint32_t buffer_id);
+
 /*======================================================================
  * Inline conversion functions.  
  * These are better-typed than the macros used previously:
@@ -559,4 +575,10 @@ intel_context(GLcontext * ctx)
    return (struct intel_context *) ctx;
 }
 
+static INLINE GLboolean
+is_power_of_two(uint32_t value)
+{
+   return (value & (value - 1)) == 0;
+}
+
 #endif
index 9ec1b4ec2f469ca24bd525829bd9725bd85a83de..269f4ff55634496e328d8bff7fd05bf8de2eb741 100644 (file)
@@ -48,6 +48,7 @@
 #define need_GL_EXT_point_parameters
 #define need_GL_EXT_secondary_color
 #define need_GL_EXT_stencil_two_side
+#define need_GL_APPLE_vertex_array_object
 #define need_GL_ATI_separate_stencil
 #define need_GL_ATI_envmap_bumpmap
 #define need_GL_NV_point_sprite
@@ -65,6 +66,7 @@
  * i965_dri.
  */
 static const struct dri_extension card_extensions[] = {
+   { "GL_ARB_half_float_pixel",           NULL },
    { "GL_ARB_multitexture",               NULL },
    { "GL_ARB_point_parameters",           GL_ARB_point_parameters_functions },
    { "GL_ARB_texture_border_clamp",       NULL },
@@ -95,6 +97,7 @@ static const struct dri_extension card_extensions[] = {
    { "GL_EXT_texture_lod_bias",           NULL },
    { "GL_3DFX_texture_compression_FXT1",  NULL },
    { "GL_APPLE_client_storage",           NULL },
+   { "GL_APPLE_vertex_array_object",      GL_APPLE_vertex_array_object_functions},
    { "GL_MESA_pack_invert",               NULL },
    { "GL_MESA_ycbcr_texture",             NULL },
    { "GL_NV_blend_square",                NULL },
index 52647ddf8b2cdd32df6bb794feee6c9877527719..0ea413aee1da195a3dc8caa8f838aacfe8f58fbc 100644 (file)
@@ -217,7 +217,8 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
       DBG("Allocating %d x %d Intel RBO (pitch %d)\n", width,
          height, pitch);
 
-      irb->region = intel_region_alloc(intel, cpp, width, height, pitch,
+      irb->region = intel_region_alloc(intel, I915_TILING_NONE,
+                                      cpp, width, height, pitch,
                                       GL_TRUE);
       if (!irb->region)
          return GL_FALSE;       /* out of memory? */
@@ -574,9 +575,10 @@ intel_render_texture(GLcontext * ctx,
 
    ASSERT(newImage);
 
-   if (newImage->Border != 0) {
-      /* Fallback on drawing to a texture with a border, which won't have a
-       * miptree.
+   intel_image = intel_texture_image(newImage);
+   if (!intel_image->mt) {
+      /* Fallback on drawing to a texture that doesn't have a miptree
+       * (has a border, width/height 0, etc.)
        */
       _mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
       _mesa_render_texture(ctx, fb, att);
@@ -607,7 +609,6 @@ intel_render_texture(GLcontext * ctx,
        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);
@@ -679,6 +680,11 @@ intel_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
       if (rb == NULL)
         continue;
 
+      if (irb == NULL) {
+        fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+        continue;
+      }
+
       switch (irb->texformat->MesaFormat) {
       case MESA_FORMAT_ARGB8888:
       case MESA_FORMAT_RGB565:
diff --git a/src/mesa/drivers/dri/intel/intel_generatemipmap.c b/src/mesa/drivers/dri/intel/intel_generatemipmap.c
new file mode 100644 (file)
index 0000000..1060fbd
--- /dev/null
@@ -0,0 +1,283 @@
+/*
+ * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
+ * Copyright Â© 2009 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 "main/glheader.h"
+#include "main/enums.h"
+#include "main/image.h"
+#include "main/mtypes.h"
+#include "main/macros.h"
+#include "main/bufferobj.h"
+#include "main/teximage.h"
+#include "main/texenv.h"
+#include "main/texobj.h"
+#include "main/texstate.h"
+#include "main/texparam.h"
+#include "main/varray.h"
+#include "main/attrib.h"
+#include "main/enable.h"
+#include "main/buffers.h"
+#include "main/fbobject.h"
+#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
+#include "main/depth.h"
+#include "main/hash.h"
+#include "main/mipmap.h"
+#include "main/blend.h"
+#include "glapi/dispatch.h"
+#include "swrast/swrast.h"
+
+#include "intel_screen.h"
+#include "intel_context.h"
+#include "intel_batchbuffer.h"
+#include "intel_pixel.h"
+#include "intel_tex.h"
+#include "intel_mipmap_tree.h"
+
+static const char *intel_fp_tex2d =
+      "!!ARBfp1.0\n"
+      "TEX result.color, fragment.texcoord[0], texture[0], 2D;\n"
+      "END\n";
+
+static GLboolean
+intel_generate_mipmap_level(GLcontext *ctx, GLuint tex_name,
+                           int level, int width, int height)
+{
+   struct intel_context *intel = intel_context(ctx);
+   GLfloat vertices[4][2];
+   GLint status;
+
+   /* Set to source from the previous level */
+   _mesa_TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, level - 1);
+   _mesa_TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, level - 1);
+
+   /* Set to draw into the current level */
+   _mesa_FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
+                                GL_COLOR_ATTACHMENT0_EXT,
+                                GL_TEXTURE_2D,
+                                tex_name,
+                                level);
+   /* Choose to render to the color attachment. */
+   _mesa_DrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
+
+   status = _mesa_CheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
+   if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
+      return GL_FALSE;
+
+   intel_meta_set_passthrough_transform(intel);
+
+   /* XXX: Doing it right would involve setting up the transformation to do
+    * 0-1 mapping or something, and not changing the vertex data.
+    */
+   vertices[0][0] = 0;
+   vertices[0][1] = 0;
+   vertices[1][0] = width;
+   vertices[1][1] = 0;
+   vertices[2][0] = width;
+   vertices[2][1] = height;
+   vertices[3][0] = 0;
+   vertices[3][1] = height;
+
+   _mesa_VertexPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &vertices);
+   _mesa_Enable(GL_VERTEX_ARRAY);
+   intel_meta_set_default_texrect(intel);
+
+   CALL_DrawArrays(ctx->Exec, (GL_TRIANGLE_FAN, 0, 4));
+
+   intel_meta_restore_texcoords(intel);
+   intel_meta_restore_transform(intel);
+
+   return GL_TRUE;
+}
+
+static GLboolean
+intel_generate_mipmap_2d(GLcontext *ctx,
+                        GLenum target,
+                        struct gl_texture_object *texObj)
+{
+   struct intel_context *intel = intel_context(ctx);
+   GLint old_active_texture;
+   int level, max_levels, start_level, end_level;
+   GLuint fb_name;
+   GLboolean success = GL_FALSE;
+   struct gl_framebuffer *saved_fbo = NULL;
+
+   _mesa_PushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT |
+                   GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT |
+                   GL_DEPTH_BUFFER_BIT);
+   _mesa_PushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
+   old_active_texture = ctx->Texture.CurrentUnit;
+   _mesa_reference_framebuffer(&saved_fbo, ctx->DrawBuffer);
+
+   _mesa_Disable(GL_POLYGON_STIPPLE);
+   _mesa_Disable(GL_DEPTH_TEST);
+   _mesa_Disable(GL_STENCIL_TEST);
+   _mesa_ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+   _mesa_DepthMask(GL_FALSE);
+
+   /* Bind the given texture to GL_TEXTURE_2D with linear filtering for our
+    * minification.
+    */
+   _mesa_ActiveTextureARB(GL_TEXTURE0_ARB);
+   _mesa_Enable(GL_TEXTURE_2D);
+   _mesa_BindTexture(GL_TEXTURE_2D, texObj->Name);
+   _mesa_TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+                      GL_LINEAR_MIPMAP_NEAREST);
+   _mesa_TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+   /* Bind the new renderbuffer to the color attachment point. */
+   _mesa_GenFramebuffersEXT(1, &fb_name);
+   _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb_name);
+
+   intel_meta_set_fragment_program(intel, &intel->meta.tex2d_fp,
+                                  intel_fp_tex2d);
+   intel_meta_set_passthrough_vertex_program(intel);
+
+   max_levels = _mesa_max_texture_levels(ctx, texObj->Target);
+   start_level = texObj->BaseLevel;
+   end_level = texObj->MaxLevel;
+
+   /* Loop generating level+1 from level. */
+   for (level = start_level; level < end_level && level < max_levels - 1; level++) {
+      const struct gl_texture_image *srcImage;
+      int width, height;
+
+      srcImage = _mesa_select_tex_image(ctx, texObj, target, level);
+      if (srcImage->Border != 0)
+        goto fail;
+
+      width = srcImage->Width / 2;
+      if (width < 1)
+        width = 1;
+      height = srcImage->Height / 2;
+      if (height < 1)
+        height = 1;
+
+      if (width == srcImage->Width &&
+         height == srcImage->Height) {
+        /* Neither _mesa_max_texture_levels nor texObj->MaxLevel are the
+         * maximum texture level for the object, so break out when we've gone
+         * over the edge.
+         */
+        break;
+      }
+
+      /* Make sure that there's space allocated for the target level.
+       * We could skip this if there's already space allocated and save some
+       * time.
+       */
+      _mesa_TexImage2D(GL_TEXTURE_2D, level + 1, srcImage->InternalFormat,
+                      width, height, 0,
+                      GL_RGBA, GL_UNSIGNED_INT, NULL);
+
+      if (!intel_generate_mipmap_level(ctx, texObj->Name, level + 1,
+                                      width, height))
+        goto fail;
+   }
+
+   success = GL_TRUE;
+
+fail:
+   intel_meta_restore_fragment_program(intel);
+   intel_meta_restore_vertex_program(intel);
+
+   _mesa_DeleteFramebuffersEXT(1, &fb_name);
+   _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + old_active_texture);
+   if (saved_fbo)
+      _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, saved_fbo->Name);
+   _mesa_reference_framebuffer(&saved_fbo, NULL);
+   _mesa_PopClientAttrib();
+   _mesa_PopAttrib();
+
+   return success;
+}
+
+
+/**
+ * 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;
+
+   /* HW path */
+   if (target == GL_TEXTURE_2D &&
+       ctx->Extensions.EXT_framebuffer_object &&
+       ctx->Extensions.ARB_fragment_program &&
+       ctx->Extensions.ARB_vertex_program) {
+      GLboolean success;
+
+      /* We'll be accessing this texture using GL entrypoints, which should
+       * be resilient against other access to this texture.
+       */
+      _mesa_unlock_texture(ctx, texObj);
+      success = intel_generate_mipmap_2d(ctx, target, texObj);
+      _mesa_lock_texture(ctx, texObj);
+
+      if (success)
+        return;
+   }
+
+   /* SW path */
+   intel_tex_map_level_images(intel, intelObj, texObj->BaseLevel);
+   _mesa_generate_mipmap(ctx, target, texObj);
+   intel_tex_unmap_level_images(intel, intelObj, texObj->BaseLevel);
+
+   /* 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);
+      }
+   }
+}
index 6e1e034e53d60936f237ea76495de4e4ae6da769..0d34f28311e10d3abd959aff2bca72b756f360d2 100644 (file)
@@ -57,14 +57,16 @@ intel_miptree_create_internal(struct intel_context *intel,
                              GLuint last_level,
                              GLuint width0,
                              GLuint height0,
-                             GLuint depth0, GLuint cpp, GLuint compress_byte)
+                             GLuint depth0, GLuint cpp, GLuint compress_byte,
+                             uint32_t tiling)
 {
    GLboolean ok;
    struct intel_mipmap_tree *mt = calloc(sizeof(*mt), 1);
 
-   DBG("%s target %s format %s level %d..%d\n", __FUNCTION__,
+   DBG("%s target %s format %s level %d..%d <-- %p\n", __FUNCTION__,
        _mesa_lookup_enum_by_nr(target),
-       _mesa_lookup_enum_by_nr(internal_format), first_level, last_level);
+       _mesa_lookup_enum_by_nr(internal_format), 
+       first_level, last_level, mt);
 
    mt->target = target_to_target(target);
    mt->internal_format = internal_format;
@@ -80,15 +82,16 @@ intel_miptree_create_internal(struct intel_context *intel,
 
 #ifdef I915
    if (IS_945(intel->intelScreen->deviceID))
-      ok = i945_miptree_layout(intel, mt);
+      ok = i945_miptree_layout(intel, mt, tiling);
    else
-      ok = i915_miptree_layout(intel, mt);
+      ok = i915_miptree_layout(intel, mt, tiling);
 #else
-   ok = brw_miptree_layout(intel, mt);
+   ok = brw_miptree_layout(intel, mt, tiling);
 #endif
 
    if (!ok) {
       free(mt);
+      DBG("%s not okay - returning NULL\n", __FUNCTION__);
       return NULL;
    }
 
@@ -107,10 +110,18 @@ intel_miptree_create(struct intel_context *intel,
                     GLboolean expect_accelerated_upload)
 {
    struct intel_mipmap_tree *mt;
+   uint32_t tiling;
+
+   if (intel->use_texture_tiling && compress_byte == 0 &&
+       intel->intelScreen->kernel_exec_fencing)
+      tiling = I915_TILING_X;
+   else
+      tiling = I915_TILING_NONE;
 
    mt = intel_miptree_create_internal(intel, target, internal_format,
                                      first_level, last_level, width0,
-                                     height0, depth0, cpp, compress_byte);
+                                     height0, depth0, cpp, compress_byte,
+                                     tiling);
    /*
     * pitch == 0 || height == 0  indicates the null texture
     */
@@ -118,6 +129,7 @@ intel_miptree_create(struct intel_context *intel,
       return NULL;
 
    mt->region = intel_region_alloc(intel,
+                                  tiling,
                                   mt->cpp,
                                   mt->pitch,
                                   mt->total_height,
@@ -147,7 +159,8 @@ intel_miptree_create_for_region(struct intel_context *intel,
    mt = intel_miptree_create_internal(intel, target, internal_format,
                                      first_level, last_level,
                                      region->width, region->height, 1,
-                                     region->cpp, compress_byte);
+                                     region->cpp, compress_byte,
+                                     I915_TILING_NONE);
    if (!mt)
       return mt;
 #if 0
@@ -185,6 +198,7 @@ intel_miptree_create_for_region(struct intel_context *intel,
 
 int intel_miptree_pitch_align (struct intel_context *intel,
                               struct intel_mipmap_tree *mt,
+                              uint32_t tiling,
                               int pitch)
 {
 #ifdef I915
@@ -205,6 +219,11 @@ int intel_miptree_pitch_align (struct intel_context *intel,
         pitch_align = 4;
       }
 
+      if (tiling == I915_TILING_X)
+        pitch_align = 512;
+      else if (tiling == I915_TILING_Y)
+        pitch_align = 128;
+
       pitch = ALIGN(pitch * mt->cpp, pitch_align);
 
 #ifdef I915
index 4060b9df78f8857e1329c959a6d8e36958e69495..3af9966827f40edda7d06417234091627842b59d 100644 (file)
@@ -148,6 +148,7 @@ intel_miptree_create_for_region(struct intel_context *intel,
 
 int intel_miptree_pitch_align (struct intel_context *intel,
                               struct intel_mipmap_tree *mt,
+                              uint32_t tiling,
                               int pitch);
 
 void intel_miptree_reference(struct intel_mipmap_tree **dst,
@@ -218,10 +219,13 @@ void intel_miptree_image_copy(struct intel_context *intel,
 /* i915_mipmap_tree.c:
  */
 GLboolean i915_miptree_layout(struct intel_context *intel,
-                             struct intel_mipmap_tree *mt);
+                             struct intel_mipmap_tree *mt,
+                             uint32_t tiling);
 GLboolean i945_miptree_layout(struct intel_context *intel,
-                             struct intel_mipmap_tree *mt);
+                             struct intel_mipmap_tree *mt,
+                             uint32_t tiling);
 GLboolean brw_miptree_layout(struct intel_context *intel,
-                            struct intel_mipmap_tree *mt);
+                            struct intel_mipmap_tree *mt,
+                            uint32_t tiling);
 
 #endif
index fc0ac0b79c0a873a8eb78fa0f54e73e90bdeded8..36a684b3b855c8feecadd15da8c64aef50f26137 100644 (file)
 
 #include "main/enums.h"
 #include "main/state.h"
+#include "main/bufferobj.h"
 #include "main/context.h"
 #include "main/enable.h"
 #include "main/matrix.h"
+#include "main/texstate.h"
+#include "main/varray.h"
 #include "main/viewport.h"
 #include "swrast/swrast.h"
 #include "shader/arbprogram.h"
@@ -334,6 +337,85 @@ intel_meta_restore_fragment_program(struct intel_context *intel)
       _mesa_Disable(GL_FRAGMENT_PROGRAM_ARB);
 }
 
+static const float default_texcoords[4][2] = { { 0.0, 0.0 },
+                                              { 1.0, 0.0 },
+                                              { 1.0, 1.0 },
+                                              { 0.0, 1.0 } };
+
+void
+intel_meta_set_default_texrect(struct intel_context *intel)
+{
+   GLcontext *ctx = &intel->ctx;
+   struct gl_client_array *old_texcoord_array;
+
+   intel->meta.saved_active_texture = ctx->Texture.CurrentUnit;
+   if (intel->meta.saved_array_vbo == NULL) {
+      _mesa_reference_buffer_object(ctx, &intel->meta.saved_array_vbo,
+                                   ctx->Array.ArrayBufferObj);
+   }
+
+   old_texcoord_array = &ctx->Array.ArrayObj->TexCoord[0];
+   intel->meta.saved_texcoord_type = old_texcoord_array->Type;
+   intel->meta.saved_texcoord_size = old_texcoord_array->Size;
+   intel->meta.saved_texcoord_stride = old_texcoord_array->Stride;
+   intel->meta.saved_texcoord_enable = old_texcoord_array->Enabled;
+   intel->meta.saved_texcoord_ptr = old_texcoord_array->Ptr;
+   _mesa_reference_buffer_object(ctx, &intel->meta.saved_texcoord_vbo,
+                                old_texcoord_array->BufferObj);
+
+   _mesa_ClientActiveTextureARB(GL_TEXTURE0);
+
+   if (intel->meta.texcoord_vbo == NULL) {
+      GLuint vbo_name;
+
+      _mesa_GenBuffersARB(1, &vbo_name);
+      _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, vbo_name);
+      _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(default_texcoords),
+                         default_texcoords, GL_STATIC_DRAW_ARB);
+      _mesa_reference_buffer_object(ctx, &intel->meta.texcoord_vbo,
+                                   ctx->Array.ArrayBufferObj);
+   } else {
+      _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB,
+                         intel->meta.texcoord_vbo->Name);
+   }
+   _mesa_TexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), NULL);
+
+   _mesa_Enable(GL_TEXTURE_COORD_ARRAY);
+}
+
+void
+intel_meta_restore_texcoords(struct intel_context *intel)
+{
+   GLcontext *ctx = &intel->ctx;
+
+   /* Restore the old TexCoordPointer */
+   if (intel->meta.saved_texcoord_vbo) {
+      _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB,
+                         intel->meta.saved_texcoord_vbo->Name);
+      _mesa_reference_buffer_object(ctx, &intel->meta.saved_texcoord_vbo, NULL);
+   } else {
+      _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
+   }
+
+   _mesa_TexCoordPointer(intel->meta.saved_texcoord_size,
+                        intel->meta.saved_texcoord_type,
+                        intel->meta.saved_texcoord_stride,
+                        intel->meta.saved_texcoord_ptr);
+   if (!intel->meta.saved_texcoord_enable)
+      _mesa_Disable(GL_TEXTURE_COORD_ARRAY);
+
+   _mesa_ClientActiveTextureARB(GL_TEXTURE0 +
+                               intel->meta.saved_active_texture);
+
+   if (intel->meta.saved_array_vbo) {
+      _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB,
+                         intel->meta.saved_array_vbo->Name);
+      _mesa_reference_buffer_object(ctx, &intel->meta.saved_array_vbo, NULL);
+   } else {
+      _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
+   }
+}
+
 void
 intelInitPixelFuncs(struct dd_function_table *functions)
 {
@@ -355,5 +437,7 @@ intel_free_pixel_state(struct intel_context *intel)
 
    _mesa_reference_vertprog(ctx, &intel->meta.passthrough_vp, NULL);
    _mesa_reference_fragprog(ctx, &intel->meta.bitmap_fp, NULL);
+   _mesa_reference_fragprog(ctx, &intel->meta.tex2d_fp, NULL);
+   _mesa_reference_buffer_object(ctx, &intel->meta.texcoord_vbo, NULL);
 }
 
index cb41fa182cb5993cf2876aa60682826174690e4c..6acf0813c8ce8efe969567375468b4ee77991f7f 100644 (file)
@@ -40,6 +40,9 @@ void intel_meta_set_fragment_program(struct intel_context *intel,
                                     const char *prog_string);
 void intel_meta_restore_fragment_program(struct intel_context *intel);
 void intel_free_pixel_state(struct intel_context *intel);
+void intel_meta_set_default_texrect(struct intel_context *intel);
+void intel_meta_set_default_texrect(struct intel_context *intel);
+void intel_meta_restore_texcoords(struct intel_context *intel);
 
 GLboolean intel_check_blit_fragment_ops(GLcontext * ctx,
                                        GLboolean src_alpha_is_one);
index 1db7f5594e9dd3849c242621071cce19692d748b..80d3239189c6fbe31032f112360d775cee1bc410 100644 (file)
@@ -360,7 +360,6 @@ intel_texture_bitmap(GLcontext * ctx,
       "END\n";
    GLuint texname;
    GLfloat vertices[4][4];
-   GLfloat texcoords[4][2];
    GLint old_active_texture;
    GLubyte *unpacked_bitmap;
    GLubyte *a8_bitmap;
@@ -401,6 +400,14 @@ intel_texture_bitmap(GLcontext * ctx,
       return GL_FALSE;
    }
 
+   if (!ctx->Extensions.ARB_texture_non_power_of_two &&
+       (!is_power_of_two(width) || !is_power_of_two(height))) {
+      if (INTEL_DEBUG & DEBUG_FALLBACKS)
+        fprintf(stderr,
+                "glBitmap() fallback: NPOT texture\n");
+      return GL_FALSE;
+   }
+
    /* Check that we can load in a texture this big. */
    if (width > (1 << (ctx->Const.MaxTextureLevels - 1)) ||
        height > (1 << (ctx->Const.MaxTextureLevels - 1))) {
@@ -485,22 +492,12 @@ intel_texture_bitmap(GLcontext * ctx,
    vertices[3][2] = dst_z;
    vertices[3][3] = 1.0;
 
-   texcoords[0][0] = 0.0;
-   texcoords[0][1] = 0.0;
-   texcoords[1][0] = 1.0;
-   texcoords[1][1] = 0.0;
-   texcoords[2][0] = 1.0;
-   texcoords[2][1] = 1.0;
-   texcoords[3][0] = 0.0;
-   texcoords[3][1] = 1.0;
-
    _mesa_VertexPointer(4, GL_FLOAT, 4 * sizeof(GLfloat), &vertices);
-   _mesa_ClientActiveTextureARB(GL_TEXTURE0);
-   _mesa_TexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &texcoords);
    _mesa_Enable(GL_VERTEX_ARRAY);
-   _mesa_Enable(GL_TEXTURE_COORD_ARRAY);
+   intel_meta_set_default_texrect(intel);
    CALL_DrawArrays(ctx->Exec, (GL_TRIANGLE_FAN, 0, 4));
 
+   intel_meta_restore_texcoords(intel);
    intel_meta_restore_transform(intel);
    intel_meta_restore_fragment_program(intel);
    intel_meta_restore_vertex_program(intel);
index e8d5ac8569d58f9b25afbb1f237320e0174ace8a..46d27f1a93a6832081424dc92154810fce60e526 100644 (file)
@@ -70,7 +70,6 @@ intel_texture_drawpixels(GLcontext * ctx,
    struct intel_context *intel = intel_context(ctx);
    GLuint texname;
    GLfloat vertices[4][4];
-   GLfloat texcoords[4][2];
    GLfloat z;
    GLint old_active_texture;
    GLenum internalFormat;
@@ -97,7 +96,7 @@ intel_texture_drawpixels(GLcontext * ctx,
    /* We don't have a way to generate fragments with stencil values which
     * will set the resulting stencil value.
     */
-   if (format == GL_STENCIL_INDEX)
+   if (format == GL_STENCIL_INDEX || format == GL_DEPTH_STENCIL)
       return GL_FALSE;
 
    /* Check that we can load in a texture this big. */
@@ -120,6 +119,14 @@ intel_texture_drawpixels(GLcontext * ctx,
       return GL_FALSE;
    }
 
+   if (!ctx->Extensions.ARB_texture_non_power_of_two &&
+       (!is_power_of_two(width) || !is_power_of_two(height))) {
+      if (INTEL_DEBUG & DEBUG_FALLBACKS)
+        fprintf(stderr,
+                "glDrawPixels() fallback: NPOT texture\n");
+      return GL_FALSE;
+   }
+
    _mesa_PushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT |
                    GL_CURRENT_BIT);
    _mesa_PushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
@@ -169,22 +176,13 @@ intel_texture_drawpixels(GLcontext * ctx,
    vertices[3][2] = z;
    vertices[3][3] = 1.0;
 
-   texcoords[0][0] = 0.0;
-   texcoords[0][1] = 0.0;
-   texcoords[1][0] = 1.0;
-   texcoords[1][1] = 0.0;
-   texcoords[2][0] = 1.0;
-   texcoords[2][1] = 1.0;
-   texcoords[3][0] = 0.0;
-   texcoords[3][1] = 1.0;
-
    _mesa_VertexPointer(4, GL_FLOAT, 4 * sizeof(GLfloat), &vertices);
-   _mesa_ClientActiveTextureARB(GL_TEXTURE0);
-   _mesa_TexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &texcoords);
    _mesa_Enable(GL_VERTEX_ARRAY);
-   _mesa_Enable(GL_TEXTURE_COORD_ARRAY);
+   intel_meta_set_default_texrect(intel);
+
    CALL_DrawArrays(ctx->Exec, (GL_TRIANGLE_FAN, 0, 4));
 
+   intel_meta_restore_texcoords(intel);
    intel_meta_restore_transform(intel);
 
    _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + old_active_texture);
@@ -208,7 +206,6 @@ intel_stencil_drawpixels(GLcontext * ctx,
    struct intel_context *intel = intel_context(ctx);
    GLuint texname, rb_name, fb_name, old_fb_name;
    GLfloat vertices[4][2];
-   GLfloat texcoords[4][2];
    struct intel_renderbuffer *irb;
    struct intel_renderbuffer *depth_irb;
    struct gl_renderbuffer *rb;
@@ -273,6 +270,14 @@ intel_stencil_drawpixels(GLcontext * ctx,
       return GL_FALSE;
    }
 
+   if (!ctx->Extensions.ARB_texture_non_power_of_two &&
+       (!is_power_of_two(width) || !is_power_of_two(height))) {
+      if (INTEL_DEBUG & DEBUG_FALLBACKS)
+        fprintf(stderr,
+                "glDrawPixels(GL_STENCIL_INDEX) fallback: NPOT texture\n");
+      return GL_FALSE;
+   }
+
    _mesa_PushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT |
                    GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    _mesa_PushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
@@ -343,7 +348,6 @@ intel_stencil_drawpixels(GLcontext * ctx,
    _mesa_free(stencil_pixels);
 
    intel_meta_set_passthrough_transform(intel);
-
    vertices[0][0] = x;
    vertices[0][1] = y;
    vertices[1][0] = x + width * ctx->Pixel.ZoomX;
@@ -353,22 +357,13 @@ intel_stencil_drawpixels(GLcontext * ctx,
    vertices[3][0] = x;
    vertices[3][1] = y + height * ctx->Pixel.ZoomY;
 
-   texcoords[0][0] = 0.0;
-   texcoords[0][1] = 0.0;
-   texcoords[1][0] = 1.0;
-   texcoords[1][1] = 0.0;
-   texcoords[2][0] = 1.0;
-   texcoords[2][1] = 1.0;
-   texcoords[3][0] = 0.0;
-   texcoords[3][1] = 1.0;
-
    _mesa_VertexPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &vertices);
-   _mesa_ClientActiveTextureARB(GL_TEXTURE0);
-   _mesa_TexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &texcoords);
    _mesa_Enable(GL_VERTEX_ARRAY);
-   _mesa_Enable(GL_TEXTURE_COORD_ARRAY);
+   intel_meta_set_default_texrect(intel);
+
    CALL_DrawArrays(ctx->Exec, (GL_TRIANGLE_FAN, 0, 4));
 
+   intel_meta_restore_texcoords(intel);
    intel_meta_restore_transform(intel);
 
    _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + old_active_texture);
index 57ac8f0cc14cb70782717c29c0f6cd33d621a61a..d19f1bae34ce36e67aeac359c79fdc606d04bc58 100644 (file)
 
 #define S7_DEPTH_OFFSET_CONST_MASK     ~0
 
+/* p143 */
+#define _3DSTATE_BUF_INFO_CMD  (CMD_3D | (0x1d<<24) | (0x8e<<16) | 1)
+/* Dword 1 */
+#define BUF_3D_ID_COLOR_BACK   (0x3<<24)
+#define BUF_3D_ID_DEPTH        (0x7<<24)
+#define BUF_3D_USE_FENCE       (1<<23)
+#define BUF_3D_TILED_SURFACE   (1<<22)
+#define BUF_3D_TILE_WALK_X     0
+#define BUF_3D_TILE_WALK_Y     (1<<21)
+#define BUF_3D_PITCH(x)         (((x)/4)<<2)
+/* Dword 2 */
+#define BUF_3D_ADDR(x)         ((x) & ~0x3)
+
 /* Primitive dispatch on 830-945 */
 #define _3DPRIMITIVE                   (CMD_3D | (0x1f << 24))
 #define PRIM_INDIRECT            (1<<23)
index 0aa5b8c02c904a2b31c7ea51b49357db9a6dabd4..49bcb3c1ddd04f91f48471dbaf28512f020d1ecc 100644 (file)
 
 #define FILE_DEBUG_FLAG DEBUG_REGION
 
+/* This should be set to the maximum backtrace size desired.
+ * Set it to 0 to disable backtrace debugging.
+ */
+#define DEBUG_BACKTRACE_SIZE 0
+
+#if DEBUG_BACKTRACE_SIZE == 0
+/* Use the standard debug output */
+#define _DBG(...) DBG(__VA_ARGS__)
+#else
+/* Use backtracing debug output */
+#define _DBG(...) {debug_backtrace(); DBG(__VA_ARGS__);}
+
+/* Backtracing debug support */
+#include <execinfo.h>
+
+static void
+debug_backtrace(void)
+{
+   void *trace[DEBUG_BACKTRACE_SIZE];
+   char **strings = NULL;
+   int traceSize;
+   register int i;
+
+   traceSize = backtrace(trace, DEBUG_BACKTRACE_SIZE);
+   strings = backtrace_symbols(trace, traceSize);
+   if (strings == NULL) {
+      DBG("no backtrace:");
+      return;
+   }
+
+   /* Spit out all the strings with a colon separator.  Ignore
+    * the first, since we don't really care about the call
+    * to debug_backtrace() itself.  Skip until the final "/" in
+    * the trace to avoid really long lines.
+    */
+   for (i = 1; i < traceSize; i++) {
+      char *p = strings[i], *slash = strings[i];
+      while (*p) {
+         if (*p++ == '/') {
+            slash = p;
+         }
+      }
+
+      DBG("%s:", slash);
+   }
+
+   /* Free up the memory, and we're done */
+   free(strings);
+}
+
+#endif
+
+
+
 /* XXX: Thread safety?
  */
 GLubyte *
 intel_region_map(struct intel_context *intel, struct intel_region *region)
 {
-   DBG("%s\n", __FUNCTION__);
+   _DBG("%s %p\n", __FUNCTION__, region);
    if (!region->map_refcount++) {
       if (region->pbo)
          intel_region_cow(intel, region);
 
-      dri_bo_map(region->buffer, GL_TRUE);
+      if (intel->intelScreen->kernel_exec_fencing)
+        drm_intel_gem_bo_map_gtt(region->buffer);
+      else
+        dri_bo_map(region->buffer, GL_TRUE);
       region->map = region->buffer->virtual;
    }
 
@@ -72,9 +129,12 @@ intel_region_map(struct intel_context *intel, struct intel_region *region)
 void
 intel_region_unmap(struct intel_context *intel, struct intel_region *region)
 {
-   DBG("%s\n", __FUNCTION__);
+   _DBG("%s %p\n", __FUNCTION__, region);
    if (!--region->map_refcount) {
-      dri_bo_unmap(region->buffer);
+      if (intel->intelScreen->kernel_exec_fencing)
+        drm_intel_gem_bo_unmap_gtt(region->buffer);
+      else
+        dri_bo_unmap(region->buffer);
       region->map = NULL;
    }
 }
@@ -87,10 +147,10 @@ intel_region_alloc_internal(struct intel_context *intel,
 {
    struct intel_region *region;
 
-   DBG("%s\n", __FUNCTION__);
-
-   if (buffer == NULL)
+   if (buffer == NULL) {
+      _DBG("%s <-- NULL\n", __FUNCTION__);
       return NULL;
+   }
 
    region = calloc(sizeof(*region), 1);
    region->cpp = cpp;
@@ -104,15 +164,18 @@ intel_region_alloc_internal(struct intel_context *intel,
    region->tiling = I915_TILING_NONE;
    region->bit_6_swizzle = I915_BIT_6_SWIZZLE_NONE;
 
+   _DBG("%s <-- %p\n", __FUNCTION__, region);
    return region;
 }
 
 struct intel_region *
 intel_region_alloc(struct intel_context *intel,
+                  uint32_t tiling,
                    GLuint cpp, GLuint width, GLuint height, GLuint pitch,
                   GLboolean expect_accelerated_upload)
 {
    dri_bo *buffer;
+   struct intel_region *region;
 
    if (expect_accelerated_upload) {
       buffer = drm_intel_bo_alloc_for_render(intel->bufmgr, "region",
@@ -122,7 +185,16 @@ intel_region_alloc(struct intel_context *intel,
                                  pitch * cpp * height, 64);
    }
 
-   return intel_region_alloc_internal(intel, cpp, width, height, pitch, buffer);
+   region = intel_region_alloc_internal(intel, cpp, width, height,
+                                       pitch, buffer);
+
+   if (tiling != I915_TILING_NONE) {
+      assert(((pitch * cpp) & 511) == 0);
+      drm_intel_bo_set_tiling(buffer, &tiling, pitch * cpp);
+      drm_intel_bo_get_tiling(buffer, &region->tiling, &region->bit_6_swizzle);
+   }
+
+   return region;
 }
 
 struct intel_region *
@@ -158,7 +230,7 @@ void
 intel_region_reference(struct intel_region **dst, struct intel_region *src)
 {
    if (src)
-      DBG("%s %p %d\n", __FUNCTION__, src, src->refcount);
+      _DBG("%s %p %d\n", __FUNCTION__, src, src->refcount);
 
    assert(*dst == NULL);
    if (src) {
@@ -172,10 +244,12 @@ intel_region_release(struct intel_region **region_handle)
 {
    struct intel_region *region = *region_handle;
 
-   if (region == NULL)
+   if (region == NULL) {
+      _DBG("%s NULL\n", __FUNCTION__);
       return;
+   }
 
-   DBG("%s %p %d\n", __FUNCTION__, region, region->refcount - 1);
+   _DBG("%s %p %d\n", __FUNCTION__, region, region->refcount - 1);
 
    ASSERT(region->refcount > 0);
    region->refcount--;
@@ -251,7 +325,7 @@ intel_region_data(struct intel_context *intel,
 {
    GLboolean locked = GL_FALSE;
 
-   DBG("%s\n", __FUNCTION__);
+   _DBG("%s\n", __FUNCTION__);
 
    if (intel == NULL)
       return;
@@ -293,7 +367,7 @@ intel_region_copy(struct intel_context *intel,
                   GLuint src_offset,
                   GLuint srcx, GLuint srcy, GLuint width, GLuint height)
 {
-   DBG("%s\n", __FUNCTION__);
+   _DBG("%s\n", __FUNCTION__);
 
    if (intel == NULL)
       return;
@@ -326,7 +400,7 @@ intel_region_fill(struct intel_context *intel,
                   GLuint dstx, GLuint dsty,
                   GLuint width, GLuint height, GLuint color)
 {
-   DBG("%s\n", __FUNCTION__);
+   _DBG("%s\n", __FUNCTION__);
 
    if (intel == NULL)
       return;   
@@ -356,6 +430,8 @@ intel_region_attach_pbo(struct intel_context *intel,
    if (region->pbo == pbo)
       return;
 
+   _DBG("%s %p %p\n", __FUNCTION__, region, pbo);
+
    /* 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
@@ -385,6 +461,7 @@ void
 intel_region_release_pbo(struct intel_context *intel,
                          struct intel_region *region)
 {
+   _DBG("%s %p\n", __FUNCTION__, region);
    assert(region->buffer == region->pbo->buffer);
    region->pbo->region = NULL;
    region->pbo = NULL;
@@ -412,7 +489,7 @@ intel_region_cow(struct intel_context *intel, struct intel_region *region)
 
    assert(region->cpp * region->pitch * region->height == pbo->Base.Size);
 
-   DBG("%s (%d bytes)\n", __FUNCTION__, pbo->Base.Size);
+   _DBG("%s %p (%d bytes)\n", __FUNCTION__, region, pbo->Base.Size);
 
    /* Now blit from the texture buffer to the new buffer: 
     */
@@ -459,6 +536,10 @@ intel_recreate_static(struct intel_context *intel,
    if (region == NULL) {
       region = calloc(sizeof(*region), 1);
       region->refcount = 1;
+      _DBG("%s creating new region %p\n", __FUNCTION__, region);
+   }
+   else {
+      _DBG("%s %p\n", __FUNCTION__, region);
    }
 
    if (intel->ctx.Visual.rgbBits == 24)
index 45e2bf4e77ab3626b7c1493380b1561f428823a6..bd3c8e7325bb9e4628a90a0fec5920021a4ed350 100644 (file)
@@ -73,7 +73,8 @@ struct intel_region
  * copied by calling intel_reference_region().
  */
 struct intel_region *intel_region_alloc(struct intel_context *intel,
-                                        GLuint cpp, GLuint width,
+                                        uint32_t tiling,
+                                       GLuint cpp, GLuint width,
                                         GLuint height, GLuint pitch,
                                        GLboolean expect_accelerated_upload);
 
index 50cb13a48223f3ad034733dbd79c924b9bee461d..70e0980ed6bc3fed2578df2170b81b10be112754 100644 (file)
 #include "i915_drm.h"
 #include "i830_dri.h"
 
+#define DRI_CONF_TEXTURE_TILING(def) \
+       DRI_CONF_OPT_BEGIN(texture_tiling, bool, def)           \
+               DRI_CONF_DESC(en, "Enable texture tiling")      \
+       DRI_CONF_OPT_END                                        \
 
 PUBLIC const char __driConfigOptions[] =
    DRI_CONF_BEGIN
@@ -64,6 +68,17 @@ PUBLIC const char __driConfigOptions[] =
            DRI_CONF_ENUM(1, "Enable reuse of all sizes of buffer objects")
         DRI_CONF_DESC_END
       DRI_CONF_OPT_END
+
+#ifdef I915
+     DRI_CONF_TEXTURE_TILING(false)
+#else
+     DRI_CONF_TEXTURE_TILING(true)
+#endif
+
+      DRI_CONF_OPT_BEGIN(early_z, bool, false)
+        DRI_CONF_DESC(en, "Enable early Z in classic mode (unstable, 945-only).")
+      DRI_CONF_OPT_END
+
    DRI_CONF_SECTION_END
    DRI_CONF_SECTION_QUALITY
       DRI_CONF_FORCE_S3TC_ENABLE(false)
@@ -76,7 +91,7 @@ PUBLIC const char __driConfigOptions[] =
    DRI_CONF_SECTION_END
 DRI_CONF_END;
 
-const GLuint __driNConfigOptions = 8;
+const GLuint __driNConfigOptions = 10;
 
 #ifdef USE_NEW_INTERFACE
 static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
@@ -236,7 +251,7 @@ intel_get_param(__DRIscreenPrivate *psp, int param, int *value)
 
    ret = drmCommandWriteRead(psp->fd, DRM_I915_GETPARAM, &gp, sizeof(gp));
    if (ret) {
-      fprintf(stderr, "drm_i915_getparam: %d\n", ret);
+      _mesa_warning(NULL, "drm_i915_getparam: %d", ret);
       return GL_FALSE;
    }
 
index ae0994b183a75c4620dc89d0cc6d79cd52ffa640..df63f29a42c95a08ad1600e6ae926010bf1b2ee2 100644 (file)
@@ -158,81 +158,11 @@ timed_memcpy(void *dest, const void *src, size_t n)
 }
 #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;
-   functions->CopyTexImage1D = intelCopyTexImage1D;
-   functions->CopyTexImage2D = intelCopyTexImage2D;
-   functions->CopyTexSubImage1D = intelCopyTexSubImage1D;
-   functions->CopyTexSubImage2D = intelCopyTexSubImage2D;
-   functions->GetTexImage = intelGetTexImage;
-   functions->GenerateMipmap = intelGenerateMipmap;
-
-   /* compressed texture functions */
-   functions->CompressedTexImage2D = intelCompressedTexImage2D;
-   functions->CompressedTexSubImage2D = intelCompressedTexSubImage2D;
-   functions->GetCompressedTexImage = intelGetCompressedTexImage;
+   functions->GenerateMipmap = intel_generate_mipmap;
 
    functions->NewTextureObject = intelNewTextureObject;
    functions->NewTextureImage = intelNewTextureImage;
index f5372d82fb2ce0004e21aa78376d7e249691e172..471aa2a240b4b5a4f844531a532f3fba815b12a2 100644 (file)
 
 void intelInitTextureFuncs(struct dd_function_table *functions);
 
+void intelInitTextureImageFuncs(struct dd_function_table *functions);
+
+void intelInitTextureSubImageFuncs(struct dd_function_table *functions);
+
+void intelInitTextureCopyImageFuncs(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 intelCompressedTexSubImage2D(GLcontext * ctx,
-                                 GLenum target,
-                                 GLint level,
-                                 GLint xoffset, GLint yoffset,
-                                 GLsizei width, GLsizei height,
-                                 GLenum format, GLsizei imageSize,
-                                 const GLvoid * pixels,
-                                 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,
index 90bbb8c6bbf7998055e65f44f55ff6c40ae338a1..260235b1eb10ba01178c5ab46bf4c94449915408 100644 (file)
@@ -118,8 +118,12 @@ do_copy_texsubimage(struct intel_context *intel,
       dstx += x - orig_x;
       dsty += y - orig_y;
 
-      /* image_offset may be non-page-aligned, but that's illegal for tiling. */
-      assert(intelImage->mt->region->tiling == I915_TILING_NONE);
+      /* Can't blit to tiled buffers with non-tile-aligned offset. */
+      if (intelImage->mt->region->tiling != I915_TILING_NONE &&
+         (image_offset & 4095) != 0) {
+        UNLOCK_HARDWARE(intel);
+        return GL_FALSE;
+      }
 
       if (ctx->ReadBuffer->Name == 0) {
         /* reading from a window, adjust x, y */
@@ -158,17 +162,14 @@ do_copy_texsubimage(struct intel_context *intel,
 
    /* GL_SGIS_generate_mipmap */
    if (intelImage->level == texObj->BaseLevel && texObj->GenerateMipmap) {
-      ctx->Driver.GenerateMipmap(ctx, target, texObj);
+      intel_generate_mipmap(ctx, target, texObj);
    }
 
    return GL_TRUE;
 }
 
 
-
-
-
-void
+static void
 intelCopyTexImage1D(GLcontext * ctx, GLenum target, GLint level,
                     GLenum internalFormat,
                     GLint x, GLint y, GLsizei width, GLint border)
@@ -214,7 +215,8 @@ intelCopyTexImage1D(GLcontext * ctx, GLenum target, GLint level,
                            width, border);
 }
 
-void
+
+static void
 intelCopyTexImage2D(GLcontext * ctx, GLenum target, GLint level,
                     GLenum internalFormat,
                     GLint x, GLint y, GLsizei width, GLsizei height,
@@ -262,7 +264,7 @@ intelCopyTexImage2D(GLcontext * ctx, GLenum target, GLint level,
 }
 
 
-void
+static void
 intelCopyTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
                        GLint xoffset, GLint x, GLint y, GLsizei width)
 {
@@ -287,8 +289,7 @@ intelCopyTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
 }
 
 
-
-void
+static void
 intelCopyTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
                        GLint xoffset, GLint yoffset,
                        GLint x, GLint y, GLsizei width, GLsizei height)
@@ -301,7 +302,6 @@ intelCopyTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
       _mesa_select_tex_image(ctx, texObj, target, level);
    GLenum internalFormat = texImage->InternalFormat;
 
-
    /* Need to check texture is compatible with source format. 
     */
 
@@ -316,3 +316,13 @@ intelCopyTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
                                  xoffset, yoffset, x, y, width, height);
    }
 }
+
+
+void
+intelInitTextureCopyImageFuncs(struct dd_function_table *functions)
+{
+   functions->CopyTexImage1D = intelCopyTexImage1D;
+   functions->CopyTexImage2D = intelCopyTexImage2D;
+   functions->CopyTexSubImage1D = intelCopyTexSubImage1D;
+   functions->CopyTexSubImage2D = intelCopyTexSubImage2D;
+}
index 1f192dafbe1c23afaefdd416beaee298037edc9d..e9a3823078a600caa521d291676e97176ac5c7fb 100644 (file)
@@ -208,7 +208,7 @@ try_pbo_upload(struct intel_context *intel,
    if (!pbo ||
        intel->ctx._ImageTransferState ||
        unpack->SkipPixels || unpack->SkipRows) {
-      _mesa_printf("%s: failure 1\n", __FUNCTION__);
+      DBG("%s: failure 1\n", __FUNCTION__);
       return GL_FALSE;
    }
 
@@ -248,7 +248,6 @@ try_pbo_upload(struct intel_context *intel,
 }
 
 
-
 static GLboolean
 try_pbo_zcopy(struct intel_context *intel,
               struct intel_texture_image *intelImage,
@@ -264,7 +263,7 @@ try_pbo_zcopy(struct intel_context *intel,
    if (!pbo ||
        intel->ctx._ImageTransferState ||
        unpack->SkipPixels || unpack->SkipRows) {
-      _mesa_printf("%s: failure 1\n", __FUNCTION__);
+      DBG("%s: failure 1\n", __FUNCTION__);
       return GL_FALSE;
    }
 
@@ -283,7 +282,7 @@ try_pbo_zcopy(struct intel_context *intel,
    dst_stride = intelImage->mt->pitch;
 
    if (src_stride != dst_stride || dst_offset != 0 || src_offset != 0) {
-      _mesa_printf("%s: failure 2\n", __FUNCTION__);
+      DBG("%s: failure 2\n", __FUNCTION__);
       return GL_FALSE;
    }
 
@@ -293,10 +292,6 @@ try_pbo_zcopy(struct intel_context *intel,
 }
 
 
-
-
-
-
 static void
 intelTexImage(GLcontext * ctx,
               GLint dims,
@@ -307,7 +302,8 @@ intelTexImage(GLcontext * ctx,
               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 gl_texture_image *texImage, GLsizei imageSize,
+              GLboolean compressed)
 {
    struct intel_context *intel = intel_context(ctx);
    struct intel_texture_object *intelObj = intel_texture_object(texObj);
@@ -316,7 +312,6 @@ intelTexImage(GLcontext * ctx,
    GLint postConvHeight = height;
    GLint texelBytes, sizeInBytes;
    GLuint dstRowStride = 0, srcRowStride = texImage->RowStride;
-   GLboolean needs_map;
 
    DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__,
        _mesa_lookup_enum_by_nr(target), level, width, height, depth, border);
@@ -464,8 +459,6 @@ intelTexImage(GLcontext * ctx,
       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:
@@ -482,15 +475,8 @@ intelTexImage(GLcontext * ctx,
 
    LOCK_HARDWARE(intel);
 
-   /* Two cases where we need a mapping of the miptree: when the user supplied
-    * data is mapped as well (non-PBO, memcpy upload) or when we're going to do
-    * (software) mipmap generation.
-    */
-   needs_map = (pixels != NULL) || (level == texObj->BaseLevel &&
-                                 texObj->GenerateMipmap);
-
    if (intelImage->mt) {
-      if (needs_map)
+      if (pixels != NULL)
          texImage->Data = intel_miptree_image_map(intel,
                                                   intelImage->mt,
                                                   intelImage->face,
@@ -547,25 +533,26 @@ intelTexImage(GLcontext * ctx,
                                                   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) {
-      if (needs_map)
+      if (pixels != NULL)
          intel_miptree_image_unmap(intel, intelImage->mt);
       texImage->Data = NULL;
    }
 
    UNLOCK_HARDWARE(intel);
+
+   /* GL_SGIS_generate_mipmap */
+   if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+      intel_generate_mipmap(ctx, target, texObj);
+   }
 }
 
-void
+
+static void
 intelTexImage3D(GLcontext * ctx,
                 GLenum target, GLint level,
                 GLint internalFormat,
@@ -578,11 +565,11 @@ intelTexImage3D(GLcontext * ctx,
 {
    intelTexImage(ctx, 3, target, level,
                  internalFormat, width, height, depth, border,
-                 format, type, pixels, unpack, texObj, texImage, 0, 0);
+                 format, type, pixels, unpack, texObj, texImage, 0, GL_FALSE);
 }
 
 
-void
+static void
 intelTexImage2D(GLcontext * ctx,
                 GLenum target, GLint level,
                 GLint internalFormat,
@@ -594,10 +581,11 @@ intelTexImage2D(GLcontext * ctx,
 {
    intelTexImage(ctx, 2, target, level,
                  internalFormat, width, height, 1, border,
-                 format, type, pixels, unpack, texObj, texImage, 0, 0);
+                 format, type, pixels, unpack, texObj, texImage, 0, GL_FALSE);
 }
 
-void
+
+static void
 intelTexImage1D(GLcontext * ctx,
                 GLenum target, GLint level,
                 GLint internalFormat,
@@ -609,21 +597,24 @@ intelTexImage1D(GLcontext * ctx,
 {
    intelTexImage(ctx, 1, target, level,
                  internalFormat, width, 1, 1, border,
-                 format, type, pixels, unpack, texObj, texImage, 0, 0);
+                 format, type, pixels, unpack, texObj, texImage, 0, GL_FALSE);
 }
 
-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 )
+
+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 )
 {
    intelTexImage(ctx, 2, target, level,
                 internalFormat, width, height, 1, border,
-                0, 0, data, &ctx->Unpack, texObj, texImage, imageSize, 1);
+                0, 0, data, &ctx->Unpack, texObj, texImage, imageSize, GL_TRUE);
 }
 
+
 /**
  * Need to map texture image into memory before copying image data,
  * then unmap it.
@@ -632,11 +623,17 @@ 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 gl_texture_image *texImage, GLboolean compressed)
 {
    struct intel_context *intel = intel_context(ctx);
    struct intel_texture_image *intelImage = intel_texture_image(texImage);
 
+   /* If we're reading from a texture that has been rendered to, need to
+    * make sure rendering is complete.
+    * We could probably predicate this on texObj->_RenderToTexture
+    */
+   intelFlush(ctx);
+
    /* Map */
    if (intelImage->mt) {
       /* Image is stored in hardware format in a buffer managed by the
@@ -680,28 +677,29 @@ intel_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
    }
 }
 
-void
+
+static 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);
-
-
+                      texObj, texImage, GL_FALSE);
 }
 
-void
+
+static 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);
+                      texObj, texImage, GL_TRUE);
 }
 
+
 void
 intelSetTexOffset(__DRIcontext *pDRICtx, GLint texname,
                  unsigned long long offset, GLint depth, GLuint pitch)
@@ -810,3 +808,16 @@ intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
     */
    intelSetTexBuffer2(pDRICtx, target, GLX_TEXTURE_FORMAT_RGBA_EXT, dPriv);
 }
+
+
+void
+intelInitTextureImageFuncs(struct dd_function_table *functions)
+{
+   functions->TexImage1D = intelTexImage1D;
+   functions->TexImage2D = intelTexImage2D;
+   functions->TexImage3D = intelTexImage3D;
+   functions->GetTexImage = intelGetTexImage;
+
+   functions->CompressedTexImage2D = intelCompressedTexImage2D;
+   functions->GetCompressedTexImage = intelGetCompressedTexImage;
+}
index e6f9a417790fa2117e2997e87b130cf65e667e5e..2c1b722b7f5db59c813020a71ac611b84a3721f5 100644 (file)
@@ -52,7 +52,9 @@ GLuint intel_compressed_alignment(GLenum internalFormat)
     return alignment;
 }
 
-void i945_miptree_layout_2d( struct intel_context *intel, struct intel_mipmap_tree *mt )
+void i945_miptree_layout_2d( struct intel_context *intel,
+                            struct intel_mipmap_tree *mt,
+                            uint32_t tiling )
 {
    GLint align_h = 2, align_w = 4;
    GLuint level;
@@ -92,7 +94,7 @@ void i945_miptree_layout_2d( struct intel_context *intel, struct intel_mipmap_tr
    /* Pitch must be a whole number of dwords, even though we
     * express it in texels.
     */
-   mt->pitch = intel_miptree_pitch_align (intel, mt, mt->pitch);
+   mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, mt->pitch);
    mt->total_height = 0;
 
    for ( level = mt->first_level ; level <= mt->last_level ; level++ ) {
index dbc90e6f9b74edc3b66a43b072193b47b7cdbe8b..7bc25b6bcb195ff9cff2544651ebfa3af3378b20 100644 (file)
@@ -38,5 +38,7 @@ static GLuint minify( GLuint d )
    return MAX2(1, d>>1);
 }
 
-extern void i945_miptree_layout_2d( struct intel_context *intel, struct intel_mipmap_tree *mt );
+extern void i945_miptree_layout_2d(struct intel_context *intel,
+                                  struct intel_mipmap_tree *mt,
+                                  uint32_t tiling);
 extern GLuint intel_compressed_alignment(GLenum);
index f86de56897644af499f3f994dff350194cf12233..1f27131dac098c711c1242364c00e816f916dfef 100644 (file)
@@ -101,11 +101,6 @@ intelTexSubimage(GLcontext * ctx,
       _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) {
@@ -114,13 +109,15 @@ intelTexSubimage(GLcontext * ctx,
    }
 
    UNLOCK_HARDWARE(intel);
-}
-
-
 
+   /* GL_SGIS_generate_mipmap */
+   if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+      intel_generate_mipmap(ctx, target, texObj);
+   }
+}
 
 
-void
+static void
 intelTexSubImage3D(GLcontext * ctx,
                    GLenum target,
                    GLint level,
@@ -132,18 +129,15 @@ intelTexSubImage3D(GLcontext * ctx,
                    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
+static void
 intelTexSubImage2D(GLcontext * ctx,
                    GLenum target,
                    GLint level,
@@ -155,17 +149,15 @@ intelTexSubImage2D(GLcontext * ctx,
                    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
+static void
 intelTexSubImage1D(GLcontext * ctx,
                    GLenum target,
                    GLint level,
@@ -182,10 +174,9 @@ intelTexSubImage1D(GLcontext * ctx,
                     xoffset, 0, 0,
                     width, 1, 1,
                     format, type, pixels, packing, texObj, texImage);
-
 }
 
-void
+static void
 intelCompressedTexSubImage2D(GLcontext * ctx,
                             GLenum target,
                             GLint level,
@@ -199,3 +190,14 @@ intelCompressedTexSubImage2D(GLcontext * ctx,
    fprintf(stderr, "stubbed CompressedTexSubImage2D: %dx%d@%dx%d\n",
           width, height, xoffset, yoffset);
 }
+
+
+
+void
+intelInitTextureSubImageFuncs(struct dd_function_table *functions)
+{
+   functions->TexSubImage1D = intelTexSubImage1D;
+   functions->TexSubImage2D = intelTexSubImage2D;
+   functions->TexSubImage3D = intelTexSubImage3D;
+   functions->CompressedTexSubImage2D = intelCompressedTexSubImage2D;
+}
index 05a375e1f3b375c4e28f6af64777bb595dbd81de..b5cb7597d164c684f4a298c71f9158265df27734 100644 (file)
@@ -241,7 +241,7 @@ intel_tex_map_level_images(struct intel_context *intel,
       struct intel_texture_image *intelImage =
         intel_texture_image(intelObj->base.Image[face][level]);
 
-      if (intelImage->mt) {
+      if (intelImage && intelImage->mt) {
         intelImage->base.Data =
            intel_miptree_image_map(intel,
                                    intelImage->mt,
@@ -268,7 +268,7 @@ intel_tex_unmap_level_images(struct intel_context *intel,
       struct intel_texture_image *intelImage =
         intel_texture_image(intelObj->base.Image[face][level]);
 
-      if (intelImage->mt) {
+      if (intelImage && intelImage->mt) {
         intel_miptree_image_unmap(intel, intelImage->mt);
         intelImage->base.Data = NULL;
       }
index e9144ac75ce117fb2b2385af12969a549bac28b8..6a246edf7cb0ea88474c53d1bf770a82e9713f6b 100644 (file)
@@ -3,6 +3,8 @@
 TOP = ../../../../..
 include $(TOP)/configs/current
 
+CFLAGS += $(RADEON_CFLAGS)
+
 LIBNAME = r200_dri.so
 
 MINIGLX_SOURCES = server/radeon_dri.c 
@@ -11,25 +13,36 @@ ifeq ($(USING_EGL), 1)
 EGL_SOURCES = server/radeon_egl.c
 endif
 
+RADEON_COMMON_SOURCES = \
+       radeon_texture.c \
+       radeon_common_context.c \
+       radeon_common.c \
+       radeon_dma.c \
+       radeon_lock.c \
+       radeon_bo_legacy.c \
+       radeon_cs_legacy.c \
+       radeon_mipmap_tree.c \
+       radeon_span.c \
+       radeon_fbo.c
+
+
 DRIVER_SOURCES = r200_context.c \
                 r200_ioctl.c \
-                r200_lock.c \
                 r200_state.c \
                 r200_state_init.c \
                 r200_cmdbuf.c \
                 r200_pixel.c \
                 r200_tex.c \
-                r200_texmem.c \
                 r200_texstate.c \
                 r200_tcl.c \
                 r200_swtcl.c \
-                r200_span.c \
                 r200_maos.c \
                 r200_sanity.c \
                 r200_fragshader.c \
                 r200_vertprog.c \
                 radeon_screen.c \
-                $(EGL_SOURCES)
+                $(EGL_SOURCES) \
+                $(RADEON_COMMON_SOURCES)
 
 C_SOURCES = $(COMMON_SOURCES) $(DRIVER_SOURCES)
 
@@ -48,7 +61,30 @@ SYMLINKS = \
 COMMON_SYMLINKS = \
        radeon_chipset.h \
        radeon_screen.c \
-       radeon_screen.h
+       radeon_screen.h \
+       radeon_bo_legacy.c \
+       radeon_cs_legacy.c \
+       radeon_bo_legacy.h \
+       radeon_cs_legacy.h \
+       radeon_bocs_wrapper.h \
+       radeon_span.h \
+       radeon_span.c \
+       radeon_lock.c \
+       radeon_lock.h \
+       radeon_common.c \
+       radeon_common_context.c \
+       radeon_common_context.h \
+       radeon_common.h \
+       radeon_cmdbuf.h \
+       radeon_mipmap_tree.c \
+       radeon_mipmap_tree.h \
+       radeon_texture.c \
+       radeon_texture.h \
+       radeon_dma.c \
+       radeon_dma.h \
+       radeon_fbo.c
+
+DRI_LIB_DEPS += $(RADEON_LDFLAGS)
 
 ##### TARGETS #####
 
index e1633772a18bfc2b370f4cfe998d0262a56d1d28..df9dd83344caa5bd701f0a2418f9ac3e351b421a 100644 (file)
@@ -38,6 +38,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "swrast/swrast.h"
 #include "main/simple_list.h"
 
+#include "radeon_common.h"
 #include "r200_context.h"
 #include "r200_state.h"
 #include "r200_ioctl.h"
@@ -45,18 +46,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r200_sanity.h"
 #include "radeon_reg.h"
 
-static void print_state_atom( struct r200_state_atom *state )
-{
-   int i;
-
-   fprintf(stderr, "emit %s/%d\n", state->name, state->cmd_size);
-
-   if (0 & R200_DEBUG & DEBUG_VERBOSE) 
-      for (i = 0 ; i < state->cmd_size ; i++) 
-        fprintf(stderr, "\t%s[%d]: %x\n", state->name, i, state->cmd[i]);
-
-}
-
 /* The state atoms will be emitted in the order they appear in the atom list,
  * so this step is important.
  */
@@ -64,141 +53,85 @@ void r200SetUpAtomList( r200ContextPtr rmesa )
 {
    int i, mtu;
 
-   mtu = rmesa->glCtx->Const.MaxTextureUnits;
-
-   make_empty_list(&rmesa->hw.atomlist);
-   rmesa->hw.atomlist.name = "atom-list";
-
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.ctx );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.set );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.lin );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.msk );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.vpt );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.vtx );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.vap );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.vte );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.msc );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.cst );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.zbs );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.tcl );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.msl );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.tcg );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.grd );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.fog );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.tam );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.tf );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.atf );
+   mtu = rmesa->radeon.glCtx->Const.MaxTextureUnits;
+
+   make_empty_list(&rmesa->radeon.hw.atomlist);
+   rmesa->radeon.hw.atomlist.name = "atom-list";
+
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.ctx );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.set );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.lin );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.msk );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.vpt );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.vtx );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.vap );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.vte );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.msc );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.cst );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.zbs );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.tcl );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.msl );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.tcg );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.grd );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.fog );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.tam );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.tf );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.atf );
    for (i = 0; i < mtu; ++i)
-       insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.tex[i] );
+       insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.tex[i] );
    for (i = 0; i < mtu; ++i)
-       insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.cube[i] );
+       insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.cube[i] );
    for (i = 0; i < 6; ++i)
-       insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.pix[i] );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.afs[0] );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.afs[1] );
+       insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.pix[i] );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.afs[0] );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.afs[1] );
    for (i = 0; i < 8; ++i)
-       insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.lit[i] );
+       insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.lit[i] );
    for (i = 0; i < 3 + mtu; ++i)
-       insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.mat[i] );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.eye );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.glt );
+       insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.mat[i] );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.eye );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.glt );
    for (i = 0; i < 2; ++i)
-      insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.mtl[i] );
+      insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.mtl[i] );
    for (i = 0; i < 6; ++i)
-       insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.ucp[i] );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.spr );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.ptp );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.prf );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.pvs );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.vpp[0] );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.vpp[1] );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.vpi[0] );
-   insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.vpi[1] );
+       insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.ucp[i] );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.spr );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.ptp );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.prf );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.pvs );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.vpp[0] );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.vpp[1] );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.vpi[0] );
+   insert_at_tail( &rmesa->radeon.hw.atomlist, &rmesa->hw.vpi[1] );
 }
 
-static void r200SaveHwState( r200ContextPtr rmesa )
+void r200EmitScissor(r200ContextPtr rmesa)
 {
-   struct r200_state_atom *atom;
-   char * dest = rmesa->backup_store.cmd_buf;
-
-   if (R200_DEBUG & DEBUG_STATE)
-      fprintf(stderr, "%s\n", __FUNCTION__);
-
-   rmesa->backup_store.cmd_used = 0;
-
-   foreach( atom, &rmesa->hw.atomlist ) {
-      if ( atom->check( rmesa->glCtx, atom->idx ) ) {
-        int size = atom->cmd_size * 4;
-        memcpy( dest, atom->cmd, size);
-        dest += size;
-        rmesa->backup_store.cmd_used += size;
-        if (R200_DEBUG & DEBUG_STATE)
-           print_state_atom( atom );
-      }
-   }
-
-   assert( rmesa->backup_store.cmd_used <= R200_CMD_BUF_SZ );
-   if (R200_DEBUG & DEBUG_STATE)
-      fprintf(stderr, "Returning to r200EmitState\n");
-}
-
-void r200EmitState( r200ContextPtr rmesa )
-{
-   char *dest;
-   int mtu;
-   struct r200_state_atom *atom;
-
-   if (R200_DEBUG & (DEBUG_STATE|DEBUG_PRIMS))
-      fprintf(stderr, "%s\n", __FUNCTION__);
-
-   if (rmesa->save_on_next_emit) {
-      r200SaveHwState(rmesa);
-      rmesa->save_on_next_emit = GL_FALSE;
-   }
-
-   if (!rmesa->hw.is_dirty && !rmesa->hw.all_dirty)
-      return;
-
-   mtu = rmesa->glCtx->Const.MaxTextureUnits;
-
-   /* To avoid going across the entire set of states multiple times, just check
-    * for enough space for the case of emitting all state, and inline the
-    * r200AllocCmdBuf code here without all the checks.
-    */
-   r200EnsureCmdBufSpace( rmesa, rmesa->hw.max_state_size );
-
-   /* we need to calculate dest after EnsureCmdBufSpace
-      as we may flush the buffer - airlied */
-   dest = rmesa->store.cmd_buf + rmesa->store.cmd_used;
-   if (R200_DEBUG & DEBUG_STATE) {
-      foreach( atom, &rmesa->hw.atomlist ) {
-        if ( atom->dirty || rmesa->hw.all_dirty ) {
-           if ( atom->check( rmesa->glCtx, atom->idx ) )
-              print_state_atom( atom );
-           else
-              fprintf(stderr, "skip state %s\n", atom->name);
-        }
-      }
-   }
-
-   foreach( atom, &rmesa->hw.atomlist ) {
-      if ( rmesa->hw.all_dirty )
-        atom->dirty = GL_TRUE;
-      if ( atom->dirty ) {
-        if ( atom->check( rmesa->glCtx, atom->idx ) ) {
-           int size = atom->cmd_size * 4;
-           memcpy( dest, atom->cmd, size);
-           dest += size;
-           rmesa->store.cmd_used += size;
-           atom->dirty = GL_FALSE;
-        }
-      }
-   }
-
-   assert( rmesa->store.cmd_used <= R200_CMD_BUF_SZ );
-
-   rmesa->hw.is_dirty = GL_FALSE;
-   rmesa->hw.all_dirty = GL_FALSE;
+    BATCH_LOCALS(&rmesa->radeon);
+    if (!rmesa->radeon.radeonScreen->kernel_mm) {
+       return;
+    }
+    if (rmesa->radeon.state.scissor.enabled) {
+        BEGIN_BATCH(8);
+        OUT_BATCH(CP_PACKET0(R200_RE_CNTL, 0));
+        OUT_BATCH(R200_SCISSOR_ENABLE | rmesa->hw.set.cmd[SET_RE_CNTL]);
+        OUT_BATCH(CP_PACKET0(R200_RE_AUX_SCISSOR_CNTL, 0));
+        OUT_BATCH(R200_SCISSOR_ENABLE_0);
+        OUT_BATCH(CP_PACKET0(R200_RE_SCISSOR_TL_0, 0));
+        OUT_BATCH((rmesa->radeon.state.scissor.rect.y1 << 16) |
+                  rmesa->radeon.state.scissor.rect.x1);
+        OUT_BATCH(CP_PACKET0(R200_RE_SCISSOR_BR_0, 0));
+        OUT_BATCH(((rmesa->radeon.state.scissor.rect.y2 - 1) << 16) |
+                  (rmesa->radeon.state.scissor.rect.x2 - 1));
+        END_BATCH();
+    } else {
+        BEGIN_BATCH(4);
+        OUT_BATCH(CP_PACKET0(R200_RE_CNTL, 0));
+        OUT_BATCH(rmesa->hw.set.cmd[SET_RE_CNTL] & ~R200_SCISSOR_ENABLE);
+        OUT_BATCH(CP_PACKET0(R200_RE_AUX_SCISSOR_CNTL, 0));
+        OUT_BATCH(0);
+        END_BATCH();
+    }
 }
 
 /* Fire a section of the retained (indexed_verts) buffer as a regular
@@ -208,51 +141,81 @@ void r200EmitVbufPrim( r200ContextPtr rmesa,
                        GLuint primitive,
                        GLuint vertex_nr )
 {
-   drm_radeon_cmd_header_t *cmd;
+   BATCH_LOCALS(&rmesa->radeon);
 
    assert(!(primitive & R200_VF_PRIM_WALK_IND));
    
-   r200EmitState( rmesa );
+   radeonEmitState(&rmesa->radeon);
    
    if (R200_DEBUG & (DEBUG_IOCTL|DEBUG_PRIMS))
       fprintf(stderr, "%s cmd_used/4: %d prim %x nr %d\n", __FUNCTION__,
              rmesa->store.cmd_used/4, primitive, vertex_nr);
-   
-   cmd = (drm_radeon_cmd_header_t *)r200AllocCmdBuf( rmesa, VBUF_BUFSZ,
-                                                 __FUNCTION__ );
-   cmd[0].i = 0;
-   cmd[0].header.cmd_type = RADEON_CMD_PACKET3_CLIP;
-   cmd[1].i = R200_CP_CMD_3D_DRAW_VBUF_2;
-   cmd[2].i = (primitive | 
-              R200_VF_PRIM_WALK_LIST |
-              R200_VF_COLOR_ORDER_RGBA |
-              (vertex_nr << R200_VF_VERTEX_NUMBER_SHIFT));
+   r200EmitScissor(rmesa);
+   BEGIN_BATCH(3);
+   OUT_BATCH_PACKET3_CLIP(R200_CP_CMD_3D_DRAW_VBUF_2, 0);
+   OUT_BATCH(primitive | R200_VF_PRIM_WALK_LIST | R200_VF_COLOR_ORDER_RGBA |
+            (vertex_nr << R200_VF_VERTEX_NUMBER_SHIFT));
+   END_BATCH();
 }
 
+static void r200FireEB(r200ContextPtr rmesa, int vertex_count, int type)
+{
+       BATCH_LOCALS(&rmesa->radeon);
+
+       if (vertex_count > 0) {
+        r200EmitScissor(rmesa);
+               BEGIN_BATCH(8+2);
+               OUT_BATCH_PACKET3_CLIP(R200_CP_CMD_3D_DRAW_INDX_2, 0);
+               OUT_BATCH(R200_VF_PRIM_WALK_IND |
+                         R200_VF_COLOR_ORDER_RGBA | 
+                         ((vertex_count + 0) << 16) |
+                         type);
+               
+               if (!rmesa->radeon.radeonScreen->kernel_mm) {
+                       OUT_BATCH_PACKET3(R200_CP_CMD_INDX_BUFFER, 2);
+                       OUT_BATCH((0x80 << 24) | (0 << 16) | 0x810);
+                       OUT_BATCH_RELOC(rmesa->radeon.tcl.elt_dma_offset,
+                                       rmesa->radeon.tcl.elt_dma_bo,
+                                       rmesa->radeon.tcl.elt_dma_offset,
+                                       RADEON_GEM_DOMAIN_GTT, 0, 0);
+                       OUT_BATCH((vertex_count + 1)/2);
+               } else {
+                       OUT_BATCH_PACKET3(R200_CP_CMD_INDX_BUFFER, 2);
+                       OUT_BATCH((0x80 << 24) | (0 << 16) | 0x810);
+                       OUT_BATCH(rmesa->radeon.tcl.elt_dma_offset);
+                       OUT_BATCH((vertex_count + 1)/2);
+                       radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
+                                             rmesa->radeon.tcl.elt_dma_bo,
+                                             RADEON_GEM_DOMAIN_GTT, 0, 0);
+               }
+               END_BATCH();
+       }
+}
 
-void r200FlushElts( r200ContextPtr rmesa )
+void r200FlushElts(GLcontext *ctx)
 {
-   int *cmd = (int *)(rmesa->store.cmd_buf + rmesa->store.elts_start);
-   int dwords;
-   int nr = (rmesa->store.cmd_used - (rmesa->store.elts_start + 12)) / 2;
+   r200ContextPtr rmesa = R200_CONTEXT(ctx);
+   int nr, elt_used = rmesa->tcl.elt_used;
 
    if (R200_DEBUG & (DEBUG_IOCTL|DEBUG_PRIMS))
-      fprintf(stderr, "%s\n", __FUNCTION__);
+     fprintf(stderr, "%s %x %d\n", __FUNCTION__, rmesa->tcl.hw_primitive, elt_used);
 
-   assert( rmesa->dma.flush == r200FlushElts );
-   rmesa->dma.flush = NULL;
+   assert( rmesa->radeon.dma.flush == r200FlushElts );
+   rmesa->radeon.dma.flush = NULL;
 
-   /* Cope with odd number of elts:
-    */
-   rmesa->store.cmd_used = (rmesa->store.cmd_used + 2) & ~2;
-   dwords = (rmesa->store.cmd_used - rmesa->store.elts_start) / 4;
+   nr = elt_used / 2;
 
-   cmd[1] |= (dwords - 3) << 16;
-   cmd[2] |= nr << R200_VF_VERTEX_NUMBER_SHIFT;
+   radeon_bo_unmap(rmesa->radeon.tcl.elt_dma_bo);
+
+   r200FireEB(rmesa, nr, rmesa->tcl.hw_primitive);
+
+   radeon_bo_unref(rmesa->radeon.tcl.elt_dma_bo);
+   rmesa->radeon.tcl.elt_dma_bo = NULL;
 
    if (R200_DEBUG & DEBUG_SYNC) {
       fprintf(stderr, "%s: Syncing\n", __FUNCTION__);
-      r200Finish( rmesa->glCtx );
+      radeonFinish( rmesa->radeon.glCtx );
    }
 }
 
@@ -261,7 +224,6 @@ GLushort *r200AllocEltsOpenEnded( r200ContextPtr rmesa,
                                    GLuint primitive,
                                    GLuint min_nr )
 {
-   drm_radeon_cmd_header_t *cmd;
    GLushort *retval;
 
    if (R200_DEBUG & DEBUG_IOCTL)
@@ -269,30 +231,30 @@ GLushort *r200AllocEltsOpenEnded( r200ContextPtr rmesa,
 
    assert((primitive & R200_VF_PRIM_WALK_IND));
    
-   r200EmitState( rmesa );
-   
-   cmd = (drm_radeon_cmd_header_t *)r200AllocCmdBuf( rmesa, ELTS_BUFSZ(min_nr),
-                                               __FUNCTION__ );
-   cmd[0].i = 0;
-   cmd[0].header.cmd_type = RADEON_CMD_PACKET3_CLIP;
-   cmd[1].i = R200_CP_CMD_3D_DRAW_INDX_2;
-   cmd[2].i = (primitive | 
-              R200_VF_PRIM_WALK_IND |
-              R200_VF_COLOR_ORDER_RGBA);
+   radeonEmitState(&rmesa->radeon);
+
+   rmesa->radeon.tcl.elt_dma_bo = radeon_bo_open(rmesa->radeon.radeonScreen->bom,
+                                         0, R200_ELT_BUF_SZ, 4,
+                                         RADEON_GEM_DOMAIN_GTT, 0);
+   rmesa->radeon.tcl.elt_dma_offset = 0;
+   rmesa->tcl.elt_used = min_nr * 2;
 
+   radeon_validate_bo(&rmesa->radeon, rmesa->radeon.tcl.elt_dma_bo,
+                      RADEON_GEM_DOMAIN_GTT, 0);
+   if (radeon_revalidate_bos(rmesa->radeon.glCtx) == GL_FALSE)
+      fprintf(stderr,"failure to revalidate BOs - badness\n");
+
+   radeon_bo_map(rmesa->radeon.tcl.elt_dma_bo, 1);
+   retval = rmesa->radeon.tcl.elt_dma_bo->ptr + rmesa->radeon.tcl.elt_dma_offset;
    
-   retval = (GLushort *)(cmd+3);
 
    if (R200_DEBUG & DEBUG_PRIMS)
-      fprintf(stderr, "%s: header 0x%x prim %x \n",
-             __FUNCTION__,
-             cmd[1].i, primitive);
-
-   assert(!rmesa->dma.flush);
-   rmesa->glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
-   rmesa->dma.flush = r200FlushElts;
+      fprintf(stderr, "%s: header prim %x \n",
+             __FUNCTION__, primitive);
 
-   rmesa->store.elts_start = ((char *)cmd) - rmesa->store.cmd_buf;
+   assert(!rmesa->radeon.dma.flush);
+   rmesa->radeon.glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
+   rmesa->radeon.dma.flush = r200FlushElts;
 
    return retval;
 }
@@ -300,129 +262,119 @@ GLushort *r200AllocEltsOpenEnded( r200ContextPtr rmesa,
 
 
 void r200EmitVertexAOS( r200ContextPtr rmesa,
-                         GLuint vertex_size,
-                         GLuint offset )
+                       GLuint vertex_size,
+                       struct radeon_bo *bo,
+                       GLuint offset )
 {
-   drm_radeon_cmd_header_t *cmd;
+   BATCH_LOCALS(&rmesa->radeon);
 
    if (R200_DEBUG & (DEBUG_PRIMS|DEBUG_IOCTL))
       fprintf(stderr, "%s:  vertex_size 0x%x offset 0x%x \n",
              __FUNCTION__, vertex_size, offset);
 
-   cmd = (drm_radeon_cmd_header_t *)r200AllocCmdBuf( rmesa, VERT_AOS_BUFSZ,
-                                                 __FUNCTION__ );
 
-   cmd[0].header.cmd_type = RADEON_CMD_PACKET3;
-   cmd[1].i = R200_CP_CMD_3D_LOAD_VBPNTR | (2 << 16);
-   cmd[2].i = 1;
-   cmd[3].i = vertex_size | (vertex_size << 8);
-   cmd[4].i = offset;
+   BEGIN_BATCH(7);
+   OUT_BATCH_PACKET3(R200_CP_CMD_3D_LOAD_VBPNTR, 2);
+   OUT_BATCH(1);
+   OUT_BATCH(vertex_size | (vertex_size << 8));
+   OUT_BATCH_RELOC(offset, bo, offset, RADEON_GEM_DOMAIN_GTT, 0, 0);
+   END_BATCH();
 }
-                      
 
-void r200EmitAOS( r200ContextPtr rmesa,
-                   struct r200_dma_region **component,
-                   GLuint nr,
-                   GLuint offset )
+void r200EmitAOS(r200ContextPtr rmesa, GLuint nr, GLuint offset)
 {
-   drm_radeon_cmd_header_t *cmd;
-   int sz = AOS_BUFSZ(nr);
+   BATCH_LOCALS(&rmesa->radeon);
+   uint32_t voffset;
+   int sz = 1 + (nr >> 1) * 3 + (nr & 1) * 2;
    int i;
-   int *tmp;
-
-   if (R200_DEBUG & DEBUG_IOCTL)
-      fprintf(stderr, "%s nr arrays: %d\n", __FUNCTION__, nr);
-
-   cmd = (drm_radeon_cmd_header_t *)r200AllocCmdBuf( rmesa, sz, __FUNCTION__ );
-   cmd[0].i = 0;
-   cmd[0].header.cmd_type = RADEON_CMD_PACKET3;
-   cmd[1].i = R200_CP_CMD_3D_LOAD_VBPNTR | (((sz / sizeof(int)) - 3) << 16);
-   cmd[2].i = nr;
-   tmp = &cmd[0].i;
-   cmd += 3;
-
-   for (i = 0 ; i < nr ; i++) {
-      if (i & 1) {
-        cmd[0].i |= ((component[i]->aos_stride << 24) | 
-                     (component[i]->aos_size << 16));
-        cmd[2].i = (component[i]->aos_start + 
-                    offset * component[i]->aos_stride * 4);
-        cmd += 3;
+   
+   if (RADEON_DEBUG & DEBUG_VERTS)
+      fprintf(stderr, "%s: nr=%d, ofs=0x%08x\n", __FUNCTION__, nr,
+             offset);
+
+   BEGIN_BATCH(sz+2+ (nr*2));
+   OUT_BATCH_PACKET3(R200_CP_CMD_3D_LOAD_VBPNTR, sz - 1);
+   OUT_BATCH(nr);
+
+    
+   if (!rmesa->radeon.radeonScreen->kernel_mm) {
+      for (i = 0; i + 1 < nr; i += 2) {
+        OUT_BATCH((rmesa->radeon.tcl.aos[i].components << 0) |
+                  (rmesa->radeon.tcl.aos[i].stride << 8) |
+                  (rmesa->radeon.tcl.aos[i + 1].components << 16) |
+                  (rmesa->radeon.tcl.aos[i + 1].stride << 24));
+                       
+        voffset =  rmesa->radeon.tcl.aos[i + 0].offset +
+           offset * 4 * rmesa->radeon.tcl.aos[i + 0].stride;
+        OUT_BATCH_RELOC(voffset,
+                        rmesa->radeon.tcl.aos[i].bo,
+                        voffset,
+                        RADEON_GEM_DOMAIN_GTT,
+                        0, 0);
+        voffset =  rmesa->radeon.tcl.aos[i + 1].offset +
+           offset * 4 * rmesa->radeon.tcl.aos[i + 1].stride;
+        OUT_BATCH_RELOC(voffset,
+                        rmesa->radeon.tcl.aos[i+1].bo,
+                        voffset,
+                        RADEON_GEM_DOMAIN_GTT,
+                        0, 0);
       }
-      else {
-        cmd[0].i = ((component[i]->aos_stride << 8) | 
-                    (component[i]->aos_size << 0));
-        cmd[1].i = (component[i]->aos_start + 
-                    offset * component[i]->aos_stride * 4);
+      
+      if (nr & 1) {
+        OUT_BATCH((rmesa->radeon.tcl.aos[nr - 1].components << 0) |
+                  (rmesa->radeon.tcl.aos[nr - 1].stride << 8));
+        voffset =  rmesa->radeon.tcl.aos[nr - 1].offset +
+           offset * 4 * rmesa->radeon.tcl.aos[nr - 1].stride;
+        OUT_BATCH_RELOC(voffset,
+                        rmesa->radeon.tcl.aos[nr - 1].bo,
+                        voffset,
+                        RADEON_GEM_DOMAIN_GTT,
+                        0, 0);
+      }
+   } else {
+      for (i = 0; i + 1 < nr; i += 2) {
+        OUT_BATCH((rmesa->radeon.tcl.aos[i].components << 0) |
+                  (rmesa->radeon.tcl.aos[i].stride << 8) |
+                  (rmesa->radeon.tcl.aos[i + 1].components << 16) |
+                  (rmesa->radeon.tcl.aos[i + 1].stride << 24));
+        
+        voffset =  rmesa->radeon.tcl.aos[i + 0].offset +
+           offset * 4 * rmesa->radeon.tcl.aos[i + 0].stride;
+        OUT_BATCH(voffset);
+        voffset =  rmesa->radeon.tcl.aos[i + 1].offset +
+           offset * 4 * rmesa->radeon.tcl.aos[i + 1].stride;
+        OUT_BATCH(voffset);
+      }
+      
+      if (nr & 1) {
+        OUT_BATCH((rmesa->radeon.tcl.aos[nr - 1].components << 0) |
+                  (rmesa->radeon.tcl.aos[nr - 1].stride << 8));
+        voffset =  rmesa->radeon.tcl.aos[nr - 1].offset +
+           offset * 4 * rmesa->radeon.tcl.aos[nr - 1].stride;
+        OUT_BATCH(voffset);
+      }
+      for (i = 0; i + 1 < nr; i += 2) {
+        voffset =  rmesa->radeon.tcl.aos[i + 0].offset +
+           offset * 4 * rmesa->radeon.tcl.aos[i + 0].stride;
+        radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
+                              rmesa->radeon.tcl.aos[i+0].bo,
+                              RADEON_GEM_DOMAIN_GTT,
+                              0, 0);
+        voffset =  rmesa->radeon.tcl.aos[i + 1].offset +
+           offset * 4 * rmesa->radeon.tcl.aos[i + 1].stride;
+        radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
+                              rmesa->radeon.tcl.aos[i+1].bo,
+                              RADEON_GEM_DOMAIN_GTT,
+                              0, 0);
+      }
+      if (nr & 1) {
+        voffset =  rmesa->radeon.tcl.aos[nr - 1].offset +
+           offset * 4 * rmesa->radeon.tcl.aos[nr - 1].stride;
+        radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
+                              rmesa->radeon.tcl.aos[nr-1].bo,
+                              RADEON_GEM_DOMAIN_GTT,
+                              0, 0);
       }
    }
-
-   if (R200_DEBUG & DEBUG_VERTS) {
-      fprintf(stderr, "%s:\n", __FUNCTION__);
-      for (i = 0 ; i < sz ; i++)
-        fprintf(stderr, "   %d: %x\n", i, tmp[i]);
-   }
-}
-
-void r200EmitBlit( r200ContextPtr rmesa,
-                  GLuint color_fmt,
-                  GLuint src_pitch,
-                  GLuint src_offset,
-                  GLuint dst_pitch,
-                  GLuint dst_offset,
-                  GLint srcx, GLint srcy,
-                  GLint dstx, GLint dsty,
-                  GLuint w, GLuint h )
-{
-   drm_radeon_cmd_header_t *cmd;
-
-   if (R200_DEBUG & DEBUG_IOCTL)
-      fprintf(stderr, "%s src %x/%x %d,%d dst: %x/%x %d,%d sz: %dx%d\n",
-             __FUNCTION__, 
-             src_pitch, src_offset, srcx, srcy,
-             dst_pitch, dst_offset, dstx, dsty,
-             w, h);
-
-   assert( (src_pitch & 63) == 0 );
-   assert( (dst_pitch & 63) == 0 );
-   assert( (src_offset & 1023) == 0 );
-   assert( (dst_offset & 1023) == 0 );
-   assert( w < (1<<16) );
-   assert( h < (1<<16) );
-
-   cmd = (drm_radeon_cmd_header_t *)r200AllocCmdBuf( rmesa, 8 * sizeof(int),
-                                                 __FUNCTION__ );
-
-
-   cmd[0].header.cmd_type = RADEON_CMD_PACKET3;
-   cmd[1].i = R200_CP_CMD_BITBLT_MULTI | (5 << 16);
-   cmd[2].i = (RADEON_GMC_SRC_PITCH_OFFSET_CNTL |
-              RADEON_GMC_DST_PITCH_OFFSET_CNTL |
-              RADEON_GMC_BRUSH_NONE |
-              (color_fmt << 8) |
-              RADEON_GMC_SRC_DATATYPE_COLOR |
-              RADEON_ROP3_S |
-              RADEON_DP_SRC_SOURCE_MEMORY |
-              RADEON_GMC_CLR_CMP_CNTL_DIS |
-              RADEON_GMC_WR_MSK_DIS );
-
-   cmd[3].i = ((src_pitch/64)<<22) | (src_offset >> 10);
-   cmd[4].i = ((dst_pitch/64)<<22) | (dst_offset >> 10);
-   cmd[5].i = (srcx << 16) | srcy;
-   cmd[6].i = (dstx << 16) | dsty; /* dst */
-   cmd[7].i = (w << 16) | h;
-}
-
-
-void r200EmitWait( r200ContextPtr rmesa, GLuint flags )
-{
-   drm_radeon_cmd_header_t *cmd;
-
-   assert( !(flags & ~(RADEON_WAIT_2D|RADEON_WAIT_3D)) );
-
-   cmd = (drm_radeon_cmd_header_t *)r200AllocCmdBuf( rmesa, 1 * sizeof(int),
-                                          __FUNCTION__ );
-   cmd[0].i = 0;
-   cmd[0].wait.cmd_type = RADEON_CMD_WAIT;
-   cmd[0].wait.flags = flags;
+   END_BATCH();
 }
index c06751516eb47f72aff9be99629284d92ecaab53..8924849d08262d4366c3bc54286d97cc555b2901 100644 (file)
@@ -54,7 +54,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r200_context.h"
 #include "r200_ioctl.h"
 #include "r200_state.h"
-#include "r200_span.h"
 #include "r200_pixel.h"
 #include "r200_tex.h"
 #include "r200_swtcl.h"
@@ -62,6 +61,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r200_maos.h"
 #include "r200_vertprog.h"
 
+#include "radeon_span.h"
+
 #define need_GL_ARB_vertex_program
 #define need_GL_ATI_fragment_shader
 #define need_GL_EXT_blend_minmax
@@ -71,6 +72,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define need_GL_EXT_blend_func_separate
 #define need_GL_NV_vertex_program
 #define need_GL_ARB_point_parameters
+#define need_GL_EXT_framebuffer_object
 #include "extension_helper.h"
 
 #define DRIVER_DATE    "20060602"
@@ -78,9 +80,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "vblank.h"
 #include "utils.h"
 #include "xmlpool.h" /* for symbolic values of enum-type options */
-#ifndef R200_DEBUG
-int R200_DEBUG = (0);
-#endif
 
 /* Return various strings for glGetString().
  */
@@ -89,8 +88,8 @@ static const GLubyte *r200GetString( GLcontext *ctx, GLenum name )
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
    static char buffer[128];
    unsigned   offset;
-   GLuint agp_mode = (rmesa->r200Screen->card_type == RADEON_CARD_PCI)? 0 :
-      rmesa->r200Screen->AGPMode;
+   GLuint agp_mode = (rmesa->radeon.radeonScreen->card_type == RADEON_CARD_PCI)? 0 :
+      rmesa->radeon.radeonScreen->AGPMode;
 
    switch ( name ) {
    case GL_VENDOR:
@@ -101,7 +100,7 @@ static const GLubyte *r200GetString( GLcontext *ctx, GLenum name )
                                     agp_mode );
 
       sprintf( & buffer[ offset ], " %sTCL",
-              !(rmesa->TclFallback & R200_TCL_FALLBACK_TCL_DISABLE)
+              !(rmesa->radeon.TclFallback & R200_TCL_FALLBACK_TCL_DISABLE)
               ? "" : "NO-" );
 
       return (GLubyte *)buffer;
@@ -126,6 +125,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_packed_depth_stencil",      NULL},
     { "GL_EXT_secondary_color",            GL_EXT_secondary_color_functions },
     { "GL_EXT_stencil_wrap",               NULL },
     { "GL_EXT_texture_edge_clamp",         NULL },
@@ -167,6 +167,11 @@ const struct dri_extension point_extensions[] = {
     { NULL,                                NULL }
 };
 
+const struct dri_extension mm_extensions[] = {
+  { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions },
+  { NULL, NULL }
+};
+
 extern const struct tnl_pipeline_stage _r200_render_stage;
 extern const struct tnl_pipeline_stage _r200_tcl_stage;
 
@@ -234,6 +239,39 @@ static const struct dri_debug_control debug_control[] =
     { NULL,    0 }
 };
 
+static void r200_get_lock(radeonContextPtr radeon)
+{
+   r200ContextPtr rmesa = (r200ContextPtr)radeon;
+   drm_radeon_sarea_t *sarea = radeon->sarea;
+
+   R200_STATECHANGE( rmesa, ctx );
+   if (rmesa->radeon.sarea->tiling_enabled) {
+      rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= R200_COLOR_TILE_ENABLE;
+   }
+   else rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] &= ~R200_COLOR_TILE_ENABLE;
+
+   if ( sarea->ctx_owner != rmesa->radeon.dri.hwContext ) {
+      sarea->ctx_owner = rmesa->radeon.dri.hwContext;
+      if (!radeon->radeonScreen->kernel_mm)
+         radeon_bo_legacy_texture_age(radeon->radeonScreen->bom);
+   }
+
+}
+
+static void r200_vtbl_emit_cs_header(struct radeon_cs *cs, radeonContextPtr rmesa)
+{
+}
+
+
+static void r200_init_vtbl(radeonContextPtr radeon)
+{
+   radeon->vtbl.get_lock = r200_get_lock;
+   radeon->vtbl.update_viewport_offset = r200UpdateViewportOffset;
+   radeon->vtbl.emit_cs_header = r200_vtbl_emit_cs_header;
+   radeon->vtbl.swtcl_flush = r200_swtcl_flush;
+   radeon->vtbl.fallback = r200Fallback;
+}
+
 
 /* Create the device specific rendering context.
  */
@@ -245,9 +283,9 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
    radeonScreenPtr screen = (radeonScreenPtr)(sPriv->private);
    struct dd_function_table functions;
    r200ContextPtr rmesa;
-   GLcontext *ctx, *shareCtx;
+   GLcontext *ctx;
    int i;
-   int tcl_mode, fthrottle_mode;
+   int tcl_mode;
 
    assert(glVisual);
    assert(driContextPriv);
@@ -257,7 +295,8 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
    rmesa = (r200ContextPtr) CALLOC( sizeof(*rmesa) );
    if ( !rmesa )
       return GL_FALSE;
-      
+
+   r200_init_vtbl(&rmesa->radeon);
    /* init exp fog table data */
    r200InitStaticFogData();
 
@@ -265,12 +304,12 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
     * Do this here so that initialMaxAnisotropy is set before we create
     * the default textures.
     */
-   driParseConfigFiles (&rmesa->optionCache, &screen->optionCache,
+   driParseConfigFiles (&rmesa->radeon.optionCache, &screen->optionCache,
                        screen->driScreen->myNum, "r200");
-   rmesa->initialMaxAnisotropy = driQueryOptionf(&rmesa->optionCache,
-                                                 "def_max_anisotropy");
+   rmesa->radeon.initialMaxAnisotropy = driQueryOptionf(&rmesa->radeon.optionCache,
+                                                       "def_max_anisotropy");
 
-   if ( driQueryOptionb( &rmesa->optionCache, "hyperz" ) ) {
+   if ( driQueryOptionb( &rmesa->radeon.optionCache, "hyperz" ) ) {
       if ( sPriv->drm_version.minor < 13 )
         fprintf( stderr, "DRM version 1.%d too old to support HyperZ, "
                          "disabling.\n", sPriv->drm_version.minor );
@@ -291,59 +330,15 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
    r200InitTextureFuncs(&functions);
    r200InitShaderFuncs(&functions); 
 
-   /* Allocate and initialize the Mesa context */
-   if (sharedContextPrivate)
-      shareCtx = ((r200ContextPtr) sharedContextPrivate)->glCtx;
-   else
-      shareCtx = NULL;
-   rmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
-                                       &functions, (void *) rmesa);
-   if (!rmesa->glCtx) {
-      FREE(rmesa);
-      return GL_FALSE;
-   }
-   driContextPriv->driverPrivate = rmesa;
-
-   /* Init r200 context data */
-   rmesa->dri.context = driContextPriv;
-   rmesa->dri.screen = sPriv;
-   rmesa->dri.drawable = NULL; /* Set by XMesaMakeCurrent */
-   rmesa->dri.hwContext = driContextPriv->hHWContext;
-   rmesa->dri.hwLock = &sPriv->pSAREA->lock;
-   rmesa->dri.fd = sPriv->fd;
-   rmesa->dri.drmMinor = sPriv->drm_version.minor;
-
-   rmesa->r200Screen = screen;
-   rmesa->sarea = (drm_radeon_sarea_t *)((GLubyte *)sPriv->pSAREA +
-                                      screen->sarea_priv_offset);
-
-
-   rmesa->dma.buf0_address = rmesa->r200Screen->buffers->list[0].address;
-
-   (void) memset( rmesa->texture_heaps, 0, sizeof( rmesa->texture_heaps ) );
-   make_empty_list( & rmesa->swapped );
-
-   rmesa->nr_heaps = 1 /* screen->numTexHeaps */ ;
-   assert(rmesa->nr_heaps < RADEON_NR_TEX_HEAPS);
-   for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
-      rmesa->texture_heaps[i] = driCreateTextureHeap( i, rmesa,
-           screen->texSize[i],
-           12,
-           RADEON_NR_TEX_REGIONS,
-           (drmTextureRegionPtr)rmesa->sarea->tex_list[i],
-           & rmesa->sarea->tex_age[i],
-           & rmesa->swapped,
-           sizeof( r200TexObj ),
-           (destroy_texture_object_t *) r200DestroyTexObj );
+   if (!radeonInitContext(&rmesa->radeon, &functions,
+                         glVisual, driContextPriv,
+                         sharedContextPrivate)) {
+     FREE(rmesa);
+     return GL_FALSE;
    }
-   rmesa->texture_depth = driQueryOptioni (&rmesa->optionCache,
-                                          "texture_depth");
-   if (rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
-      rmesa->texture_depth = ( screen->cpp == 4 ) ?
-        DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
 
-   rmesa->swtcl.RenderIndex = ~0;
-   rmesa->hw.all_dirty = 1;
+   rmesa->radeon.swtcl.RenderIndex = ~0;
+   rmesa->radeon.hw.all_dirty = 1;
 
    /* Set the maximum texture size small enough that we can guarentee that
     * all texture units can bind a maximal texture and have all of them in
@@ -351,29 +346,17 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
     * setting allow larger textures.
     */
 
-   ctx = rmesa->glCtx;
-   ctx->Const.MaxTextureUnits = driQueryOptioni (&rmesa->optionCache,
+   ctx = rmesa->radeon.glCtx;
+   ctx->Const.MaxTextureUnits = driQueryOptioni (&rmesa->radeon.optionCache,
                                                 "texture_units");
    ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits;
    ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits;
 
-   i = driQueryOptioni( &rmesa->optionCache, "allow_large_textures");
-
-   driCalculateMaxTextureLevels( rmesa->texture_heaps,
-                                rmesa->nr_heaps,
-                                & ctx->Const,
-                                4,
-                                11, /* max 2D texture size is 2048x2048 */
-#if ENABLE_HW_3D_TEXTURE
-                                8,  /* max 3D texture size is 256^3 */
-#else
-                                0,  /* 3D textures unsupported */
-#endif
-                                11, /* max cube texture size is 2048x2048 */
-                                11, /* max texture rectangle size is 2048x2048 */
-                                12,
-                                GL_FALSE,
-                                i );
+   i = driQueryOptioni( &rmesa->radeon.optionCache, "allow_large_textures");
+
+   /* FIXME: When no memory manager is available we should set this 
+    * to some reasonable value based on texture memory pool size */
+   ctx->Const.MaxTextureLevels = 12;
 
    ctx->Const.MaxTextureMaxAnisotropy = 16.0;
 
@@ -383,7 +366,7 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
    ctx->Const.MinPointSizeAA = 1.0;
    ctx->Const.MaxPointSizeAA = 1.0;
    ctx->Const.PointSizeGranularity = 0.0625;
-   if (rmesa->r200Screen->drmSupportsPointSprites)
+   if (rmesa->radeon.radeonScreen->drmSupportsPointSprites)
       ctx->Const.MaxPointSize = 2047.0;
    else
       ctx->Const.MaxPointSize = 1.0;
@@ -439,32 +422,35 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
    _math_matrix_set_identity( &rmesa->tmpmat );
 
    driInitExtensions( ctx, card_extensions, GL_TRUE );
-   if (!(rmesa->r200Screen->chip_flags & R200_CHIPSET_YCBCR_BROKEN)) {
+
+   if (rmesa->radeon.radeonScreen->kernel_mm)
+     driInitExtensions(ctx, mm_extensions, GL_FALSE);
+   if (!(rmesa->radeon.radeonScreen->chip_flags & R200_CHIPSET_YCBCR_BROKEN)) {
      /* yuv textures don't work with some chips - R200 / rv280 okay so far
        others get the bit ordering right but don't actually do YUV-RGB conversion */
       _mesa_enable_extension( ctx, "GL_MESA_ycbcr_texture" );
    }
-   if (rmesa->glCtx->Mesa_DXTn) {
+   if (rmesa->radeon.glCtx->Mesa_DXTn) {
       _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
       _mesa_enable_extension( ctx, "GL_S3_s3tc" );
    }
-   else if (driQueryOptionb (&rmesa->optionCache, "force_s3tc_enable")) {
+   else if (driQueryOptionb (&rmesa->radeon.optionCache, "force_s3tc_enable")) {
       _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
    }
 
-   if (rmesa->r200Screen->drmSupportsCubeMapsR200)
+   if (rmesa->radeon.radeonScreen->drmSupportsCubeMapsR200)
       _mesa_enable_extension( ctx, "GL_ARB_texture_cube_map" );
-   if (rmesa->r200Screen->drmSupportsBlendColor) {
+   if (rmesa->radeon.radeonScreen->drmSupportsBlendColor) {
        driInitExtensions( ctx, blend_extensions, GL_FALSE );
    }
-   if(rmesa->r200Screen->drmSupportsVertexProgram)
+   if(rmesa->radeon.radeonScreen->drmSupportsVertexProgram)
       driInitSingleExtension( ctx, ARB_vp_extension );
-   if(driQueryOptionb(&rmesa->optionCache, "nv_vertex_program"))
+   if(driQueryOptionb(&rmesa->radeon.optionCache, "nv_vertex_program"))
       driInitSingleExtension( ctx, NV_vp_extension );
 
-   if ((ctx->Const.MaxTextureUnits == 6) && rmesa->r200Screen->drmSupportsFragShader)
+   if ((ctx->Const.MaxTextureUnits == 6) && rmesa->radeon.radeonScreen->drmSupportsFragShader)
       driInitSingleExtension( ctx, ATI_fs_extension );
-   if (rmesa->r200Screen->drmSupportsPointSprites)
+   if (rmesa->radeon.radeonScreen->drmSupportsPointSprites)
       driInitExtensions( ctx, point_extensions, GL_FALSE );
 #if 0
    r200InitDriverFuncs( ctx );
@@ -474,33 +460,16 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
 #endif
    /* plug in a few more device driver functions */
    /* XXX these should really go right after _mesa_init_driver_functions() */
+   radeon_fbo_init(&rmesa->radeon);
+   radeonInitSpanFuncs( ctx );
    r200InitPixelFuncs( ctx );
-   r200InitSpanFuncs( ctx );
    r200InitTnlFuncs( ctx );
    r200InitState( rmesa );
    r200InitSwtcl( ctx );
 
-   fthrottle_mode = driQueryOptioni(&rmesa->optionCache, "fthrottle_mode");
-   rmesa->iw.irq_seq = -1;
-   rmesa->irqsEmitted = 0;
-   rmesa->do_irqs = (fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS &&
-                    rmesa->r200Screen->irq);
-
-   rmesa->do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS);
-
-   if (!rmesa->do_irqs)
-      fprintf(stderr,
-             "IRQ's not enabled, falling back to %s: %d %d\n",
-             rmesa->do_usleeps ? "usleeps" : "busy waits",
-             fthrottle_mode,
-             rmesa->r200Screen->irq);
-
    rmesa->prefer_gart_client_texturing = 
       (getenv("R200_GART_CLIENT_TEXTURES") != 0);
 
-   (*sPriv->systemTime->getUST)( & rmesa->swap_ust );
-
-
 #if DO_DEBUG
    R200_DEBUG  = driParseDebugString( getenv( "R200_DEBUG" ),
                                      debug_control );
@@ -508,202 +477,21 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
                                      debug_control );
 #endif
 
-   tcl_mode = driQueryOptioni(&rmesa->optionCache, "tcl_mode");
-   if (driQueryOptionb(&rmesa->optionCache, "no_rast")) {
+   tcl_mode = driQueryOptioni(&rmesa->radeon.optionCache, "tcl_mode");
+   if (driQueryOptionb(&rmesa->radeon.optionCache, "no_rast")) {
       fprintf(stderr, "disabling 3D acceleration\n");
       FALLBACK(rmesa, R200_FALLBACK_DISABLE, 1);
    }
    else if (tcl_mode == DRI_CONF_TCL_SW || getenv("R200_NO_TCL") ||
-           !(rmesa->r200Screen->chip_flags & RADEON_CHIPSET_TCL)) {
-      if (rmesa->r200Screen->chip_flags & RADEON_CHIPSET_TCL) {
-        rmesa->r200Screen->chip_flags &= ~RADEON_CHIPSET_TCL;
+           !(rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL)) {
+      if (rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL) {
+        rmesa->radeon.radeonScreen->chip_flags &= ~RADEON_CHIPSET_TCL;
         fprintf(stderr, "Disabling HW TCL support\n");
       }
-      TCL_FALLBACK(rmesa->glCtx, R200_TCL_FALLBACK_TCL_DISABLE, 1);
+      TCL_FALLBACK(rmesa->radeon.glCtx, R200_TCL_FALLBACK_TCL_DISABLE, 1);
    }
 
    return GL_TRUE;
 }
 
 
-/* Destroy the device specific context.
- */
-/* Destroy the Mesa and driver specific context data.
- */
-void r200DestroyContext( __DRIcontextPrivate *driContextPriv )
-{
-   GET_CURRENT_CONTEXT(ctx);
-   r200ContextPtr rmesa = (r200ContextPtr) driContextPriv->driverPrivate;
-   r200ContextPtr current = ctx ? R200_CONTEXT(ctx) : NULL;
-
-   /* check if we're deleting the currently bound context */
-   if (rmesa == current) {
-      R200_FIREVERTICES( rmesa );
-      _mesa_make_current(NULL, NULL, NULL);
-   }
-
-   /* Free r200 context resources */
-   assert(rmesa); /* should never be null */
-   if ( rmesa ) {
-      GLboolean   release_texture_heaps;
-
-
-      release_texture_heaps = (rmesa->glCtx->Shared->RefCount == 1);
-      _swsetup_DestroyContext( rmesa->glCtx );
-      _tnl_DestroyContext( rmesa->glCtx );
-      _vbo_DestroyContext( rmesa->glCtx );
-      _swrast_DestroyContext( rmesa->glCtx );
-
-      r200DestroySwtcl( rmesa->glCtx );
-      r200ReleaseArrays( rmesa->glCtx, ~0 );
-
-      if (rmesa->dma.current.buf) {
-        r200ReleaseDmaRegion( rmesa, &rmesa->dma.current, __FUNCTION__ );
-        r200FlushCmdBuf( rmesa, __FUNCTION__ );
-      }
-
-      if (rmesa->state.scissor.pClipRects) {
-        FREE(rmesa->state.scissor.pClipRects);
-        rmesa->state.scissor.pClipRects = NULL;
-      }
-
-      if ( release_texture_heaps ) {
-         /* This share group is about to go away, free our private
-          * texture object data.
-          */
-         int i;
-
-         for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
-           driDestroyTextureHeap( rmesa->texture_heaps[ i ] );
-           rmesa->texture_heaps[ i ] = NULL;
-         }
-
-        assert( is_empty_list( & rmesa->swapped ) );
-      }
-
-      /* free the Mesa context */
-      rmesa->glCtx->DriverCtx = NULL;
-      _mesa_destroy_context( rmesa->glCtx );
-
-      /* free the option cache */
-      driDestroyOptionCache (&rmesa->optionCache);
-
-      FREE( rmesa );
-   }
-}
-
-
-
-
-void
-r200SwapBuffers( __DRIdrawablePrivate *dPriv )
-{
-   if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
-      r200ContextPtr rmesa;
-      GLcontext *ctx;
-      rmesa = (r200ContextPtr) dPriv->driContextPriv->driverPrivate;
-      ctx = rmesa->glCtx;
-      if (ctx->Visual.doubleBufferMode) {
-         _mesa_notifySwapBuffers( ctx );  /* flush pending rendering comands */
-         if ( rmesa->doPageFlip ) {
-            r200PageFlip( dPriv );
-         }
-         else {
-            r200CopyBuffer( dPriv, NULL );
-         }
-      }
-   }
-   else {
-      /* XXX this shouldn't be an error but we can't handle it for now */
-      _mesa_problem(NULL, "%s: drawable has no context!", __FUNCTION__);
-   }
-}
-
-void
-r200CopySubBuffer( __DRIdrawablePrivate *dPriv,
-                  int x, int y, int w, int h )
-{
-   if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
-      r200ContextPtr rmesa;
-      GLcontext *ctx;
-      rmesa = (r200ContextPtr) dPriv->driContextPriv->driverPrivate;
-      ctx = rmesa->glCtx;
-      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 */
-        r200CopyBuffer( dPriv, &rect );
-      }
-   }
-   else {
-      /* XXX this shouldn't be an error but we can't handle it for now */
-      _mesa_problem(NULL, "%s: drawable has no context!", __FUNCTION__);
-   }
-}
-
-/* Force the context `c' to be the current context and associate with it
- * buffer `b'.
- */
-GLboolean
-r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
-                   __DRIdrawablePrivate *driDrawPriv,
-                   __DRIdrawablePrivate *driReadPriv )
-{
-   if ( driContextPriv ) {
-      r200ContextPtr newCtx = 
-        (r200ContextPtr) driContextPriv->driverPrivate;
-
-      if (R200_DEBUG & DEBUG_DRI)
-        fprintf(stderr, "%s ctx %p\n", __FUNCTION__, (void *)newCtx->glCtx);
-
-      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);
-        r200UpdateViewportOffset( newCtx->glCtx );
-      }
-
-      _mesa_make_current( newCtx->glCtx,
-                         (GLframebuffer *) driDrawPriv->driverPrivate,
-                         (GLframebuffer *) driReadPriv->driverPrivate );
-
-      _mesa_update_state( newCtx->glCtx );
-      r200ValidateState( newCtx->glCtx );
-
-   } else {
-      if (R200_DEBUG & DEBUG_DRI)
-        fprintf(stderr, "%s ctx is null\n", __FUNCTION__);
-      _mesa_make_current( NULL, NULL, NULL );
-   }
-
-   if (R200_DEBUG & DEBUG_DRI)
-      fprintf(stderr, "End %s\n", __FUNCTION__);
-   return GL_TRUE;
-}
-
-/* Force the context `c' to be unbound from its buffer.
- */
-GLboolean
-r200UnbindContext( __DRIcontextPrivate *driContextPriv )
-{
-   r200ContextPtr rmesa = (r200ContextPtr) driContextPriv->driverPrivate;
-
-   if (R200_DEBUG & DEBUG_DRI)
-      fprintf(stderr, "%s ctx %p\n", __FUNCTION__, (void *)rmesa->glCtx);
-
-   return GL_TRUE;
-}
index 14a1dda46ac0b3e869888e118e58aea4c6095007..6267293817d951d67a8987617d99e4f09f606001 100644 (file)
@@ -53,51 +53,17 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #error This driver requires a newer libdrm to compile
 #endif
 
+#include "radeon_screen.h"
+#include "radeon_common.h"
+
+#include "radeon_lock.h"
+
 struct r200_context;
 typedef struct r200_context r200ContextRec;
 typedef struct r200_context *r200ContextPtr;
 
-/* This union is used to avoid warnings/miscompilation
-   with float to uint32_t casts due to strict-aliasing */
-typedef union { GLfloat f; uint32_t ui32; } float_ui32_type;
-
-#include "r200_lock.h"
-#include "radeon_screen.h"
 #include "main/mm.h"
 
-/* Flags for software fallback cases */
-/* See correponding strings in r200_swtcl.c */
-#define R200_FALLBACK_TEXTURE           0x01
-#define R200_FALLBACK_DRAW_BUFFER       0x02
-#define R200_FALLBACK_STENCIL           0x04
-#define R200_FALLBACK_RENDER_MODE       0x08
-#define R200_FALLBACK_DISABLE           0x10
-#define R200_FALLBACK_BORDER_MODE       0x20
-
-/* The blit width for texture uploads
- */
-#define BLIT_WIDTH_BYTES 1024
-
-/* Use the templated vertex format:
- */
-#define COLOR_IS_RGBA
-#define TAG(x) r200##x
-#include "tnl_dd/t_dd_vertex.h"
-#undef TAG
-
-typedef void (*r200_tri_func)( r200ContextPtr,
-                                r200Vertex *,
-                                r200Vertex *,
-                                r200Vertex * );
-
-typedef void (*r200_line_func)( r200ContextPtr,
-                                 r200Vertex *,
-                                 r200Vertex * );
-
-typedef void (*r200_point_func)( r200ContextPtr,
-                                  r200Vertex * );
-
-
 struct r200_vertex_program {
         struct gl_vertex_program mesa_program; /* Must be first */
         int translated;
@@ -112,93 +78,11 @@ struct r200_vertex_program {
         int fogmode;
 };
 
-struct r200_colorbuffer_state {
-   GLuint clear;
-#if 000
-   GLint drawOffset, drawPitch;
-#endif
-   int roundEnable;
-};
-
-
-struct r200_depthbuffer_state {
-   GLuint clear;
-   GLfloat scale;
-};
-
-#if 000
-struct r200_pixel_state {
-   GLint readOffset, readPitch;
-};
-#endif
-
-struct r200_scissor_state {
-   drm_clip_rect_t rect;
-   GLboolean enabled;
-
-   GLuint numClipRects;                        /* Cliprects active */
-   GLuint numAllocedClipRects;         /* Cliprects available */
-   drm_clip_rect_t *pClipRects;
-};
-
-struct r200_stencilbuffer_state {
-   GLboolean hwBuffer;
-   GLuint clear;                       /* rb3d_stencilrefmask value */
-};
-
-struct r200_stipple_state {
-   GLuint mask[32];
-};
-
-
-
-#define TEX_0   0x1
-#define TEX_1   0x2
-#define TEX_2  0x4
-#define TEX_3  0x8
-#define TEX_4  0x10
-#define TEX_5  0x20
-#define TEX_ALL 0x3f
-
-typedef struct r200_tex_obj r200TexObj, *r200TexObjPtr;
-
-/* Texture object in locally shared texture space.
- */
-struct r200_tex_obj {
-   driTextureObject   base;
-
-   GLuint bufAddr;                     /* Offset to start of locally
-                                          shared texture block */
-
-   GLuint dirty_state;                 /* Flags (1 per texunit) for
-                                          whether or not this texobj
-                                          has dirty hardware state
-                                          (pp_*) that needs to be
-                                          brought into the
-                                          texunit. */
-
-   drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS];
-                                       /* Six, for the cube faces */
-   GLboolean image_override;           /* Image overridden by GLX_EXT_tfp */
-
-   GLuint pp_txfilter;                 /* hardware register values */
-   GLuint pp_txformat;
-   GLuint pp_txformat_x;
-   GLuint pp_txoffset;                 /* Image location in texmem.
-                                          All cube faces follow. */
-   GLuint pp_txsize;                   /* npot only */
-   GLuint pp_txpitch;                  /* npot only */
-   GLuint pp_border_color;
-   GLuint pp_cubic_faces;              /* cube face 1,2,3,4 log2 sizes */
-
-   GLboolean  border_fallback;
-
-   GLuint tile_bits;                   /* hw texture tile bits used on this texture */
-};
+#define R200_TEX_ALL 0x3f
 
 
 struct r200_texture_env_state {
-   r200TexObjPtr texobj;
+   radeonTexObjPtr texobj;
    GLuint outputreg;
    GLuint unitneeded;
 };
@@ -210,19 +94,6 @@ struct r200_texture_state {
 };
 
 
-struct r200_state_atom {
-   struct r200_state_atom *next, *prev;
-   const char *name;                    /* for debug */
-   int cmd_size;                        /* size in bytes */
-   GLuint idx;
-   int *cmd;                            /* one or more cmd's */
-   int *lastcmd;                        /* one or more cmd's */
-   GLboolean dirty;
-   GLboolean (*check)( GLcontext *, int );    /* is this state active? */
-};
-   
-
-
 /* Trying to keep these relatively short as the variables are becoming
  * extravagently long.  Drop the driver name prefix off the front of
  * everything - I think we know which driver we're in by now, and keep the
@@ -597,181 +468,79 @@ struct r200_state_atom {
 
 
 struct r200_hw_state {
-   /* Head of the linked list of state atoms. */
-   struct r200_state_atom atomlist;
-
    /* Hardware state, stored as cmdbuf commands:  
     *   -- Need to doublebuffer for
     *           - reviving state after loss of context
     *           - eliding noop statechange loops? (except line stipple count)
     */
-   struct r200_state_atom ctx;
-   struct r200_state_atom set;
-   struct r200_state_atom vte;
-   struct r200_state_atom lin;
-   struct r200_state_atom msk;
-   struct r200_state_atom vpt;
-   struct r200_state_atom vap;
-   struct r200_state_atom vtx;
-   struct r200_state_atom tcl;
-   struct r200_state_atom msl;
-   struct r200_state_atom tcg;
-   struct r200_state_atom msc;
-   struct r200_state_atom cst;
-   struct r200_state_atom tam;
-   struct r200_state_atom tf;
-   struct r200_state_atom tex[6];
-   struct r200_state_atom cube[6];
-   struct r200_state_atom zbs;
-   struct r200_state_atom mtl[2];
-   struct r200_state_atom mat[9];
-   struct r200_state_atom lit[8]; /* includes vec, scl commands */
-   struct r200_state_atom ucp[6];
-   struct r200_state_atom pix[6]; /* pixshader stages */
-   struct r200_state_atom eye; /* eye pos */
-   struct r200_state_atom grd; /* guard band clipping */
-   struct r200_state_atom fog;
-   struct r200_state_atom glt;
-   struct r200_state_atom prf;
-   struct r200_state_atom afs[2];
-   struct r200_state_atom pvs;
-   struct r200_state_atom vpi[2];
-   struct r200_state_atom vpp[2];
-   struct r200_state_atom atf;
-   struct r200_state_atom spr;
-   struct r200_state_atom ptp;
-
-   int max_state_size; /* Number of bytes necessary for a full state emit. */
-   GLboolean is_dirty, all_dirty;
+   struct radeon_state_atom ctx;
+   struct radeon_state_atom set;
+   struct radeon_state_atom vte;
+   struct radeon_state_atom lin;
+   struct radeon_state_atom msk;
+   struct radeon_state_atom vpt;
+   struct radeon_state_atom vap;
+   struct radeon_state_atom vtx;
+   struct radeon_state_atom tcl;
+   struct radeon_state_atom msl;
+   struct radeon_state_atom tcg;
+   struct radeon_state_atom msc;
+   struct radeon_state_atom cst;
+   struct radeon_state_atom tam;
+   struct radeon_state_atom tf;
+   struct radeon_state_atom tex[6];
+   struct radeon_state_atom cube[6];
+   struct radeon_state_atom zbs;
+   struct radeon_state_atom mtl[2];
+   struct radeon_state_atom mat[9];
+   struct radeon_state_atom lit[8]; /* includes vec, scl commands */
+   struct radeon_state_atom ucp[6];
+   struct radeon_state_atom pix[6]; /* pixshader stages */
+   struct radeon_state_atom eye; /* eye pos */
+   struct radeon_state_atom grd; /* guard band clipping */
+   struct radeon_state_atom fog;
+   struct radeon_state_atom glt;
+   struct radeon_state_atom prf;
+   struct radeon_state_atom afs[2];
+   struct radeon_state_atom pvs;
+   struct radeon_state_atom vpi[2];
+   struct radeon_state_atom vpp[2];
+   struct radeon_state_atom atf;
+   struct radeon_state_atom spr;
+   struct radeon_state_atom ptp;
 };
 
 struct r200_state {
    /* Derived state for internal purposes:
     */
-   struct r200_colorbuffer_state color;
-   struct r200_depthbuffer_state depth;
-#if 00
-   struct r200_pixel_state pixel;
-#endif
-   struct r200_scissor_state scissor;
-   struct r200_stencilbuffer_state stencil;
-   struct r200_stipple_state stipple;
+   struct radeon_stipple_state stipple;
    struct r200_texture_state texture;
    GLuint envneeded;
 };
 
-/* Need refcounting on dma buffers:
- */
-struct r200_dma_buffer {
-   int refcount;               /* the number of retained regions in buf */
-   drmBufPtr buf;
-};
-
-#define GET_START(rvb) (rmesa->r200Screen->gart_buffer_offset +                \
-                       (rvb)->address - rmesa->dma.buf0_address +      \
-                       (rvb)->start)
-
-/* A retained region, eg vertices for indexed vertices.
- */
-struct r200_dma_region {
-   struct r200_dma_buffer *buf;
-   char *address;              /* == buf->address */
-   int start, end, ptr;                /* offsets from start of buf */
-   int aos_start;
-   int aos_stride;
-   int aos_size;
-};
-
-
-struct r200_dma {
-   /* Active dma region.  Allocations for vertices and retained
-    * regions come from here.  Also used for emitting random vertices,
-    * these may be flushed by calling flush_current();
-    */
-   struct r200_dma_region current;
-   
-   void (*flush)( r200ContextPtr );
-
-   char *buf0_address;         /* start of buf[0], for index calcs */
-   GLuint nr_released_bufs;    /* flush after so many buffers released */
-};
-
-struct r200_dri_mirror {
-   __DRIcontextPrivate *context;       /* DRI context */
-   __DRIscreenPrivate  *screen;        /* DRI screen */
-   __DRIdrawablePrivate        *drawable;      /* DRI drawable bound to this ctx */
-   __DRIdrawablePrivate        *readable;      /* DRI readable bound to this ctx */
-
-   drm_context_t hwContext;
-   drm_hw_lock_t *hwLock;
-   int fd;
-   int drmMinor;
-};
-
-
 #define R200_CMD_BUF_SZ  (16*1024) 
 
-struct r200_store {
-   GLuint statenr;
-   GLuint primnr;
-   char cmd_buf[R200_CMD_BUF_SZ];
-   int cmd_used;   
-   int elts_start;
-};
-
-
+#define R200_ELT_BUF_SZ  (16*1024) 
 /* r200_tcl.c
  */
 struct r200_tcl_info {
    GLuint hw_primitive;
 
-/* hw can handle 12 components max */
-   struct r200_dma_region *aos_components[12];
-   GLuint nr_aos_components;
-
    GLuint *Elts;
 
-   struct r200_dma_region indexed_verts;
-   struct r200_dma_region vertex_data[15];
+   int elt_used;
+
 };
 
 
 /* r200_swtcl.c
  */
 struct r200_swtcl_info {
-   GLuint RenderIndex;
-   
-   /**
-    * Size of a hardware vertex.  This is calculated when \c ::vertex_attrs is
-    * installed in the Mesa state vector.
-    */
-   GLuint vertex_size;
 
-   /**
-    * Attributes instructing the Mesa TCL pipeline where / how to put vertex
-    * data in the hardware buffer.
-    */
-   struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
 
-   /**
-    * Number of elements of \c ::vertex_attrs that are actually used.
-    */
-   GLuint vertex_attr_count;
-
-   /**
-    * Cached pointer to the buffer where Mesa will store vertex data.
-    */
-   GLubyte *verts;
-
-   /* Fallback rasterization functions
-    */
-   r200_point_func draw_point;
-   r200_line_func draw_line;
-   r200_tri_func draw_tri;
-
-   GLuint hw_primitive;
-   GLenum render_primitive;
-   GLuint numverts;
+   radeon_point_func draw_point;
+   radeon_line_func draw_line;
+   radeon_tri_func draw_tri;
 
    /**
     * Offset of the 4UB color data within a hardware (swtcl) vertex.
@@ -787,27 +556,10 @@ struct r200_swtcl_info {
     * Should Mesa project vertex data or will the hardware do it?
     */
    GLboolean needproj;
-
-   struct r200_dma_region indexed_verts;
-};
-
-
-struct r200_ioctl {
-   GLuint vertex_offset;
-   GLuint vertex_size;
 };
 
 
 
-#define R200_MAX_PRIMS 64
-
-
-
-struct r200_prim {
-   GLuint start;
-   GLuint end;
-   GLuint prim;
-};
 
    /* A maximum total of 29 elements per vertex:  3 floats for position, 3
     * floats for normal, 4 floats for color, 4 bytes for secondary color,
@@ -822,9 +574,8 @@ struct r200_prim {
 
 #define R200_MAX_VERTEX_SIZE ((3*6)+11)
 
-
 struct r200_context {
-   GLcontext *glCtx;                   /* Mesa context */
+   struct radeon_context radeon;
 
    /* Driver and hardware state management
     */
@@ -832,56 +583,15 @@ struct r200_context {
    struct r200_state state;
    struct r200_vertex_program *curr_vp_hw;
 
-   /* Texture object bookkeeping
-    */
-   unsigned              nr_heaps;
-   driTexHeap          * texture_heaps[ RADEON_NR_TEX_HEAPS ];
-   driTextureObject      swapped;
-   int                   texture_depth;
-   float                 initialMaxAnisotropy;
-
-   /* Rasterization and vertex state:
-    */
-   GLuint TclFallback;
-   GLuint Fallback;
-   GLuint NewGLState;
-   DECLARE_RENDERINPUTS(tnl_index_bitset);     /* index of bits for last tnl_install_attrs */
-
    /* Vertex buffers
     */
-   struct r200_ioctl ioctl;
-   struct r200_dma dma;
-   struct r200_store store;
-   /* A full state emit as of the first state emit in the main store, in case
-    * the context is lost.
-    */
-   struct r200_store backup_store;
-
-   /* Page flipping
-    */
-   GLuint doPageFlip;
-
-   /* Busy waiting
-    */
-   GLuint do_usleeps;
-   GLuint do_irqs;
-   GLuint irqsEmitted;
-   drm_radeon_irq_wait_t iw;
+   struct radeon_ioctl ioctl;
+   struct radeon_store store;
 
    /* Clientdata textures;
     */
    GLuint prefer_gart_client_texturing;
 
-   /* Drawable, cliprect and scissor information
-    */
-   GLuint numClipRects;                        /* Cliprects for the draw buffer */
-   drm_clip_rect_t *pClipRects;
-   unsigned int lastStamp;
-   GLboolean lost_context;
-   GLboolean save_on_next_emit;
-   radeonScreenPtr r200Screen; /* Screen private DRI data */
-   drm_radeon_sarea_t *sarea;          /* Private SAREA data */
-
    /* TCL stuff
     */
    GLmatrix TexGenMatrix[R200_MAX_TEXTURE_UNITS];
@@ -893,15 +603,6 @@ struct r200_context {
    GLuint TexGenCompSel;
    GLmatrix tmpmat;
 
-   /* buffer swap
-    */
-   int64_t swap_ust;
-   int64_t swap_missed_ust;
-
-   GLuint swap_count;
-   GLuint swap_missed_count;
-
-
    /* r200_tcl.c
     */
    struct r200_tcl_info tcl;
@@ -910,14 +611,6 @@ struct r200_context {
     */
    struct r200_swtcl_info swtcl;
 
-   /* Mirrors of some DRI state
-    */
-   struct r200_dri_mirror dri;
-
-   /* Configuration cache
-    */
-   driOptionCache optionCache;
-
    GLboolean using_hyperz;
    GLboolean texmicrotile;
 
@@ -927,28 +620,10 @@ struct r200_context {
 #define R200_CONTEXT(ctx)              ((r200ContextPtr)(ctx->DriverCtx))
 
 
-static INLINE GLuint r200PackColor( GLuint cpp,
-                                       GLubyte r, GLubyte g,
-                                       GLubyte b, GLubyte a )
-{
-   switch ( cpp ) {
-   case 2:
-      return PACK_COLOR_565( r, g, b );
-   case 4:
-      return PACK_COLOR_8888( a, r, g, b );
-   default:
-      return 0;
-   }
-}
-
-
 extern void r200DestroyContext( __DRIcontextPrivate *driContextPriv );
 extern GLboolean r200CreateContext( const __GLcontextModes *glVisual,
                                    __DRIcontextPrivate *driContextPriv,
                                    void *sharedContextPrivate);
-extern void r200SwapBuffers( __DRIdrawablePrivate *dPriv );
-extern void r200CopySubBuffer( __DRIdrawablePrivate * dPriv,
-                              int x, int y, int w, int h );
 extern GLboolean r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
                                  __DRIdrawablePrivate *driDrawPriv,
                                  __DRIdrawablePrivate *driReadPriv );
@@ -957,28 +632,9 @@ extern GLboolean r200UnbindContext( __DRIcontextPrivate *driContextPriv );
 /* ================================================================
  * Debugging:
  */
-#define DO_DEBUG               1
 
-#if DO_DEBUG
-extern int R200_DEBUG;
-#else
-#define R200_DEBUG             0
-#endif
+#define R200_DEBUG RADEON_DEBUG
+
 
-#define DEBUG_TEXTURE  0x001
-#define DEBUG_STATE    0x002
-#define DEBUG_IOCTL    0x004
-#define DEBUG_PRIMS    0x008
-#define DEBUG_VERTS    0x010
-#define DEBUG_FALLBACKS        0x020
-#define DEBUG_VFMT     0x040
-#define DEBUG_CODEGEN  0x080
-#define DEBUG_VERBOSE  0x100
-#define DEBUG_DRI       0x200
-#define DEBUG_DMA       0x400
-#define DEBUG_SANITY    0x800
-#define DEBUG_SYNC      0x1000
-#define DEBUG_PIXEL     0x2000
-#define DEBUG_MEMORY    0x4000
 
 #endif /* __R200_CONTEXT_H__ */
index d514b28219ade521136ef3478e97f0178090dbd1..85c1b7bdd19426bcdb5072abe15373a0b77874d2 100644 (file)
@@ -522,7 +522,7 @@ static void r200UpdateFSConstants( GLcontext *ctx )
         CLAMPED_FLOAT_TO_UBYTE(con_byte[2], ctx->ATIFragmentShader.GlobalConstants[i][2]);
         CLAMPED_FLOAT_TO_UBYTE(con_byte[3], ctx->ATIFragmentShader.GlobalConstants[i][3]);
       }
-      rmesa->hw.atf.cmd[ATF_TFACTOR_0 + i] = r200PackColor (
+      rmesa->hw.atf.cmd[ATF_TFACTOR_0 + i] = radeonPackColor (
         4, con_byte[0], con_byte[1], con_byte[2], con_byte[3] );
    }
 }
index 0741e57af717dcfd599f5e21f08d7ddb53225f2b..0b3398a730e15d004c133e447db81760fc398f93 100644 (file)
@@ -31,7 +31,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  * Authors:
  *   Keith Whitwell <keith@tungstengraphics.com>
  */
+
 #include <sched.h>
 #include <errno.h>
 
@@ -41,6 +41,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/context.h"
 #include "swrast/swrast.h"
 
+
+
+#include "radeon_common.h"
+#include "radeon_lock.h"
 #include "r200_context.h"
 #include "r200_state.h"
 #include "r200_ioctl.h"
@@ -54,635 +58,19 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define R200_TIMEOUT             512
 #define R200_IDLE_RETRY           16
 
-
-static void r200WaitForIdle( r200ContextPtr rmesa );
-
-
-/* At this point we were in FlushCmdBufLocked but we had lost our context, so
- * we need to unwire our current cmdbuf, hook the one with the saved state in
- * it, flush it, and then put the current one back.  This is so commands at the
- * start of a cmdbuf can rely on the state being kept from the previous one.
- */
-static void r200BackUpAndEmitLostStateLocked( r200ContextPtr rmesa )
-{
-   GLuint nr_released_bufs;
-   struct r200_store saved_store;
-
-   if (rmesa->backup_store.cmd_used == 0)
-      return;
-
-   if (R200_DEBUG & DEBUG_STATE)
-      fprintf(stderr, "Emitting backup state on lost context\n");
-
-   rmesa->lost_context = GL_FALSE;
-
-   nr_released_bufs = rmesa->dma.nr_released_bufs;
-   saved_store = rmesa->store;
-   rmesa->dma.nr_released_bufs = 0;
-   rmesa->store = rmesa->backup_store;
-   r200FlushCmdBufLocked( rmesa, __FUNCTION__ );
-   rmesa->dma.nr_released_bufs = nr_released_bufs;
-   rmesa->store = saved_store;
-}
-
-int r200FlushCmdBufLocked( r200ContextPtr rmesa, const char * caller )
-{
-   int ret, i;
-   drm_radeon_cmd_buffer_t cmd;
-
-   if (rmesa->lost_context)
-      r200BackUpAndEmitLostStateLocked( rmesa );
-
-   if (R200_DEBUG & DEBUG_IOCTL) {
-      fprintf(stderr, "%s from %s\n", __FUNCTION__, caller); 
-
-      if (0 & R200_DEBUG & DEBUG_VERBOSE) 
-        for (i = 0 ; i < rmesa->store.cmd_used ; i += 4 )
-           fprintf(stderr, "%d: %x\n", i/4, 
-                   *(int *)(&rmesa->store.cmd_buf[i]));
-   }
-
-   if (R200_DEBUG & DEBUG_DMA)
-      fprintf(stderr, "%s: Releasing %d buffers\n", __FUNCTION__,
-             rmesa->dma.nr_released_bufs);
-
-
-   if (R200_DEBUG & DEBUG_SANITY) {
-      if (rmesa->state.scissor.enabled) 
-        ret = r200SanityCmdBuffer( rmesa, 
-                                   rmesa->state.scissor.numClipRects,
-                                   rmesa->state.scissor.pClipRects);
-      else
-        ret = r200SanityCmdBuffer( rmesa, 
-                                   rmesa->numClipRects,
-                                   rmesa->pClipRects);
-      if (ret) {
-        fprintf(stderr, "drmSanityCommandWrite: %d\n", ret);    
-        goto out;
-      }
-   }
-
-
-   if (R200_DEBUG & DEBUG_MEMORY) {
-      if (! driValidateTextureHeaps( rmesa->texture_heaps, rmesa->nr_heaps,
-                                    & rmesa->swapped ) ) {
-        fprintf( stderr, "%s: texture memory is inconsistent - expect "
-                 "mangled textures\n", __FUNCTION__ );
-      }
-   }
-
-
-   cmd.bufsz = rmesa->store.cmd_used;
-   cmd.buf = rmesa->store.cmd_buf;
-
-   if (rmesa->state.scissor.enabled) {
-      cmd.nbox = rmesa->state.scissor.numClipRects;
-      cmd.boxes = (drm_clip_rect_t *)rmesa->state.scissor.pClipRects;
-   } else {
-      cmd.nbox = rmesa->numClipRects;
-      cmd.boxes = (drm_clip_rect_t *)rmesa->pClipRects;
-   }
-
-   ret = drmCommandWrite( rmesa->dri.fd,
-                         DRM_RADEON_CMDBUF,
-                         &cmd, sizeof(cmd) );
-
-   if (ret)
-      fprintf(stderr, "drmCommandWrite: %d\n", ret);
-
-   if (R200_DEBUG & DEBUG_SYNC) {
-      fprintf(stderr, "\nSyncing in %s\n\n", __FUNCTION__);
-      r200WaitForIdleLocked( rmesa );
-   }
-
-
- out:
-   rmesa->store.primnr = 0;
-   rmesa->store.statenr = 0;
-   rmesa->store.cmd_used = 0;
-   rmesa->dma.nr_released_bufs = 0;
-   rmesa->save_on_next_emit = 1;
-
-   return ret;
-}
-
-
-/* Note: does not emit any commands to avoid recursion on
- * r200AllocCmdBuf.
- */
-void r200FlushCmdBuf( r200ContextPtr rmesa, const char *caller )
-{
-   int ret;
-
-   LOCK_HARDWARE( rmesa );
-
-   ret = r200FlushCmdBufLocked( rmesa, caller );
-
-   UNLOCK_HARDWARE( rmesa );
-
-   if (ret) {
-      fprintf(stderr, "drmRadeonCmdBuffer: %d (exiting)\n", ret);
-      exit(ret);
-   }
-}
-
-
-/* =============================================================
- * Hardware vertex buffer handling
- */
-
-
-void r200RefillCurrentDmaRegion( r200ContextPtr rmesa )
-{
-   struct r200_dma_buffer *dmabuf;
-   int fd = rmesa->dri.fd;
-   int index = 0;
-   int size = 0;
-   drmDMAReq dma;
-   int ret;
-
-   if (R200_DEBUG & (DEBUG_IOCTL|DEBUG_DMA))
-      fprintf(stderr, "%s\n", __FUNCTION__);  
-
-   if (rmesa->dma.flush) {
-      rmesa->dma.flush( rmesa );
-   }
-
-   if (rmesa->dma.current.buf)
-      r200ReleaseDmaRegion( rmesa, &rmesa->dma.current, __FUNCTION__ );
-
-   if (rmesa->dma.nr_released_bufs > 4)
-      r200FlushCmdBuf( rmesa, __FUNCTION__ );
-
-   dma.context = rmesa->dri.hwContext;
-   dma.send_count = 0;
-   dma.send_list = NULL;
-   dma.send_sizes = NULL;
-   dma.flags = 0;
-   dma.request_count = 1;
-   dma.request_size = RADEON_BUFFER_SIZE;
-   dma.request_list = &index;
-   dma.request_sizes = &size;
-   dma.granted_count = 0;
-
-   LOCK_HARDWARE(rmesa);       /* no need to validate */
-
-   while (1) {
-      ret = drmDMA( fd, &dma );
-      if (ret == 0)
-        break;
-   
-      if (rmesa->dma.nr_released_bufs) {
-        r200FlushCmdBufLocked( rmesa, __FUNCTION__ );
-      }
-
-      if (rmesa->do_usleeps) {
-        UNLOCK_HARDWARE( rmesa );
-        DO_USLEEP( 1 );
-        LOCK_HARDWARE( rmesa );
-      }
-   }
-
-   UNLOCK_HARDWARE(rmesa);
-
-   if (R200_DEBUG & DEBUG_DMA)
-      fprintf(stderr, "Allocated buffer %d\n", index);
-
-   dmabuf = CALLOC_STRUCT( r200_dma_buffer );
-   dmabuf->buf = &rmesa->r200Screen->buffers->list[index];
-   dmabuf->refcount = 1;
-
-   rmesa->dma.current.buf = dmabuf;
-   rmesa->dma.current.address = dmabuf->buf->address;
-   rmesa->dma.current.end = dmabuf->buf->total;
-   rmesa->dma.current.start = 0;
-   rmesa->dma.current.ptr = 0;
-}
-
-void r200ReleaseDmaRegion( r200ContextPtr rmesa,
-                            struct r200_dma_region *region,
-                            const char *caller )
-{
-   if (R200_DEBUG & DEBUG_IOCTL)
-      fprintf(stderr, "%s from %s\n", __FUNCTION__, caller); 
-   
-   if (!region->buf)
-      return;
-
-   if (rmesa->dma.flush)
-      rmesa->dma.flush( rmesa );
-
-   if (--region->buf->refcount == 0) {
-      drm_radeon_cmd_header_t *cmd;
-
-      if (R200_DEBUG & (DEBUG_IOCTL|DEBUG_DMA))
-        fprintf(stderr, "%s -- DISCARD BUF %d\n", __FUNCTION__,
-                region->buf->buf->idx);  
-      
-      cmd = (drm_radeon_cmd_header_t *)r200AllocCmdBuf( rmesa, sizeof(*cmd), 
-                                                    __FUNCTION__ );
-      cmd->dma.cmd_type = RADEON_CMD_DMA_DISCARD;
-      cmd->dma.buf_idx = region->buf->buf->idx;
-      FREE(region->buf);
-      rmesa->dma.nr_released_bufs++;
-   }
-
-   region->buf = NULL;
-   region->start = 0;
-}
-
-/* Allocates a region from rmesa->dma.current.  If there isn't enough
- * space in current, grab a new buffer (and discard what was left of current)
- */
-void r200AllocDmaRegion( r200ContextPtr rmesa, 
-                          struct r200_dma_region *region,
-                          int bytes,
-                          int alignment )
-{
-   if (R200_DEBUG & DEBUG_IOCTL)
-      fprintf(stderr, "%s %d\n", __FUNCTION__, bytes);
-
-   if (rmesa->dma.flush)
-      rmesa->dma.flush( rmesa );
-
-   if (region->buf)
-      r200ReleaseDmaRegion( rmesa, region, __FUNCTION__ );
-
-   alignment--;
-   rmesa->dma.current.start = rmesa->dma.current.ptr = 
-      (rmesa->dma.current.ptr + alignment) & ~alignment;
-
-   if ( rmesa->dma.current.ptr + bytes > rmesa->dma.current.end ) 
-      r200RefillCurrentDmaRegion( rmesa );
-
-   region->start = rmesa->dma.current.start;
-   region->ptr = rmesa->dma.current.start;
-   region->end = rmesa->dma.current.start + bytes;
-   region->address = rmesa->dma.current.address;
-   region->buf = rmesa->dma.current.buf;
-   region->buf->refcount++;
-
-   rmesa->dma.current.ptr += bytes; /* bug - if alignment > 7 */
-   rmesa->dma.current.start = 
-      rmesa->dma.current.ptr = (rmesa->dma.current.ptr + 0x7) & ~0x7;  
-
-   assert( rmesa->dma.current.ptr <= rmesa->dma.current.end );
-}
-
-/* ================================================================
- * SwapBuffers with client-side throttling
- */
-
-static uint32_t r200GetLastFrame(r200ContextPtr rmesa)
-{
-   drm_radeon_getparam_t gp;
-   int ret;
-   uint32_t frame;
-
-   gp.param = RADEON_PARAM_LAST_FRAME;
-   gp.value = (int *)&frame;
-   ret = drmCommandWriteRead( rmesa->dri.fd, DRM_RADEON_GETPARAM,
-                             &gp, sizeof(gp) );
-   if ( ret ) {
-      fprintf( stderr, "%s: drmRadeonGetParam: %d\n", __FUNCTION__, ret );
-      exit(1);
-   }
-
-   return frame;
-}
-
-static void r200EmitIrqLocked( r200ContextPtr rmesa )
-{
-   drm_radeon_irq_emit_t ie;
-   int ret;
-
-   ie.irq_seq = &rmesa->iw.irq_seq;
-   ret = drmCommandWriteRead( rmesa->dri.fd, DRM_RADEON_IRQ_EMIT, 
-                             &ie, sizeof(ie) );
-   if ( ret ) {
-      fprintf( stderr, "%s: drmRadeonIrqEmit: %d\n", __FUNCTION__, ret );
-      exit(1);
-   }
-}
-
-
-static void r200WaitIrq( r200ContextPtr rmesa )
-{
-   int ret;
-
-   do {
-      ret = drmCommandWrite( rmesa->dri.fd, DRM_RADEON_IRQ_WAIT,
-                            &rmesa->iw, sizeof(rmesa->iw) );
-   } while (ret && (errno == EINTR || errno == EBUSY));
-
-   if ( ret ) {
-      fprintf( stderr, "%s: drmRadeonIrqWait: %d\n", __FUNCTION__, ret );
-      exit(1);
-   }
-}
-
-
-static void r200WaitForFrameCompletion( r200ContextPtr rmesa )
-{
-   drm_radeon_sarea_t *sarea = rmesa->sarea;
-
-   if (rmesa->do_irqs) {
-      if (r200GetLastFrame(rmesa) < sarea->last_frame) {
-        if (!rmesa->irqsEmitted) {
-           while (r200GetLastFrame (rmesa) < sarea->last_frame)
-              ;
-        }
-        else {
-           UNLOCK_HARDWARE( rmesa ); 
-           r200WaitIrq( rmesa );       
-           LOCK_HARDWARE( rmesa ); 
-        }
-        rmesa->irqsEmitted = 10;
-      }
-
-      if (rmesa->irqsEmitted) {
-        r200EmitIrqLocked( rmesa );
-        rmesa->irqsEmitted--;
-      }
-   } 
-   else {
-      while (r200GetLastFrame (rmesa) < sarea->last_frame) {
-        UNLOCK_HARDWARE( rmesa ); 
-        if (rmesa->do_usleeps) 
-           DO_USLEEP( 1 );
-        LOCK_HARDWARE( rmesa ); 
-      }
-   }
-}
-
-
-
-/* Copy the back color buffer to the front color buffer.
- */
-void r200CopyBuffer( __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);
-   assert(dPriv->driContextPriv->driverPrivate);
-
-   rmesa = (r200ContextPtr) dPriv->driContextPriv->driverPrivate;
-
-   if ( R200_DEBUG & DEBUG_IOCTL ) {
-      fprintf( stderr, "\n%s( %p )\n\n", __FUNCTION__, (void *)rmesa->glCtx );
-   }
-
-   R200_FIREVERTICES( rmesa );
-
-   LOCK_HARDWARE( rmesa );
-
-
-   /* Throttle the frame rate -- only allow one pending swap buffers
-    * request at a time.
-    */
-   r200WaitForFrameCompletion( rmesa );
-   if (!rect)
-   {
-       UNLOCK_HARDWARE( rmesa );
-       driWaitForVBlank( dPriv, & missed_target );
-       LOCK_HARDWARE( rmesa );
-   }
-
-   nbox = dPriv->numClipRects; /* must be in locked region */
-
-   for ( i = 0 ; i < nbox ; ) {
-      GLint nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS , nbox );
-      drm_clip_rect_t *box = dPriv->pClipRects;
-      drm_clip_rect_t *b = rmesa->sarea->boxes;
-      GLint n = 0;
-
-      for ( ; i < nr ; i++ ) {
-
-         *b = box[i];
-
-         if (rect)
-         {
-            if (rect->x1 > b->x1)
-                b->x1 = rect->x1;
-            if (rect->y1 > b->y1)
-                b->y1 = rect->y1;
-            if (rect->x2 < b->x2)
-                b->x2 = rect->x2;
-            if (rect->y2 < b->y2)
-                b->y2 = rect->y2;
-
-            if (b->x1 >= b->x2 || b->y1 >= b->y2)
-                continue;
-         }
-
-         b++;
-         n++;
-      }
-      rmesa->sarea->nbox = n;
-
-      if (!n)
-        continue;
-
-      ret = drmCommandNone( rmesa->dri.fd, DRM_RADEON_SWAP );
-
-      if ( ret ) {
-        fprintf( stderr, "DRM_R200_SWAP_BUFFERS: return = %d\n", ret );
-        UNLOCK_HARDWARE( rmesa );
-        exit( 1 );
-      }
-   }
-
-   UNLOCK_HARDWARE( rmesa );
-   if (!rect)
-   {
-       rmesa->hw.all_dirty = GL_TRUE;
-
-       rmesa->swap_count++;
-       (*psp->systemTime->getUST)( & ust );
-       if ( missed_target ) {
-          rmesa->swap_missed_count++;
-          rmesa->swap_missed_ust = ust - rmesa->swap_ust;
-       }
-
-       rmesa->swap_ust = ust;
-
-       sched_yield();
-   }
-}
-
-void r200PageFlip( __DRIdrawablePrivate *dPriv )
+static void r200UserClear(GLcontext *ctx, GLuint mask)
 {
-   r200ContextPtr rmesa;
-   GLint ret;
-   GLboolean   missed_target;
-   __DRIscreenPrivate *psp = dPriv->driScreenPriv;
-
-   assert(dPriv);
-   assert(dPriv->driContextPriv);
-   assert(dPriv->driContextPriv->driverPrivate);
-
-   rmesa = (r200ContextPtr) dPriv->driContextPriv->driverPrivate;
-
-   if ( R200_DEBUG & DEBUG_IOCTL ) {
-      fprintf(stderr, "%s: pfCurrentPage: %d\n", __FUNCTION__,
-             rmesa->sarea->pfCurrentPage);
-   }
-
-   R200_FIREVERTICES( rmesa );
-   LOCK_HARDWARE( rmesa );
-
-   if (!dPriv->numClipRects) {
-      UNLOCK_HARDWARE( rmesa );
-      usleep( 10000 );         /* throttle invisible client 10ms */
-      return;
-   }
-
-   /* Need to do this for the perf box placement:
-    */
-   {
-      drm_clip_rect_t *box = dPriv->pClipRects;
-      drm_clip_rect_t *b = rmesa->sarea->boxes;
-      b[0] = box[0];
-      rmesa->sarea->nbox = 1;
-   }
-
-   /* Throttle the frame rate -- only allow a few pending swap buffers
-    * request at a time.
-    */
-   r200WaitForFrameCompletion( rmesa );
-   UNLOCK_HARDWARE( rmesa );
-   driWaitForVBlank( dPriv, & missed_target );
-   if ( missed_target ) {
-      rmesa->swap_missed_count++;
-      (void) (*psp->systemTime->getUST)( & rmesa->swap_missed_ust );
-   }
-   LOCK_HARDWARE( rmesa );
-
-   ret = drmCommandNone( rmesa->dri.fd, DRM_RADEON_FLIP );
-
-   UNLOCK_HARDWARE( rmesa );
-
-   if ( ret ) {
-      fprintf( stderr, "DRM_RADEON_FLIP: return = %d\n", ret );
-      exit( 1 );
-   }
-
-   rmesa->swap_count++;
-   (void) (*psp->systemTime->getUST)( & rmesa->swap_ust );
-
-#if 000
-   if ( rmesa->sarea->pfCurrentPage == 1 ) {
-        rmesa->state.color.drawOffset = rmesa->r200Screen->frontOffset;
-        rmesa->state.color.drawPitch  = rmesa->r200Screen->frontPitch;
-   } else {
-        rmesa->state.color.drawOffset = rmesa->r200Screen->backOffset;
-        rmesa->state.color.drawPitch  = rmesa->r200Screen->backPitch;
-   }
-
-   R200_STATECHANGE( rmesa, ctx );
-   rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = rmesa->state.color.drawOffset
-                                          + rmesa->r200Screen->fbLocation;
-   rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH]  = rmesa->state.color.drawPitch;
-   if (rmesa->sarea->tiling_enabled) {
-      rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= R200_COLOR_TILE_ENABLE;
-   }
-#else
-   /* Get ready for drawing next frame.  Update the renderbuffers'
-    * flippedOffset/Pitch fields so we draw into the right place.
-    */
-   driFlipRenderbuffers(rmesa->glCtx->WinSysDrawBuffer,
-                        rmesa->sarea->pfCurrentPage);
-
-
-   r200UpdateDrawBuffer(rmesa->glCtx);
-#endif
+   radeon_clear_tris(ctx, mask);
 }
 
-
-/* ================================================================
- * Buffer clear
- */
-static void r200Clear( GLcontext *ctx, GLbitfield mask )
+static void r200KernelClear(GLcontext *ctx, GLuint flags)
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
-   GLuint flags = 0;
-   GLuint color_mask = 0;
-   GLint ret, i;
-   GLint cx, cy, cw, ch;
-
-   if ( R200_DEBUG & DEBUG_IOCTL ) {
-      fprintf( stderr, "r200Clear\n");
-   }
-
-   {
-      LOCK_HARDWARE( rmesa );
-      UNLOCK_HARDWARE( rmesa );
-      if ( dPriv->numClipRects == 0 ) 
-        return;
-   }
-
-   r200Flush( ctx );
-
-   if ( mask & BUFFER_BIT_FRONT_LEFT ) {
-      flags |= RADEON_FRONT;
-      color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
-      mask &= ~BUFFER_BIT_FRONT_LEFT;
-   }
-
-   if ( mask & BUFFER_BIT_BACK_LEFT ) {
-      flags |= RADEON_BACK;
-      color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
-      mask &= ~BUFFER_BIT_BACK_LEFT;
-   }
+   __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
+   GLint cx, cy, cw, ch, ret;
+   GLuint i;
 
-   if ( mask & BUFFER_BIT_DEPTH ) {
-      flags |= RADEON_DEPTH;
-      mask &= ~BUFFER_BIT_DEPTH;
-   }
-
-   if ( (mask & BUFFER_BIT_STENCIL) && rmesa->state.stencil.hwBuffer ) {
-      flags |= RADEON_STENCIL;
-      mask &= ~BUFFER_BIT_STENCIL;
-   }
-
-   if ( mask ) {
-      if (R200_DEBUG & DEBUG_FALLBACKS)
-        fprintf(stderr, "%s: swrast clear, mask: %x\n", __FUNCTION__, mask);
-      _swrast_Clear( ctx, mask );
-   }
-
-   if ( !flags ) 
-      return;
-
-   if (rmesa->using_hyperz) {
-      flags |= RADEON_USE_COMP_ZBUF;
-/*      if (rmesa->r200Screen->chip_family == CHIP_FAMILY_R200)
-        flags |= RADEON_USE_HIERZ; */
-      if (!(rmesa->state.stencil.hwBuffer) ||
-        ((flags & RADEON_DEPTH) && (flags & RADEON_STENCIL) &&
-           ((rmesa->state.stencil.clear & R200_STENCIL_WRITE_MASK) == R200_STENCIL_WRITE_MASK))) {
-         flags |= RADEON_CLEAR_FASTZ;
-      }
-   }
-
-   LOCK_HARDWARE( rmesa );
-
-   /* compute region after locking: */
-   cx = ctx->DrawBuffer->_Xmin;
-   cy = ctx->DrawBuffer->_Ymin;
-   cw = ctx->DrawBuffer->_Xmax - cx;
-   ch = ctx->DrawBuffer->_Ymax - cy;
-
-   /* Flip top to bottom */
-   cx += dPriv->x;
-   cy  = dPriv->y + dPriv->h - cy - ch;
+   LOCK_HARDWARE( &rmesa->radeon );
 
    /* Throttle the number of clear ioctls we do.
     */
@@ -693,7 +81,7 @@ static void r200Clear( GLcontext *ctx, GLbitfield mask )
 
       gp.param = RADEON_PARAM_LAST_CLEAR;
       gp.value = (int *)&clear;
-      ret = drmCommandWriteRead( rmesa->dri.fd,
+      ret = drmCommandWriteRead( rmesa->radeon.dri.fd,
                      DRM_RADEON_GETPARAM, &gp, sizeof(gp) );
 
       if ( ret ) {
@@ -703,24 +91,34 @@ static void r200Clear( GLcontext *ctx, GLbitfield mask )
 
       /* Clear throttling needs more thought.
        */
-      if ( rmesa->sarea->last_clear - clear <= 25 ) {
+      if ( rmesa->radeon.sarea->last_clear - clear <= 25 ) {
         break;
       }
-      
-      if (rmesa->do_usleeps) {
-        UNLOCK_HARDWARE( rmesa );
+
+      if (rmesa->radeon.do_usleeps) {
+        UNLOCK_HARDWARE( &rmesa->radeon );
         DO_USLEEP( 1 );
-        LOCK_HARDWARE( rmesa );
+        LOCK_HARDWARE( &rmesa->radeon );
       }
    }
 
    /* Send current state to the hardware */
-   r200FlushCmdBufLocked( rmesa, __FUNCTION__ );
+   rcommonFlushCmdBufLocked( &rmesa->radeon, __FUNCTION__ );
+
+
+  /* compute region after locking: */
+   cx = ctx->DrawBuffer->_Xmin;
+   cy = ctx->DrawBuffer->_Ymin;
+   cw = ctx->DrawBuffer->_Xmax - cx;
+   ch = ctx->DrawBuffer->_Ymax - cy;
 
+   /* Flip top to bottom */
+   cx += dPriv->x;
+   cy  = dPriv->y + dPriv->h - cy - ch;
    for ( i = 0 ; i < dPriv->numClipRects ; ) {
       GLint nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS, dPriv->numClipRects );
       drm_clip_rect_t *box = dPriv->pClipRects;
-      drm_clip_rect_t *b = rmesa->sarea->boxes;
+      drm_clip_rect_t *b = rmesa->radeon.sarea->boxes;
       drm_radeon_clear_t clear;
       drm_radeon_clear_rect_t depth_boxes[RADEON_NR_SAREA_CLIPRECTS];
       GLint n = 0;
@@ -755,17 +153,17 @@ static void r200Clear( GLcontext *ctx, GLbitfield mask )
         }
       }
 
-      rmesa->sarea->nbox = n;
+      rmesa->radeon.sarea->nbox = n;
 
       clear.flags       = flags;
-      clear.clear_color = rmesa->state.color.clear;
-      clear.clear_depth = rmesa->state.depth.clear;    /* needed for hyperz */
+      clear.clear_color = rmesa->radeon.state.color.clear;
+      clear.clear_depth = rmesa->radeon.state.depth.clear;     /* needed for hyperz */
       clear.color_mask  = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
-      clear.depth_mask  = rmesa->state.stencil.clear;
+      clear.depth_mask  = rmesa->radeon.state.stencil.clear;
       clear.depth_boxes = depth_boxes;
 
       n--;
-      b = rmesa->sarea->boxes;
+      b = rmesa->radeon.sarea->boxes;
       for ( ; n >= 0 ; n-- ) {
         depth_boxes[n].f[CLEAR_X1] = (float)b[n].x1;
         depth_boxes[n].f[CLEAR_Y1] = (float)b[n].y1;
@@ -774,84 +172,91 @@ static void r200Clear( GLcontext *ctx, GLbitfield mask )
         depth_boxes[n].f[CLEAR_DEPTH] = ctx->Depth.Clear;
       }
 
-      ret = drmCommandWrite( rmesa->dri.fd, DRM_RADEON_CLEAR,
+      ret = drmCommandWrite( rmesa->radeon.dri.fd, DRM_RADEON_CLEAR,
                             &clear, sizeof(clear));
 
 
       if ( ret ) {
-        UNLOCK_HARDWARE( rmesa );
+        UNLOCK_HARDWARE( &rmesa->radeon );
         fprintf( stderr, "DRM_RADEON_CLEAR: return = %d\n", ret );
         exit( 1 );
       }
    }
-
-   UNLOCK_HARDWARE( rmesa );
-   rmesa->hw.all_dirty = GL_TRUE;
+   UNLOCK_HARDWARE( &rmesa->radeon );
 }
+/* ================================================================
+ * Buffer clear
+ */
+static void r200Clear( GLcontext *ctx, GLbitfield mask )
+{
+   r200ContextPtr rmesa = R200_CONTEXT(ctx);
+   __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
+   GLuint flags = 0;
+   GLuint color_mask = 0;
+   GLuint orig_mask = mask;
 
+   if ( R200_DEBUG & DEBUG_IOCTL ) {
+       fprintf( stderr, "r200Clear %x %d\n", mask, rmesa->radeon.sarea->pfCurrentPage);
+   }
 
-void r200WaitForIdleLocked( r200ContextPtr rmesa )
-{
-    int ret;
-    int i = 0;
-    
-    do {
-       ret = drmCommandNone( rmesa->dri.fd, DRM_RADEON_CP_IDLE);
-       if (ret) 
-         DO_USLEEP( 1 );
-    } while (ret && ++i < 100);
-    
-    if ( ret < 0 ) {
-       UNLOCK_HARDWARE( rmesa );
-       fprintf( stderr, "Error: R200 timed out... exiting\n" );
-       exit( -1 );
-    }
-}
+   {
+      LOCK_HARDWARE( &rmesa->radeon );
+      UNLOCK_HARDWARE( &rmesa->radeon );
+      if ( dPriv->numClipRects == 0 )
+        return;
+   }
 
+   radeonFlush( ctx );
 
-static void r200WaitForIdle( r200ContextPtr rmesa )
-{
-   LOCK_HARDWARE(rmesa);
-   r200WaitForIdleLocked( rmesa );
-   UNLOCK_HARDWARE(rmesa);
-}
+   if ( mask & BUFFER_BIT_FRONT_LEFT ) {
+      flags |= RADEON_FRONT;
+      color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
+      mask &= ~BUFFER_BIT_FRONT_LEFT;
+   }
 
+   if ( mask & BUFFER_BIT_BACK_LEFT ) {
+      flags |= RADEON_BACK;
+      color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
+      mask &= ~BUFFER_BIT_BACK_LEFT;
+   }
 
-void r200Flush( GLcontext *ctx )
-{
-   r200ContextPtr rmesa = R200_CONTEXT( ctx );
+   if ( mask & BUFFER_BIT_DEPTH ) {
+      flags |= RADEON_DEPTH;
+      mask &= ~BUFFER_BIT_DEPTH;
+   }
 
-   if (R200_DEBUG & DEBUG_IOCTL)
-      fprintf(stderr, "%s\n", __FUNCTION__);
+   if ( (mask & BUFFER_BIT_STENCIL) ) {
+      flags |= RADEON_STENCIL;
+      mask &= ~BUFFER_BIT_STENCIL;
+   }
 
-   if (rmesa->dma.flush)
-      rmesa->dma.flush( rmesa );
+   if ( mask ) {
+      if (R200_DEBUG & DEBUG_FALLBACKS)
+        fprintf(stderr, "%s: swrast clear, mask: %x\n", __FUNCTION__, mask);
+      _swrast_Clear( ctx, mask );
+   }
 
-   r200EmitState( rmesa );
-   
-   if (rmesa->store.cmd_used)
-      r200FlushCmdBuf( rmesa, __FUNCTION__ );
-}
+   if ( !flags )
+      return;
 
-/* Make sure all commands have been sent to the hardware and have
- * completed processing.
- */
-void r200Finish( GLcontext *ctx )
-{
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   r200Flush( ctx );
+   if (rmesa->using_hyperz) {
+      flags |= RADEON_USE_COMP_ZBUF;
+/*      if (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R200)
+        flags |= RADEON_USE_HIERZ; */
+      if (!((flags & RADEON_DEPTH) && (flags & RADEON_STENCIL) &&
+           ((rmesa->radeon.state.stencil.clear & R200_STENCIL_WRITE_MASK) == R200_STENCIL_WRITE_MASK))) {
+         flags |= RADEON_CLEAR_FASTZ;
+      }
+   }
 
-   if (rmesa->do_irqs) {
-      LOCK_HARDWARE( rmesa );
-      r200EmitIrqLocked( rmesa );
-      UNLOCK_HARDWARE( rmesa );
-      r200WaitIrq( rmesa );
+   if (rmesa->radeon.radeonScreen->kernel_mm)
+      r200UserClear(ctx, orig_mask);
+   else {
+      r200KernelClear(ctx, flags);
+      rmesa->radeon.hw.all_dirty = GL_TRUE;
    }
-   else 
-      r200WaitForIdle( rmesa );
 }
 
-
 /* This version of AllocateMemoryMESA allocates only GART memory, and
  * only does so after the point at which the driver has been
  * initialized.
@@ -862,7 +267,7 @@ void r200Finish( GLcontext *ctx )
  * device fd.
  */
 void *r200AllocateMemoryMESA(__DRIscreen *screen, GLsizei size,
-                            GLfloat readfreq, GLfloat writefreq, 
+                            GLfloat readfreq, GLfloat writefreq,
                             GLfloat priority)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -872,10 +277,10 @@ void *r200AllocateMemoryMESA(__DRIscreen *screen, GLsizei size,
    int ret;
 
    if (R200_DEBUG & DEBUG_IOCTL)
-      fprintf(stderr, "%s sz %d %f/%f/%f\n", __FUNCTION__, size, readfreq, 
+      fprintf(stderr, "%s sz %d %f/%f/%f\n", __FUNCTION__, size, readfreq,
              writefreq, priority);
 
-   if (!ctx || !(rmesa = R200_CONTEXT(ctx)) || !rmesa->r200Screen->gartTextures.map)
+   if (!ctx || !(rmesa = R200_CONTEXT(ctx)) || !rmesa->radeon.radeonScreen->gartTextures.map)
       return NULL;
 
    if (getenv("R200_NO_ALLOC"))
@@ -886,17 +291,17 @@ void *r200AllocateMemoryMESA(__DRIscreen *screen, GLsizei size,
    alloc.size = size;
    alloc.region_offset = &region_offset;
 
-   ret = drmCommandWriteRead( rmesa->r200Screen->driScreen->fd,
+   ret = drmCommandWriteRead( rmesa->radeon.radeonScreen->driScreen->fd,
                              DRM_RADEON_ALLOC,
                              &alloc, sizeof(alloc));
-   
+
    if (ret) {
       fprintf(stderr, "%s: DRM_RADEON_ALLOC ret %d\n", __FUNCTION__, ret);
       return NULL;
    }
-   
+
    {
-      char *region_start = (char *)rmesa->r200Screen->gartTextures.map;
+      char *region_start = (char *)rmesa->radeon.radeonScreen->gartTextures.map;
       return (void *)(region_start + region_offset);
    }
 }
@@ -914,28 +319,28 @@ void r200FreeMemoryMESA(__DRIscreen *screen, GLvoid *pointer)
    if (R200_DEBUG & DEBUG_IOCTL)
       fprintf(stderr, "%s %p\n", __FUNCTION__, pointer);
 
-   if (!ctx || !(rmesa = R200_CONTEXT(ctx)) || !rmesa->r200Screen->gartTextures.map) {
+   if (!ctx || !(rmesa = R200_CONTEXT(ctx)) || !rmesa->radeon.radeonScreen->gartTextures.map) {
       fprintf(stderr, "%s: no context\n", __FUNCTION__);
       return;
    }
 
-   region_offset = (char *)pointer - (char *)rmesa->r200Screen->gartTextures.map;
+   region_offset = (char *)pointer - (char *)rmesa->radeon.radeonScreen->gartTextures.map;
 
-   if (region_offset < 0 || 
-       region_offset > rmesa->r200Screen->gartTextures.size) {
+   if (region_offset < 0 ||
+       region_offset > rmesa->radeon.radeonScreen->gartTextures.size) {
       fprintf(stderr, "offset %d outside range 0..%d\n", region_offset,
-             rmesa->r200Screen->gartTextures.size);
+             rmesa->radeon.radeonScreen->gartTextures.size);
       return;
    }
 
    memfree.region = RADEON_MEM_REGION_GART;
    memfree.region_offset = region_offset;
-   
-   ret = drmCommandWrite( rmesa->r200Screen->driScreen->fd,
+
+   ret = drmCommandWrite( rmesa->radeon.radeonScreen->driScreen->fd,
                          DRM_RADEON_FREE,
                          &memfree, sizeof(memfree));
-   
-   if (ret) 
+
+   if (ret)
       fprintf(stderr, "%s: DRM_RADEON_FREE ret %d\n", __FUNCTION__, ret);
 }
 
@@ -956,32 +361,32 @@ GLuint r200GetMemoryOffsetMESA(__DRIscreen *screen, const GLvoid *pointer)
 
    card_offset = r200GartOffsetFromVirtual( rmesa, pointer );
 
-   return card_offset - rmesa->r200Screen->gart_base;
+   return card_offset - rmesa->radeon.radeonScreen->gart_base;
 }
 
 GLboolean r200IsGartMemory( r200ContextPtr rmesa, const GLvoid *pointer,
                           GLint size )
 {
-   ptrdiff_t offset = (char *)pointer - (char *)rmesa->r200Screen->gartTextures.map;
+   ptrdiff_t offset = (char *)pointer - (char *)rmesa->radeon.radeonScreen->gartTextures.map;
    int valid = (size >= 0 &&
                offset >= 0 &&
-               offset + size < rmesa->r200Screen->gartTextures.size);
+               offset + size < rmesa->radeon.radeonScreen->gartTextures.size);
 
    if (R200_DEBUG & DEBUG_IOCTL)
       fprintf(stderr, "r200IsGartMemory( %p ) : %d\n", pointer, valid );
-   
+
    return valid;
 }
 
 
 GLuint r200GartOffsetFromVirtual( r200ContextPtr rmesa, const GLvoid *pointer )
 {
-   ptrdiff_t offset = (char *)pointer - (char *)rmesa->r200Screen->gartTextures.map;
+   ptrdiff_t offset = (char *)pointer - (char *)rmesa->radeon.radeonScreen->gartTextures.map;
 
-   if (offset < 0 || offset > rmesa->r200Screen->gartTextures.size)
+   if (offset < 0 || offset > rmesa->radeon.radeonScreen->gartTextures.size)
       return ~0;
    else
-      return rmesa->r200Screen->gart_texture_offset + offset;
+      return rmesa->radeon.radeonScreen->gart_texture_offset + offset;
 }
 
 
@@ -989,7 +394,7 @@ GLuint r200GartOffsetFromVirtual( r200ContextPtr rmesa, const GLvoid *pointer )
 void r200InitIoctlFuncs( struct dd_function_table *functions )
 {
     functions->Clear = r200Clear;
-    functions->Finish = r200Finish;
-    functions->Flush = r200Flush;
+    functions->Finish = radeonFinish;
+    functions->Flush = radeonFlush;
 }
 
index f7458e4a0ed9e02ee195b9f27506dbd533b1219a..2a4b8a11f4c8850b99df87fb40e88637fa498436 100644 (file)
@@ -37,65 +37,30 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "main/simple_list.h"
 #include "radeon_dri.h"
-#include "r200_lock.h"
+
+#include "radeon_bocs_wrapper.h"
 
 #include "xf86drm.h"
 #include "drm.h"
 #include "radeon_drm.h"
 
-extern void r200EmitState( r200ContextPtr rmesa );
 extern void r200EmitVertexAOS( r200ContextPtr rmesa,
-                                GLuint vertex_size,
-                                GLuint offset );
+                              GLuint vertex_size,
+                              struct radeon_bo *bo,
+                              GLuint offset );
 
 extern void r200EmitVbufPrim( r200ContextPtr rmesa,
                                GLuint primitive,
                                GLuint vertex_nr );
 
-extern void r200FlushElts( r200ContextPtr rmesa );
+extern void r200FlushElts(GLcontext *ctx);
 
 extern GLushort *r200AllocEltsOpenEnded( r200ContextPtr rmesa,
                                           GLuint primitive,
                                           GLuint min_nr );
 
-extern void r200EmitAOS( r200ContextPtr rmesa,
-                          struct r200_dma_region **regions,
-                          GLuint n,
-                          GLuint offset );
-
-extern void r200EmitBlit( r200ContextPtr rmesa,
-                         GLuint color_fmt,
-                         GLuint src_pitch,
-                         GLuint src_offset,
-                         GLuint dst_pitch,
-                         GLuint dst_offset,
-                         GLint srcx, GLint srcy,
-                         GLint dstx, GLint dsty,
-                         GLuint w, GLuint h );
-
-extern void r200EmitWait( r200ContextPtr rmesa, GLuint flags );
-
-extern void r200FlushCmdBuf( r200ContextPtr rmesa, const char * );
-extern int r200FlushCmdBufLocked( r200ContextPtr rmesa, const char * caller );
-
-extern void r200RefillCurrentDmaRegion( r200ContextPtr rmesa );
-
-extern void r200AllocDmaRegion( r200ContextPtr rmesa,
-                                 struct r200_dma_region *region,
-                                 int bytes, 
-                                 int alignment );
-
-extern void r200ReleaseDmaRegion( r200ContextPtr rmesa,
-                                   struct r200_dma_region *region,
-                                   const char *caller );
-
-extern void r200CopyBuffer( __DRIdrawablePrivate *drawable,
-                           const drm_clip_rect_t      *rect);
-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 r200EmitAOS(r200ContextPtr rmesa, GLuint nr, GLuint offset);
+
 extern void r200InitIoctlFuncs( struct dd_function_table *functions );
 
 extern void *r200AllocateMemoryMESA( __DRIscreen *screen, GLsizei size, GLfloat readfreq,
@@ -119,8 +84,8 @@ void r200SetUpAtomList( r200ContextPtr rmesa );
  */
 #define R200_NEWPRIM( rmesa )                  \
 do {                                           \
-   if ( rmesa->dma.flush )                     \
-      rmesa->dma.flush( rmesa );       \
+   if ( rmesa->radeon.dma.flush )                      \
+      rmesa->radeon.dma.flush( rmesa->radeon.glCtx );  \
 } while (0)
 
 /* Can accomodate several state changes and primitive changes without
@@ -130,7 +95,7 @@ do {                                         \
 do {                                                           \
    R200_NEWPRIM( rmesa );                                      \
    rmesa->hw.ATOM.dirty = GL_TRUE;                             \
-   rmesa->hw.is_dirty = GL_TRUE;                               \
+   rmesa->radeon.hw.is_dirty = GL_TRUE;                                \
 } while (0)
 
 #define R200_DB_STATE( ATOM )                          \
@@ -139,13 +104,13 @@ do {                                                              \
 
 static INLINE int R200_DB_STATECHANGE( 
    r200ContextPtr rmesa,
-   struct r200_state_atom *atom )
+   struct radeon_state_atom *atom )
 {
    if (memcmp(atom->cmd, atom->lastcmd, atom->cmd_size*4)) {
-      int *tmp;
+      GLuint *tmp;
       R200_NEWPRIM( rmesa );
       atom->dirty = GL_TRUE;
-      rmesa->hw.is_dirty = GL_TRUE;
+      rmesa->radeon.hw.is_dirty = GL_TRUE;
       tmp = atom->cmd; 
       atom->cmd = atom->lastcmd;
       atom->lastcmd = tmp;
@@ -156,15 +121,6 @@ static INLINE int R200_DB_STATECHANGE(
 }
 
 
-/* Fire the buffered vertices no matter what.
- */
-#define R200_FIREVERTICES( rmesa )                     \
-do {                                                   \
-   if ( rmesa->store.cmd_used || rmesa->dma.flush ) {  \
-      r200Flush( rmesa->glCtx );                       \
-   }                                                   \
-} while (0)
-
 /* Command lengths.  Note that any time you ensure ELTS_BUFSZ or VBUF_BUFSZ
  * are available, you will also be adding an rmesa->state.max_state_size because
  * r200EmitState is called from within r200EmitVbufPrim and r200FlushElts.
@@ -174,36 +130,36 @@ do {                                                      \
 #define ELTS_BUFSZ(nr) (12 + nr * 2)
 #define VBUF_BUFSZ     (3 * sizeof(int))
 
-/* Ensure that a minimum amount of space is available in the command buffer.
- * This is used to ensure atomicity of state updates with the rendering requests
- * that rely on them.
- *
- * An alternative would be to implement a "soft lock" such that when the buffer
- * wraps at an inopportune time, we grab the lock, flush the current buffer,
- * and hang on to the lock until the critical section is finished and we flush
- * the buffer again and unlock.
- */
-static INLINE void r200EnsureCmdBufSpace( r200ContextPtr rmesa, int bytes )
+static inline uint32_t cmdpacket3(int cmd_type)
 {
-   if (rmesa->store.cmd_used + bytes > R200_CMD_BUF_SZ)
-      r200FlushCmdBuf( rmesa, __FUNCTION__ );
-   assert( bytes <= R200_CMD_BUF_SZ );
-}
+  drm_radeon_cmd_header_t cmd;
 
-/* Alloc space in the command buffer
- */
-static INLINE char *r200AllocCmdBuf( r200ContextPtr rmesa,
-                                        int bytes, const char *where )
-{
-   char * head;
+  cmd.i = 0;
+  cmd.header.cmd_type = cmd_type;
 
-   if (rmesa->store.cmd_used + bytes > R200_CMD_BUF_SZ)
-      r200FlushCmdBuf( rmesa, where );
+  return (uint32_t)cmd.i;
 
-   head = rmesa->store.cmd_buf + rmesa->store.cmd_used;
-   rmesa->store.cmd_used += bytes;
-   assert( rmesa->store.cmd_used <= R200_CMD_BUF_SZ );
-   return head;
 }
 
+#define OUT_BATCH_PACKET3(packet, num_extra) do {            \
+    if (!b_l_rmesa->radeonScreen->kernel_mm) {               \
+      OUT_BATCH(cmdpacket3(RADEON_CMD_PACKET3));                                     \
+      OUT_BATCH(CP_PACKET3((packet), (num_extra)));          \
+    } else {                                                 \
+      OUT_BATCH(CP_PACKET2);                                 \
+      OUT_BATCH(CP_PACKET3((packet), (num_extra)));          \
+    }                                                        \
+  } while(0)
+
+#define OUT_BATCH_PACKET3_CLIP(packet, num_extra) do {       \
+    if (!b_l_rmesa->radeonScreen->kernel_mm) {               \
+      OUT_BATCH(cmdpacket3(RADEON_CMD_PACKET3_CLIP));        \
+      OUT_BATCH(CP_PACKET3((packet), (num_extra)));          \
+    } else {                                                 \
+      OUT_BATCH(CP_PACKET2);                                 \
+      OUT_BATCH(CP_PACKET3((packet), (num_extra)));          \
+    }                                                        \
+  } while(0)
+
+
 #endif /* __R200_IOCTL_H__ */
diff --git a/src/mesa/drivers/dri/r200/r200_lock.c b/src/mesa/drivers/dri/r200/r200_lock.c
deleted file mode 100644 (file)
index 99661a4..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
-Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
-
-The Weather Channel (TM) funded Tungsten Graphics to develop the
-initial release of the Radeon 8500 driver under the XFree86 license.
-This notice must be preserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Keith Whitwell <keith@tungstengraphics.com>
- */
-#include "r200_context.h"
-#include "r200_lock.h"
-#include "r200_tex.h"
-#include "r200_state.h"
-#include "r200_ioctl.h"
-
-#include "drirenderbuffer.h"
-
-
-#if DEBUG_LOCKING
-char *prevLockFile = NULL;
-int prevLockLine = 0;
-#endif
-
-/* Turn on/off page flipping according to the flags in the sarea:
- */
-static void
-r200UpdatePageFlipping( r200ContextPtr rmesa )
-{
-   rmesa->doPageFlip = rmesa->sarea->pfState;
-   if (rmesa->glCtx->WinSysDrawBuffer) {
-      driFlipRenderbuffers(rmesa->glCtx->WinSysDrawBuffer,
-                           rmesa->sarea->pfCurrentPage);
-   }
-}
-
-
-
-/* Update the hardware state.  This is called if another main/context.has
- * grabbed the hardware lock, which includes the X server.  This
- * function also updates the driver's window state after the X server
- * moves, resizes or restacks a window -- the change will be reflected
- * in the drawable position and clip rects.  Since the X server grabs
- * the hardware lock when it changes the window state, this routine will
- * automatically be called after such a change.
- */
-void r200GetLock( r200ContextPtr rmesa, GLuint flags )
-{
-   __DRIdrawablePrivate *drawable = rmesa->dri.drawable;
-   __DRIdrawablePrivate *readable = rmesa->dri.readable;
-   __DRIscreenPrivate *sPriv = rmesa->dri.screen;
-   drm_radeon_sarea_t *sarea = rmesa->sarea;
-   int i;
-
-   drmGetLock( rmesa->dri.fd, rmesa->dri.hwContext, flags );
-
-   /* The window might have moved, so we might need to get new clip
-    * rects.
-    *
-    * NOTE: This releases and regrabs the hw lock to allow the X server
-    * to respond to the DRI protocol request for new drawable info.
-    * Since the hardware state depends on having the latest drawable
-    * clip rects, all state checking must be done _after_ this call.
-    */
-   DRI_VALIDATE_DRAWABLE_INFO( sPriv, drawable );
-   if (drawable != readable) {
-      DRI_VALIDATE_DRAWABLE_INFO( sPriv, readable );
-   }
-
-   if ( rmesa->lastStamp != drawable->lastStamp ) {
-      r200UpdatePageFlipping( rmesa );
-      r200SetCliprects( rmesa );
-      r200UpdateViewportOffset( rmesa->glCtx );
-      driUpdateFramebufferSize(rmesa->glCtx, drawable);
-   }
-
-   R200_STATECHANGE( rmesa, ctx );
-   if (rmesa->sarea->tiling_enabled) {
-      rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= R200_COLOR_TILE_ENABLE;
-   }
-   else rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] &= ~R200_COLOR_TILE_ENABLE;
-
-   if ( sarea->ctx_owner != rmesa->dri.hwContext ) {
-      sarea->ctx_owner = rmesa->dri.hwContext;
-   }
-
-   for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
-      DRI_AGE_TEXTURES( rmesa->texture_heaps[ i ] );
-   }
-
-   rmesa->lost_context = GL_TRUE;
-}
diff --git a/src/mesa/drivers/dri/r200/r200_lock.h b/src/mesa/drivers/dri/r200/r200_lock.h
deleted file mode 100644 (file)
index 4ff9890..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
-Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
-
-The Weather Channel (TM) funded Tungsten Graphics to develop the
-initial release of the Radeon 8500 driver under the XFree86 license.
-This notice must be preserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#ifndef __R200_LOCK_H__
-#define __R200_LOCK_H__
-
-extern void r200GetLock( r200ContextPtr rmesa, GLuint flags );
-
-/* Turn DEBUG_LOCKING on to find locking conflicts.
- */
-#define DEBUG_LOCKING  0
-
-#if DEBUG_LOCKING
-extern char *prevLockFile;
-extern int prevLockLine;
-
-#define DEBUG_LOCK()                                                   \
-   do {                                                                        \
-      prevLockFile = (__FILE__);                                       \
-      prevLockLine = (__LINE__);                                       \
-   } while (0)
-
-#define DEBUG_RESET()                                                  \
-   do {                                                                        \
-      prevLockFile = 0;                                                        \
-      prevLockLine = 0;                                                        \
-   } while (0)
-
-#define DEBUG_CHECK_LOCK()                                             \
-   do {                                                                        \
-      if ( prevLockFile ) {                                            \
-        fprintf( stderr,                                               \
-                 "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n",    \
-                 prevLockFile, prevLockLine, __FILE__, __LINE__ );     \
-        exit( 1 );                                                     \
-      }                                                                        \
-   } while (0)
-
-#else
-
-#define DEBUG_LOCK()
-#define DEBUG_RESET()
-#define DEBUG_CHECK_LOCK()
-
-#endif
-
-/*
- * !!! We may want to separate locks from locks with validation.  This
- * could be used to improve performance for those things commands that
- * do not do any drawing !!!
- */
-
-
-/* Lock the hardware and validate our state.
- */
-#define LOCK_HARDWARE( rmesa )                                 \
-   do {                                                                \
-      char __ret = 0;                                          \
-      DEBUG_CHECK_LOCK();                                      \
-      DRM_CAS( rmesa->dri.hwLock, rmesa->dri.hwContext,                \
-              (DRM_LOCK_HELD | rmesa->dri.hwContext), __ret ); \
-      if ( __ret )                                             \
-        r200GetLock( rmesa, 0 );                               \
-      DEBUG_LOCK();                                            \
-   } while (0)
-
-#define UNLOCK_HARDWARE( rmesa )                                       \
-   do {                                                                        \
-      DRM_UNLOCK( rmesa->dri.fd,                                       \
-                 rmesa->dri.hwLock,                                    \
-                 rmesa->dri.hwContext );                               \
-      DEBUG_RESET();                                                   \
-   } while (0)
-
-#endif /* __R200_LOCK_H__ */
index d3ed06d4021912e599fce64c87ac6e6246ca26b8..16a70475e18b67e56208a636f561731b0b783187 100644 (file)
@@ -38,6 +38,5 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r200_context.h"
 
 extern void r200EmitArrays( GLcontext *ctx, GLubyte *vimap_rev );
-extern void r200ReleaseArrays( GLcontext *ctx, GLuint newinputs );
 
 #endif
index 8512b9af478ab6f02f2e66df219fe17daabd5d5b..383a0c4b0d3ea6c67c3f8ea1d973a77fcec32f4c 100644 (file)
@@ -50,110 +50,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r200_maos.h"
 #include "r200_tcl.h"
 
-
-#if 0
-/* Usage:
- *   - from r200_tcl_render
- *   - call r200EmitArrays to ensure uptodate arrays in dma
- *   - emit primitives (new type?) which reference the data
- *       -- need to use elts for lineloop, quads, quadstrip/flat
- *       -- other primitives are all well-formed (need tristrip-1,fake-poly)
- *
- */
-static void emit_ubyte_rgba3( GLcontext *ctx,
-                      struct r200_dma_region *rvb,
-                      char *data,
-                      int stride,
-                      int count )
-{
-   int i;
-   r200_color_t *out = (r200_color_t *)(rvb->start + rvb->address);
-
-   if (R200_DEBUG & DEBUG_VERTS)
-      fprintf(stderr, "%s count %d stride %d out %p\n",
-             __FUNCTION__, count, stride, (void *)out);
-
-   for (i = 0; i < count; i++) {
-      out->red   = *data;
-      out->green = *(data+1);
-      out->blue  = *(data+2);
-      out->alpha = 0xFF;
-      out++;
-      data += stride;
-   }
-}
-
-static void emit_ubyte_rgba4( GLcontext *ctx,
-                             struct r200_dma_region *rvb,
-                             char *data,
-                             int stride,
-                             int count )
-{
-   int i;
-   int *out = (int *)(rvb->address + rvb->start);
-
-   if (R200_DEBUG & DEBUG_VERTS)
-      fprintf(stderr, "%s count %d stride %d\n",
-             __FUNCTION__, count, stride);
-
-   if (stride == 4) {
-      for (i = 0; i < count; i++)
-        ((int *)out)[i] = LE32_TO_CPU(((int *)data)[i]);
-   } else {
-      for (i = 0; i < count; i++) {
-        *(int *)out++ = LE32_TO_CPU(*(int *)data);
-        data += stride;
-      }
-   }
-}
-
-
-static void emit_ubyte_rgba( GLcontext *ctx,
-                            struct r200_dma_region *rvb,
-                            char *data,
-                            int size,
-                            int stride,
-                            int count )
-{
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);
-
-   if (R200_DEBUG & DEBUG_VERTS)
-      fprintf(stderr, "%s %d/%d\n", __FUNCTION__, count, size);
-
-   assert (!rvb->buf);
-
-   if (stride == 0) {
-      r200AllocDmaRegion( rmesa, rvb, 4, 4 );
-      count = 1;
-      rvb->aos_start = GET_START(rvb);
-      rvb->aos_stride = 0;
-      rvb->aos_size = 1;
-   }
-   else {
-      r200AllocDmaRegion( rmesa, rvb, 4 * count, 4 );  /* alignment? */
-      rvb->aos_start = GET_START(rvb);
-      rvb->aos_stride = 1;
-      rvb->aos_size = 1;
-   }
-
-   /* Emit the data
-    */
-   switch (size) {
-   case 3:
-      emit_ubyte_rgba3( ctx, rvb, data, stride, count );
-      break;
-   case 4:
-      emit_ubyte_rgba4( ctx, rvb, data, stride, count );
-      break;
-   default:
-      assert(0);
-      exit(1);
-      break;
-   }
-}
-#endif
-
-
 #if defined(USE_X86_ASM)
 #define COPY_DWORDS( dst, src, nr )                                    \
 do {                                                                   \
@@ -174,204 +70,34 @@ do {                                              \
 } while (0)
 #endif
 
-
-static void emit_vecfog( GLcontext *ctx,
-                        struct r200_dma_region *rvb,
-                        char *data,
-                        int stride,
-                        int count )
+static void r200_emit_vecfog(GLcontext *ctx, struct radeon_aos *aos,
+                            GLvoid *data, int stride, int count)
 {
-   int i;
-   GLfloat *out;
-
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   
-   if (R200_DEBUG & DEBUG_VERTS)
-      fprintf(stderr, "%s count %d stride %d\n",
-             __FUNCTION__, count, stride);
-
-   assert (!rvb->buf);
-
-   if (stride == 0) {
-      r200AllocDmaRegion( rmesa, rvb, 4, 4 );
-      count = 1;
-      rvb->aos_start = GET_START(rvb);
-      rvb->aos_stride = 0;
-      rvb->aos_size = 1;
-   }
-   else {
-      r200AllocDmaRegion( rmesa, rvb, count * 4, 4 );  /* alignment? */
-      rvb->aos_start = GET_START(rvb);
-      rvb->aos_stride = 1;
-      rvb->aos_size = 1;
-   }
-
-   /* Emit the data
-    */
-   out = (GLfloat *)(rvb->address + rvb->start);
-   for (i = 0; i < count; i++) {
-      out[0] = r200ComputeFogBlendFactor( ctx, *(GLfloat *)data );
-      out++;
-      data += stride;
-   }
-
+       radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+       uint32_t *out;
+       int i;
+       int size = 1;
+
+       if (stride == 0) {
+               radeonAllocDmaRegion(rmesa, &aos->bo, &aos->offset, size * 4, 32);
+               count = 1;
+               aos->stride = 0;
+       } else {
+               radeonAllocDmaRegion(rmesa, &aos->bo, &aos->offset, size * 4, 32);
+               aos->stride = size;
+       }
+
+       aos->components = size;
+       aos->count = count;
+
+       out = (uint32_t*)((char*)aos->bo->ptr + aos->offset);
+       for (i = 0; i < count; i++) {
+         out[0] = r200ComputeFogBlendFactor( ctx, *(GLfloat *)data );
+         out++;
+         data += stride;
+       }
 }
 
-
-static void emit_vec4( GLcontext *ctx,
-                      struct r200_dma_region *rvb,
-                      char *data,
-                      int stride,
-                      int count )
-{
-   int i;
-   int *out = (int *)(rvb->address + rvb->start);
-
-   if (R200_DEBUG & DEBUG_VERTS)
-      fprintf(stderr, "%s count %d stride %d\n",
-             __FUNCTION__, count, stride);
-
-   if (stride == 4)
-      COPY_DWORDS( out, data, count );
-   else
-      for (i = 0; i < count; i++) {
-        out[0] = *(int *)data;
-        out++;
-        data += stride;
-      }
-}
-
-
-static void emit_vec8( GLcontext *ctx,
-                      struct r200_dma_region *rvb,
-                      char *data,
-                      int stride,
-                      int count )
-{
-   int i;
-   int *out = (int *)(rvb->address + rvb->start);
-
-   if (R200_DEBUG & DEBUG_VERTS)
-      fprintf(stderr, "%s count %d stride %d\n",
-             __FUNCTION__, count, stride);
-
-   if (stride == 8)
-      COPY_DWORDS( out, data, count*2 );
-   else
-      for (i = 0; i < count; i++) {
-        out[0] = *(int *)data;
-        out[1] = *(int *)(data+4);
-        out += 2;
-        data += stride;
-      }
-}
-
-static void emit_vec12( GLcontext *ctx,
-                      struct r200_dma_region *rvb,
-                      char *data,
-                      int stride,
-                      int count )
-{
-   int i;
-   int *out = (int *)(rvb->address + rvb->start);
-
-   if (R200_DEBUG & DEBUG_VERTS)
-      fprintf(stderr, "%s count %d stride %d out %p data %p\n",
-             __FUNCTION__, count, stride, (void *)out, (void *)data);
-
-   if (stride == 12)
-      COPY_DWORDS( out, data, count*3 );
-   else
-      for (i = 0; i < count; i++) {
-        out[0] = *(int *)data;
-        out[1] = *(int *)(data+4);
-        out[2] = *(int *)(data+8);
-        out += 3;
-        data += stride;
-      }
-}
-
-static void emit_vec16( GLcontext *ctx,
-                       struct r200_dma_region *rvb,
-                       char *data,
-                       int stride,
-                       int count )
-{
-   int i;
-   int *out = (int *)(rvb->address + rvb->start);
-
-   if (R200_DEBUG & DEBUG_VERTS)
-      fprintf(stderr, "%s count %d stride %d\n",
-             __FUNCTION__, count, stride);
-
-   if (stride == 16)
-      COPY_DWORDS( out, data, count*4 );
-   else
-      for (i = 0; i < count; i++) {
-        out[0] = *(int *)data;
-        out[1] = *(int *)(data+4);
-        out[2] = *(int *)(data+8);
-        out[3] = *(int *)(data+12);
-        out += 4;
-        data += stride;
-      }
-}
-
-
-static void emit_vector( GLcontext *ctx,
-                        struct r200_dma_region *rvb,
-                        char *data,
-                        int size,
-                        int stride,
-                        int count )
-{
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);
-
-   if (R200_DEBUG & DEBUG_VERTS)
-      fprintf(stderr, "%s count %d size %d stride %d\n",
-             __FUNCTION__, count, size, stride);
-
-   assert (!rvb->buf);
-
-   if (stride == 0) {
-      r200AllocDmaRegion( rmesa, rvb, size * 4, 4 );
-      count = 1;
-      rvb->aos_start = GET_START(rvb);
-      rvb->aos_stride = 0;
-      rvb->aos_size = size;
-   }
-   else {
-      r200AllocDmaRegion( rmesa, rvb, size * count * 4, 4 );   /* alignment? */
-      rvb->aos_start = GET_START(rvb);
-      rvb->aos_stride = size;
-      rvb->aos_size = size;
-   }
-
-   /* Emit the data
-    */
-   switch (size) {
-   case 1:
-      emit_vec4( ctx, rvb, data, stride, count );
-      break;
-   case 2:
-      emit_vec8( ctx, rvb, data, stride, count );
-      break;
-   case 3:
-      emit_vec12( ctx, rvb, data, stride, count );
-      break;
-   case 4:
-      emit_vec16( ctx, rvb, data, stride, count );
-      break;
-   default:
-      assert(0);
-      exit(1);
-      break;
-   }
-
-}
-
-
-
 /* Emit any changed arrays to new GART memory, re-emit a packet to
  * update the arrays.  
  */
@@ -379,12 +105,12 @@ void r200EmitArrays( GLcontext *ctx, GLubyte *vimap_rev )
 {
    r200ContextPtr rmesa = R200_CONTEXT( ctx );
    struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
-   struct r200_dma_region **component = rmesa->tcl.aos_components;
    GLuint nr = 0;
    GLuint vfmt0 = 0, vfmt1 = 0;
    GLuint count = VB->Count;
    GLuint i, emitsize;
 
+   //   fprintf(stderr,"emit arrays\n");
    for ( i = 0; i < 15; i++ ) {
       GLubyte attrib = vimap_rev[i];
       if (attrib != 255) {
@@ -416,20 +142,20 @@ void r200EmitArrays( GLcontext *ctx, GLubyte *vimap_rev )
         case 3:
            /* special handling to fix up fog. Will get us into trouble with vbos...*/
            assert(attrib == VERT_ATTRIB_FOG);
-           if (!rmesa->tcl.vertex_data[i].buf) {
+           if (!rmesa->radeon.tcl.aos[i].bo) {
               if (ctx->VertexProgram._Enabled)
-                 emit_vector( ctx,
-                        &(rmesa->tcl.vertex_data[i]),
-                        (char *)VB->AttribPtr[attrib]->data,
-                        1,
-                        VB->AttribPtr[attrib]->stride,
-                        count);
+                 rcommon_emit_vector( ctx,
+                                      &(rmesa->radeon.tcl.aos[nr]),
+                                      (char *)VB->AttribPtr[attrib]->data,
+                                      1,
+                                      VB->AttribPtr[attrib]->stride,
+                                      count);
               else
-                 emit_vecfog( ctx,
-                        &(rmesa->tcl.vertex_data[i]),
-                        (char *)VB->AttribPtr[attrib]->data,
-                        VB->AttribPtr[attrib]->stride,
-                        count);
+                r200_emit_vecfog( ctx,
+                                  &(rmesa->radeon.tcl.aos[nr]),
+                                  (char *)VB->AttribPtr[attrib]->data,
+                                  VB->AttribPtr[attrib]->stride,
+                                  count);
            }
            vfmt0 |= R200_VTX_DISCRETE_FOG;
            goto after_emit;
@@ -473,17 +199,17 @@ void r200EmitArrays( GLcontext *ctx, GLubyte *vimap_rev )
         default:
            assert(0);
         }
-        if (!rmesa->tcl.vertex_data[i].buf) {
-           emit_vector( ctx,
-                        &(rmesa->tcl.vertex_data[i]),
-                        (char *)VB->AttribPtr[attrib]->data,
-                        emitsize,
-                        VB->AttribPtr[attrib]->stride,
-                        count );
+        if (!rmesa->radeon.tcl.aos[nr].bo) {
+          rcommon_emit_vector( ctx,
+                               &(rmesa->radeon.tcl.aos[nr]),
+                               (char *)VB->AttribPtr[attrib]->data,
+                               emitsize,
+                               VB->AttribPtr[attrib]->stride,
+                               count );
         }
 after_emit:
         assert(nr < 12);
-        component[nr++] = &rmesa->tcl.vertex_data[i];
+        nr++;
       }
    }
 
@@ -494,19 +220,6 @@ after_emit:
       rmesa->hw.vtx.cmd[VTX_VTXFMT_1] = vfmt1;
    }
 
-   rmesa->tcl.nr_aos_components = nr;
+   rmesa->radeon.tcl.aos_count = nr;
 }
 
-
-void r200ReleaseArrays( GLcontext *ctx, GLuint newinputs )
-{
-   r200ContextPtr rmesa = R200_CONTEXT( ctx );
-
-   /* only do it for changed inputs ? */
-   int i;
-   for (i = 0; i < 15; i++) {
-      if (newinputs & (1 << i))
-        r200ReleaseDmaRegion( rmesa,
-           &rmesa->tcl.vertex_data[i], __FUNCTION__ );
-   }
-}
index 2797cbb3dc0a7dbc8f79ca52caec25489beee541..654f2c6ae986778aeb37c9a1597fbfc729828c26 100644 (file)
@@ -51,7 +51,7 @@ check_color( const GLcontext *ctx, GLenum type, GLenum format,
             const void *pixels, GLint sz, GLint pitch )
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   GLuint cpp = rmesa->r200Screen->cpp;
+   GLuint cpp = rmesa->radeon.radeonScreen->cpp;
 
    if (R200_DEBUG & DEBUG_PIXEL)
       fprintf(stderr, "%s\n", __FUNCTION__);
@@ -65,8 +65,8 @@ check_color( const GLcontext *ctx, GLenum type, GLenum format,
       return GL_FALSE;
    }
 
-   if ( type == GL_UNSIGNED_INT_8_8_8_8_REV && 
-       cpp == 4 && 
+   if ( type == GL_UNSIGNED_INT_8_8_8_8_REV &&
+       cpp == 4 &&
        format == GL_BGRA ) {
       if (R200_DEBUG & DEBUG_PIXEL)
         fprintf(stderr, "%s: passed 2\n", __FUNCTION__);
@@ -83,7 +83,7 @@ static GLboolean
 check_color_per_fragment_ops( const GLcontext *ctx )
 {
    int result;
-   result = (!(     ctx->Color.AlphaEnabled || 
+   result = (!(     ctx->Color.AlphaEnabled ||
                    ctx->Depth.Test ||
                    ctx->Fog.Enabled ||
                    ctx->Scissor.Enabled ||
@@ -96,7 +96,7 @@ check_color_per_fragment_ops( const GLcontext *ctx )
                    ctx->Texture._EnabledUnits
            ) &&
           ctx->Current.RasterPosValid);
-   
+
    return result;
 }
 
@@ -137,8 +137,8 @@ clip_pixelrect( const GLcontext *ctx,
    if (*height <= 0)
       return GL_FALSE;
 
-   *size = ((*y + *height - 1) * rmesa->r200Screen->frontPitch +
-           (*x + *width - 1) * rmesa->r200Screen->cpp);
+   *size = ((*y + *height - 1) * rmesa->radeon.radeonScreen->frontPitch +
+           (*x + *width - 1) * rmesa->radeon.radeonScreen->cpp);
 
    return GL_TRUE;
 }
@@ -153,19 +153,20 @@ r200TryReadPixels( GLcontext *ctx,
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
    GLint pitch = pack->RowLength ? pack->RowLength : width;
    GLint blit_format;
-   GLuint cpp = rmesa->r200Screen->cpp;
+   GLuint cpp = rmesa->radeon.radeonScreen->cpp;
    GLint size = width * height * cpp;
 
+   return GL_FALSE;
+#if 0
    if (R200_DEBUG & DEBUG_PIXEL)
       fprintf(stderr, "%s\n", __FUNCTION__);
 
    /* Only accelerate reading to GART buffers.
     */
-   if ( !r200IsGartMemory(rmesa, pixels, 
-                        pitch * height * rmesa->r200Screen->cpp ) ) {
+   if ( !r200IsGartMemory(rmesa, pixels,
+                        pitch * height * rmesa->radeon.radeonScreen->cpp ) ) {
       if (R200_DEBUG & DEBUG_PIXEL)
         fprintf(stderr, "%s: dest not GART\n", __FUNCTION__);
-      return GL_FALSE;
    }
 
    /* Need GL_PACK_INVERT_MESA to cope with upsidedown results from
@@ -180,7 +181,7 @@ r200TryReadPixels( GLcontext *ctx,
    if (!check_color(ctx, type, format, pack, pixels, size, pitch))
       return GL_FALSE;
 
-   switch ( rmesa->r200Screen->cpp ) {
+   switch ( rmesa->radeon.radeonScreen->cpp ) {
    case 4:
       blit_format = R200_CP_COLOR_FORMAT_ARGB8888;
       break;
@@ -197,14 +198,14 @@ r200TryReadPixels( GLcontext *ctx,
     * a full command buffer expects to be called unlocked.  As a
     * workaround, immediately flush the buffer on aquiring the lock.
     */
-   LOCK_HARDWARE( rmesa );
+   LOCK_HARDWARE( &rmesa->radeon );
 
    if (rmesa->store.cmd_used)
-      r200FlushCmdBufLocked( rmesa, __FUNCTION__ );
+      rcommonFlushCmdBufLocked( &rmesa->radeon, __FUNCTION__ );
 
    if (!clip_pixelrect(ctx, ctx->ReadBuffer, &x, &y, &width, &height,
                       &size)) {
-      UNLOCK_HARDWARE( rmesa );
+      UNLOCK_HARDWARE( &rmesa->radeon );
       if (R200_DEBUG & DEBUG_PIXEL)
         fprintf(stderr, "%s totally clipped -- nothing to do\n",
                 __FUNCTION__);
@@ -212,18 +213,18 @@ r200TryReadPixels( GLcontext *ctx,
    }
 
    {
-      __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+      __DRIdrawablePrivate *dPriv = rmesa->radeon.dri.drawable;
       driRenderbuffer *drb = (driRenderbuffer *) ctx->ReadBuffer->_ColorReadBuffer;
       int nbox = dPriv->numClipRects;
       int src_offset = drb->offset
-                    + rmesa->r200Screen->fbLocation;
+                    + rmesa->radeon.radeonScreen->fbLocation;
       int src_pitch = drb->pitch * drb->cpp;
       int dst_offset = r200GartOffsetFromVirtual( rmesa, pixels );
-      int dst_pitch = pitch * rmesa->r200Screen->cpp;
+      int dst_pitch = pitch * rmesa->radeon.radeonScreen->cpp;
       drm_clip_rect_t *box = dPriv->pClipRects;
       int i;
 
-      r200EmitWait( rmesa, RADEON_WAIT_3D ); 
+      r200EmitWait( rmesa, RADEON_WAIT_3D );
 
       y = dPriv->h - y - height;
       x += dPriv->x;
@@ -240,7 +241,7 @@ r200TryReadPixels( GLcontext *ctx,
         GLint by = box[i].y1;
         GLint bw = box[i].x2 - bx;
         GLint bh = box[i].y2 - by;
-        
+
         if (bx < x) bw -= x - bx, bx = x;
         if (by < y) bh -= y - by, by = y;
         if (bx + bw > x + width) bw = x + width - bx;
@@ -257,12 +258,12 @@ r200TryReadPixels( GLcontext *ctx,
                       bw, bh );
       }
 
-      r200FlushCmdBufLocked( rmesa, __FUNCTION__ );
+      rcommonFlushCmdBufLocked( &rmesa->radeon, __FUNCTION__ );
    }
-   UNLOCK_HARDWARE( rmesa );
-
-   r200Finish( ctx ); /* required by GL */
+   UNLOCK_HARDWARE( &rmesa->radeon );
 
+   radeonFinish( ctx ); /* required by GL */
+#endif
    return GL_TRUE;
 }
 
@@ -276,9 +277,9 @@ r200ReadPixels( GLcontext *ctx,
    if (R200_DEBUG & DEBUG_PIXEL)
       fprintf(stderr, "%s\n", __FUNCTION__);
 
-   if (!r200TryReadPixels( ctx, x, y, width, height, format, type, pack, 
+   if (!r200TryReadPixels( ctx, x, y, width, height, format, type, pack,
                           pixels))
-      _swrast_ReadPixels( ctx, x, y, width, height, format, type, pack, 
+      _swrast_ReadPixels( ctx, x, y, width, height, format, type, pack,
                          pixels);
 }
 
@@ -292,7 +293,7 @@ static void do_draw_pix( GLcontext *ctx,
                         GLuint planemask)
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+   __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
    drm_clip_rect_t *box = dPriv->pClipRects;
    struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorDrawBuffers[0];
    driRenderbuffer *drb = (driRenderbuffer *) rb;
@@ -301,12 +302,12 @@ static void do_draw_pix( GLcontext *ctx,
    int blit_format;
    int size;
    int src_offset = r200GartOffsetFromVirtual( rmesa, pixels );
-   int src_pitch = pitch * rmesa->r200Screen->cpp;
+   int src_pitch = pitch * rmesa->radeon.radeonScreen->cpp;
 
    if (R200_DEBUG & DEBUG_PIXEL)
       fprintf(stderr, "%s\n", __FUNCTION__);
-
-   switch ( rmesa->r200Screen->cpp ) {
+#if 0
+   switch ( rmesa->radeon.radeonScreen->cpp ) {
    case 2:
       blit_format = R200_CP_COLOR_FORMAT_RGB565;
       break;
@@ -318,17 +319,17 @@ static void do_draw_pix( GLcontext *ctx,
    }
 
 
-   LOCK_HARDWARE( rmesa );
+   LOCK_HARDWARE( &rmesa->radeon );
 
    if (rmesa->store.cmd_used)
-      r200FlushCmdBufLocked( rmesa, __FUNCTION__ );
+      rcommonFlushCmdBufLocked( &rmesa->radeon, __FUNCTION__ );
 
    y -= height;                        /* cope with pixel zoom */
-   
+
    if (!clip_pixelrect(ctx, ctx->DrawBuffer,
                       &x, &y, &width, &height,
                       &size)) {
-      UNLOCK_HARDWARE( rmesa );
+      UNLOCK_HARDWARE( &rmesa->radeon );
       return;
    }
 
@@ -357,15 +358,16 @@ static void do_draw_pix( GLcontext *ctx,
                    blit_format,
                    src_pitch, src_offset,
                    drb->pitch * drb->cpp,
-                   drb->offset + rmesa->r200Screen->fbLocation,
+                   drb->offset + rmesa->radeon.radeonScreen->fbLocation,
                    bx - x, by - y,
                    bx, by,
                    bw, bh );
    }
 
-   r200FlushCmdBufLocked( rmesa, __FUNCTION__ );
-   r200WaitForIdleLocked( rmesa ); /* required by GL */
-   UNLOCK_HARDWARE( rmesa );
+   rcommonFlushCmdBufLocked( &rmesa->radeon, __FUNCTION__ );
+   radeonWaitForIdleLocked( &rmesa->radeon ); /* required by GL */
+   UNLOCK_HARDWARE( &rmesa->radeon );
+#endif
 }
 
 
@@ -381,7 +383,7 @@ r200TryDrawPixels( GLcontext *ctx,
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
    GLint pitch = unpack->RowLength ? unpack->RowLength : width;
    GLuint planemask;
-   GLuint cpp = rmesa->r200Screen->cpp;
+   GLuint cpp = rmesa->radeon.radeonScreen->cpp;
    GLint size = height * pitch * cpp;
 
    if (R200_DEBUG & DEBUG_PIXEL)
@@ -395,7 +397,7 @@ r200TryDrawPixels( GLcontext *ctx,
    case GL_RGB:
    case GL_RGBA:
    case GL_BGRA:
-      planemask = r200PackColor(cpp,
+      planemask = radeonPackColor(cpp,
                                ctx->Color.ColorMask[RCOMP],
                                ctx->Color.ColorMask[GCOMP],
                                ctx->Color.ColorMask[BCOMP],
@@ -407,7 +409,7 @@ r200TryDrawPixels( GLcontext *ctx,
       if (planemask != ~0)
         return GL_FALSE;       /* fix me -- should be possible */
 
-      /* Can't do conversions on GART reads/draws. 
+      /* Can't do conversions on GART reads/draws.
        */
       if ( !r200IsGartMemory( rmesa, pixels, size ) ) {
         if (R200_DEBUG & DEBUG_PIXEL)
@@ -431,7 +433,7 @@ r200TryDrawPixels( GLcontext *ctx,
       return GL_FALSE;
    }
 
-   if ( r200IsGartMemory(rmesa, pixels, size) )
+   if (0)// r200IsGartMemory(rmesa, pixels, size) )
    {
       do_draw_pix( ctx, x, y, width, height, pitch, pixels, planemask );
       return GL_TRUE;
@@ -471,7 +473,7 @@ r200Bitmap( GLcontext *ctx, GLint px, GLint py,
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
 
-   if (rmesa->Fallback)
+   if (rmesa->radeon.Fallback)
       _swrast_Bitmap( ctx, px, py, width, height, unpack, bitmap );
    else
       r200PointsBitmap( ctx, px, py, width, height, unpack, bitmap );
@@ -482,9 +484,9 @@ r200Bitmap( GLcontext *ctx, GLint px, GLint py,
 void r200InitPixelFuncs( GLcontext *ctx )
 {
    if (!getenv("R200_NO_BLITS")) {
-      ctx->Driver.ReadPixels = r200ReadPixels;  
-      ctx->Driver.DrawPixels = r200DrawPixels; 
-      if (getenv("R200_HW_BITMAP")) 
+      ctx->Driver.ReadPixels = r200ReadPixels;
+      ctx->Driver.DrawPixels = r200DrawPixels;
+      if (getenv("R200_HW_BITMAP"))
         ctx->Driver.Bitmap = r200Bitmap;
    }
 }
index 5ce287f7a5f9bc7f8e07f33aa9978021860795e4..526a624b69727a77b6de01eafea5b3de97dda28f 100644 (file)
@@ -463,8 +463,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define     R200_VSC_UPDATE_USER_COLOR_1_ENABLE    0x00020000
 /* gap */
 #define R200_SE_TCL_VECTOR_INDX_REG                0x2200
+#       define RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT  16
+#       define RADEON_VEC_INDX_DWORD_COUNT_SHIFT     28
 #define R200_SE_TCL_VECTOR_DATA_REG                0x2204
 #define R200_SE_TCL_SCALAR_INDX_REG                0x2208
+#       define RADEON_SCAL_INDX_DWORD_STRIDE_SHIFT  16
 #define R200_SE_TCL_SCALAR_DATA_REG                0x220c
 /* gap */
 #define R200_SE_TCL_MATRIX_SEL_0                   0x2230
@@ -949,6 +952,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define     R200_LOD_BIAS_MASK                        (0xfff80000)
 #define     R200_LOD_BIAS_SHIFT                       19
 #define R200_PP_TXSIZE_0                  0x2c0c /* NPOT only */
+#define R200_PP_TX_WIDTHMASK_SHIFT 0
+#define R200_PP_TX_HEIGHTMASK_SHIFT 16
+
 #define R200_PP_TXPITCH_0                 0x2c10 /* NPOT only */
 #define R200_PP_BORDER_COLOR_0            0x2c14
 #define R200_PP_CUBIC_FACES_0             0x2c18
diff --git a/src/mesa/drivers/dri/r200/r200_span.c b/src/mesa/drivers/dri/r200/r200_span.c
deleted file mode 100644 (file)
index 9783678..0000000
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
-Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
-
-The Weather Channel (TM) funded Tungsten Graphics to develop the
-initial release of the Radeon 8500 driver under the XFree86 license.
-This notice must be preserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "main/glheader.h"
-#include "main/imports.h"
-#include "main/colormac.h"
-#include "swrast/swrast.h"
-
-#include "r200_context.h"
-#include "r200_ioctl.h"
-#include "r200_state.h"
-#include "r200_span.h"
-#include "r200_tex.h"
-
-#define DBG 0
-
-/*
- * Note that all information needed to access pixels in a renderbuffer
- * should be obtained through the gl_renderbuffer parameter, not per-context
- * information.
- */
-#define LOCAL_VARS                                             \
-   driRenderbuffer *drb = (driRenderbuffer *) rb;              \
-   const __DRIdrawablePrivate *dPriv = drb->dPriv;             \
-   const GLuint bottom = dPriv->h - 1;                         \
-   GLubyte *buf = (GLubyte *) drb->flippedData                 \
-      + (dPriv->y * drb->flippedPitch + dPriv->x) * drb->cpp;  \
-   GLuint p;                                                   \
-   (void) p;
-
-#define LOCAL_DEPTH_VARS                               \
-   driRenderbuffer *drb = (driRenderbuffer *) rb;      \
-   const __DRIdrawablePrivate *dPriv = drb->dPriv;     \
-   const GLuint bottom = dPriv->h - 1;                 \
-   GLuint xo = dPriv->x;                               \
-   GLuint yo = dPriv->y;                               \
-   GLubyte *buf = (GLubyte *) drb->Base.Data;
-
-#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
-
-#define Y_FLIP(Y) (bottom - (Y))
-
-#define HW_LOCK() 
-
-#define HW_UNLOCK()                                                    
-
-
-
-/* ================================================================
- * Color buffer
- */
-
-/* 16 bit, RGB565 color spanline and pixel functions
- */
-#define SPANTMP_PIXEL_FMT GL_RGB
-#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
-
-#define TAG(x)    r200##x##_RGB565
-#define TAG2(x,y) r200##x##_RGB565##y
-#define GET_PTR(X,Y) (buf + ((Y) * drb->flippedPitch + (X)) * 2)
-#include "spantmp2.h"
-
-/* 32 bit, ARGB8888 color spanline and pixel functions
- */
-#define SPANTMP_PIXEL_FMT GL_BGRA
-#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
-
-#define TAG(x)    r200##x##_ARGB8888
-#define TAG2(x,y) r200##x##_ARGB8888##y
-#define GET_PTR(X,Y) (buf + ((Y) * drb->flippedPitch + (X)) * 4)
-#include "spantmp2.h"
-
-
-/* ================================================================
- * Depth buffer
- */
-
-/* The Radeon family has depth tiling on all the time, so we have to convert
- * the x,y coordinates into the memory bus address (mba) in the same
- * manner as the engine.  In each case, the linear block address (ba)
- * is calculated, and then wired with x and y to produce the final
- * memory address.
- * The chip will do address translation on its own if the surface registers
- * are set up correctly. It is not quite enough to get it working with hyperz too...
- */
-
-/* extract bit 'b' of x, result is zero or one */
-#define BIT(x,b) ((x & (1<<b))>>b)
-
-static GLuint
-r200_mba_z32( driRenderbuffer *drb, GLint x, GLint y )
-{
-   GLuint pitch = drb->pitch;
-   if (drb->depthHasSurface) {
-      return 4 * (x + y * pitch);
-   }
-   else {
-      GLuint b = ((y & 0x7FF) >> 4) * ((pitch & 0xFFF) >> 5) + ((x & 0x7FF) >> 5);
-      GLuint a = 
-         (BIT(x,0) << 2) |
-         (BIT(y,0) << 3) |
-         (BIT(x,1) << 4) |
-         (BIT(y,1) << 5) |
-         (BIT(x,3) << 6) |
-         (BIT(x,4) << 7) |
-         (BIT(x,2) << 8) |
-         (BIT(y,2) << 9) |
-         (BIT(y,3) << 10) |
-         (((pitch & 0x20) ? (b & 0x01) : ((b & 0x01) ^ (BIT(y,4)))) << 11) |
-         ((b >> 1) << 12);
-      return a;
-   }
-}
-
-static GLuint
-r200_mba_z16( driRenderbuffer *drb, GLint x, GLint y )
-{
-   GLuint pitch = drb->pitch;
-   if (drb->depthHasSurface) {
-      return 2 * (x + y * pitch);
-   }
-   else {
-      GLuint b = ((y & 0x7FF) >> 4) * ((pitch & 0xFFF) >> 6) + ((x & 0x7FF) >> 6);
-      GLuint a = 
-         (BIT(x,0) << 1) |
-         (BIT(y,0) << 2) |
-         (BIT(x,1) << 3) |
-         (BIT(y,1) << 4) |
-         (BIT(x,2) << 5) |
-         (BIT(x,4) << 6) |
-         (BIT(x,5) << 7) |
-         (BIT(x,3) << 8) |
-         (BIT(y,2) << 9) |
-         (BIT(y,3) << 10) |
-         (((pitch & 0x40) ? (b & 0x01) : ((b & 0x01) ^ (BIT(y,4)))) << 11) |
-         ((b >> 1) << 12);
-      return a;
-   }
-}
-
-
-/* 16-bit depth buffer functions
- */
-#define VALUE_TYPE GLushort
-
-#define WRITE_DEPTH( _x, _y, d )                                       \
-   *(GLushort *)(buf + r200_mba_z16( drb, _x + xo, _y + yo )) = d;
-
-#define READ_DEPTH( d, _x, _y )                                                \
-   d = *(GLushort *)(buf + r200_mba_z16( drb, _x + xo, _y + yo ));
-
-#define TAG(x) r200##x##_z16
-#include "depthtmp.h"
-
-
-/* 24 bit depth, 8 bit stencil depthbuffer functions
- */
-#define VALUE_TYPE GLuint
-
-#define WRITE_DEPTH( _x, _y, d )                                       \
-do {                                                                   \
-   GLuint offset = r200_mba_z32( drb, _x + xo, _y + yo );              \
-   GLuint tmp = *(GLuint *)(buf + offset);                             \
-   tmp &= 0xff000000;                                                  \
-   tmp |= ((d) & 0x00ffffff);                                          \
-   *(GLuint *)(buf + offset) = tmp;                                    \
-} while (0)
-
-#define READ_DEPTH( d, _x, _y )                                                \
-   d = *(GLuint *)(buf + r200_mba_z32( drb, _x + xo,                   \
-                                        _y + yo )) & 0x00ffffff;
-
-#define TAG(x) r200##x##_z24_s8
-#include "depthtmp.h"
-
-
-/* ================================================================
- * Stencil buffer
- */
-
-/* 24 bit depth, 8 bit stencil depthbuffer functions
- */
-#define WRITE_STENCIL( _x, _y, d )                                     \
-do {                                                                   \
-   GLuint offset = r200_mba_z32( drb, _x + xo, _y + yo );              \
-   GLuint tmp = *(GLuint *)(buf + offset);                             \
-   tmp &= 0x00ffffff;                                                  \
-   tmp |= (((d) & 0xff) << 24);                                                \
-   *(GLuint *)(buf + offset) = tmp;                                    \
-} while (0)
-
-#define READ_STENCIL( d, _x, _y )                                      \
-do {                                                                   \
-   GLuint offset = r200_mba_z32( drb, _x + xo, _y + yo );              \
-   GLuint tmp = *(GLuint *)(buf + offset);                             \
-   tmp &= 0xff000000;                                                  \
-   d = tmp >> 24;                                                      \
-} while (0)
-
-#define TAG(x) r200##x##_z24_s8
-#include "stenciltmp.h"
-
-
-/* Move locking out to get reasonable span performance (10x better
- * than doing this in HW_LOCK above).  WaitForIdle() is the main
- * culprit.
- */
-
-static void r200SpanRenderStart( GLcontext *ctx )
-{
-   r200ContextPtr rmesa = R200_CONTEXT( ctx );
-
-   R200_FIREVERTICES( rmesa );
-   LOCK_HARDWARE( rmesa );
-   r200WaitForIdleLocked( rmesa );
-
-   /* Read & rewrite the first pixel in the frame buffer.  This should
-    * be a noop, right?  In fact without this conform fails as reading
-    * from the framebuffer sometimes produces old results -- the
-    * on-card read cache gets mixed up and doesn't notice that the
-    * framebuffer has been updated.
-    *
-    * In the worst case this is buggy too as p might get the wrong
-    * value first time, so really need a hidden pixel somewhere for this.
-    */
-   {
-      int p;
-      driRenderbuffer *drb =
-        (driRenderbuffer *) ctx->WinSysDrawBuffer->_ColorDrawBuffers[0];
-      volatile int *buf =
-        (volatile int *)(rmesa->dri.screen->pFB + drb->offset);
-      p = *buf;
-      *buf = p;
-   }
-}
-
-static void r200SpanRenderFinish( GLcontext *ctx )
-{
-   r200ContextPtr rmesa = R200_CONTEXT( ctx );
-   _swrast_flush( ctx );
-   UNLOCK_HARDWARE( rmesa );
-}
-
-void r200InitSpanFuncs( GLcontext *ctx )
-{
-   struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
-   swdd->SpanRenderStart          = r200SpanRenderStart;
-   swdd->SpanRenderFinish         = r200SpanRenderFinish; 
-}
-
-
-
-/**
- * Plug in the Get/Put routines for the given driRenderbuffer.
- */
-void
-radeonSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
-{
-   if (drb->Base.InternalFormat == GL_RGBA) {
-      if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
-         r200InitPointers_RGB565(&drb->Base);
-      }
-      else {
-         r200InitPointers_ARGB8888(&drb->Base);
-      }
-   }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
-      r200InitDepthPointers_z16(&drb->Base);
-   }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
-      r200InitDepthPointers_z24_s8(&drb->Base);
-   }
-   else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
-      r200InitStencilPointers_z24_s8(&drb->Base);
-   }
-}
diff --git a/src/mesa/drivers/dri/r200/r200_span.h b/src/mesa/drivers/dri/r200/r200_span.h
deleted file mode 100644 (file)
index bae5644..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
-
-The Weather Channel (TM) funded Tungsten Graphics to develop the
-initial release of the Radeon 8500 driver under the XFree86 license.
-This notice must be preserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#ifndef __R200_SPAN_H__
-#define __R200_SPAN_H__
-
-#include "drirenderbuffer.h"
-
-extern void r200InitSpanFuncs( GLcontext *ctx );
-
-extern void
-radeonSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
-
-#endif
index 2fcc87c0f5a6eccf2b863ec605aea103a7f31e2c..f8ebe0df57e6973ea949a9e3f85edc0af1404712 100644 (file)
@@ -47,6 +47,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "tnl/t_pipeline.h"
 #include "swrast_setup/swrast_setup.h"
 
+#include "radeon_common.h"
+#include "radeon_mipmap_tree.h"
 #include "r200_context.h"
 #include "r200_ioctl.h"
 #include "r200_state.h"
@@ -77,7 +79,7 @@ static void r200AlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref )
 
    switch ( func ) {
    case GL_NEVER:
-      pp_misc |= R200_ALPHA_TEST_FAIL; 
+      pp_misc |= R200_ALPHA_TEST_FAIL;
       break;
    case GL_LESS:
       pp_misc |= R200_ALPHA_TEST_LESS;
@@ -114,8 +116,8 @@ static void r200BlendColor( GLcontext *ctx, const GLfloat cf[4] )
    CLAMPED_FLOAT_TO_UBYTE(color[1], cf[1]);
    CLAMPED_FLOAT_TO_UBYTE(color[2], cf[2]);
    CLAMPED_FLOAT_TO_UBYTE(color[3], cf[3]);
-   if (rmesa->r200Screen->drmSupportsBlendColor)
-      rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCOLOR] = r200PackColor( 4, color[0], color[1], color[2], color[3] );
+   if (rmesa->radeon.radeonScreen->drmSupportsBlendColor)
+      rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCOLOR] = radeonPackColor( 4, color[0], color[1], color[2], color[3] );
 }
 
 /**
@@ -213,7 +215,7 @@ static void r200_set_blend_state( GLcontext * ctx )
 
    R200_STATECHANGE( rmesa, ctx );
 
-   if (rmesa->r200Screen->drmSupportsBlendColor) {
+   if (rmesa->radeon.radeonScreen->drmSupportsBlendColor) {
       if (ctx->Color.ColorLogicOpEnabled) {
          rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] =  cntl | R200_ROP_ENABLE;
          rmesa->hw.ctx.cmd[CTX_RB3D_ABLENDCNTL] = eqn | func;
@@ -278,7 +280,7 @@ static void r200_set_blend_state( GLcontext * ctx )
       return;
    }
 
-   if (!rmesa->r200Screen->drmSupportsBlendColor) {
+   if (!rmesa->radeon.radeonScreen->drmSupportsBlendColor) {
       rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] = eqn | func;
       return;
    }
@@ -383,10 +385,10 @@ static void r200ClearDepth( GLcontext *ctx, GLclampd d )
 
    switch ( format ) {
    case R200_DEPTH_FORMAT_16BIT_INT_Z:
-      rmesa->state.depth.clear = d * 0x0000ffff;
+      rmesa->radeon.state.depth.clear = d * 0x0000ffff;
       break;
    case R200_DEPTH_FORMAT_24BIT_INT_Z:
-      rmesa->state.depth.clear = d * 0x00ffffff;
+      rmesa->radeon.state.depth.clear = d * 0x00ffffff;
       break;
    }
 }
@@ -477,10 +479,10 @@ static void r200Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
         }
       }
       break;
-   case GL_FOG_COLOR: 
+   case GL_FOG_COLOR:
       R200_STATECHANGE( rmesa, ctx );
       UNCLAMPED_FLOAT_TO_RGB_CHAN( col, ctx->Fog.Color );
-      i = r200PackColor( 4, col[0], col[1], col[2], 0 );
+      i = radeonPackColor( 4, col[0], col[1], col[2], 0 );
       rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] &= ~R200_FOG_COLOR_MASK;
       rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] |= i;
       break;
@@ -505,7 +507,7 @@ static void r200Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
 
       if (out_0 != rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0]) {
         R200_STATECHANGE( rmesa, vtx );
-        rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] = out_0;     
+        rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] = out_0;
       }
 
       break;
@@ -521,102 +523,6 @@ static void r200Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
    }
 }
 
-
-/* =============================================================
- * Scissoring
- */
-
-
-static GLboolean intersect_rect( drm_clip_rect_t *out,
-                                drm_clip_rect_t *a,
-                                drm_clip_rect_t *b )
-{
-   *out = *a;
-   if ( b->x1 > out->x1 ) out->x1 = b->x1;
-   if ( b->y1 > out->y1 ) out->y1 = b->y1;
-   if ( b->x2 < out->x2 ) out->x2 = b->x2;
-   if ( b->y2 < out->y2 ) out->y2 = b->y2;
-   if ( out->x1 >= out->x2 ) return GL_FALSE;
-   if ( out->y1 >= out->y2 ) return GL_FALSE;
-   return GL_TRUE;
-}
-
-
-void r200RecalcScissorRects( r200ContextPtr rmesa )
-{
-   drm_clip_rect_t *out;
-   int i;
-
-   /* Grow cliprect store?
-    */
-   if (rmesa->state.scissor.numAllocedClipRects < rmesa->numClipRects) {
-      while (rmesa->state.scissor.numAllocedClipRects < rmesa->numClipRects) {
-        rmesa->state.scissor.numAllocedClipRects += 1; /* zero case */
-        rmesa->state.scissor.numAllocedClipRects *= 2;
-      }
-
-      if (rmesa->state.scissor.pClipRects)
-        FREE(rmesa->state.scissor.pClipRects);
-
-      rmesa->state.scissor.pClipRects = 
-        MALLOC( rmesa->state.scissor.numAllocedClipRects * 
-                sizeof(drm_clip_rect_t) );
-
-      if ( rmesa->state.scissor.pClipRects == NULL ) {
-        rmesa->state.scissor.numAllocedClipRects = 0;
-        return;
-      }
-   }
-   
-   out = rmesa->state.scissor.pClipRects;
-   rmesa->state.scissor.numClipRects = 0;
-
-   for ( i = 0 ; i < rmesa->numClipRects ;  i++ ) {
-      if ( intersect_rect( out, 
-                          &rmesa->pClipRects[i], 
-                          &rmesa->state.scissor.rect ) ) {
-        rmesa->state.scissor.numClipRects++;
-        out++;
-      }
-   }
-}
-
-
-static void r200UpdateScissor( GLcontext *ctx )
-{
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);
-
-   if ( rmesa->dri.drawable ) {
-      __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
-
-      int x = ctx->Scissor.X;
-      int y = dPriv->h - ctx->Scissor.Y - ctx->Scissor.Height;
-      int w = ctx->Scissor.X + ctx->Scissor.Width - 1;
-      int h = dPriv->h - ctx->Scissor.Y - 1;
-
-      rmesa->state.scissor.rect.x1 = x + dPriv->x;
-      rmesa->state.scissor.rect.y1 = y + dPriv->y;
-      rmesa->state.scissor.rect.x2 = w + dPriv->x + 1;
-      rmesa->state.scissor.rect.y2 = h + dPriv->y + 1;
-
-      r200RecalcScissorRects( rmesa );
-   }
-}
-
-
-static void r200Scissor( GLcontext *ctx,
-                          GLint x, GLint y, GLsizei w, GLsizei h )
-{
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);
-
-   if ( ctx->Scissor.Enabled ) {
-      R200_FIREVERTICES( rmesa );      /* don't pipeline cliprect changes */
-      r200UpdateScissor( ctx );
-   }
-
-}
-
-
 /* =============================================================
  * Culling
  */
@@ -790,7 +696,7 @@ static void r200LineStipple( GLcontext *ctx, GLint factor, GLushort pattern )
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
 
    R200_STATECHANGE( rmesa, lin );
-   rmesa->hw.lin.cmd[LIN_RE_LINE_PATTERN] = 
+   rmesa->hw.lin.cmd[LIN_RE_LINE_PATTERN] =
       ((((GLuint)factor & 0xff) << 16) | ((GLuint)pattern));
 }
 
@@ -803,7 +709,7 @@ static void r200ColorMask( GLcontext *ctx,
                           GLboolean b, GLboolean a )
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   GLuint mask = r200PackColor( rmesa->r200Screen->cpp,
+   GLuint mask = radeonPackColor( rmesa->radeon.radeonScreen->cpp,
                                ctx->Color.ColorMask[RCOMP],
                                ctx->Color.ColorMask[GCOMP],
                                ctx->Color.ColorMask[BCOMP],
@@ -814,10 +720,10 @@ static void r200ColorMask( GLcontext *ctx,
    if (!(r && g && b && a))
       flag |= R200_PLANE_MASK_ENABLE;
 
-   if ( rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] != flag ) { 
-      R200_STATECHANGE( rmesa, ctx ); 
-      rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] = flag; 
-   } 
+   if ( rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] != flag ) {
+      R200_STATECHANGE( rmesa, ctx );
+      rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] = flag;
+   }
 
    if ( rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK] != mask ) {
       R200_STATECHANGE( rmesa, msk );
@@ -834,7 +740,8 @@ static void r200PolygonOffset( GLcontext *ctx,
                               GLfloat factor, GLfloat units )
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   float_ui32_type constant =  { units * rmesa->state.depth.scale };
+   const GLfloat depthScale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
+   float_ui32_type constant =  { units * depthScale };
    float_ui32_type factoru = { factor };
 
 /*    factor *= 2; */
@@ -861,15 +768,15 @@ static void r200PolygonStipple( GLcontext *ctx, const GLubyte *mask )
 
    /* TODO: push this into cmd mechanism
     */
-   R200_FIREVERTICES( rmesa );
-   LOCK_HARDWARE( rmesa );
+   radeon_firevertices(&rmesa->radeon);
+   LOCK_HARDWARE( &rmesa->radeon );
 
    /* FIXME: Use window x,y offsets into stipple RAM.
     */
    stipple.mask = rmesa->state.stipple.mask;
-   drmCommandWrite( rmesa->dri.fd, DRM_RADEON_STIPPLE, 
+   drmCommandWrite( rmesa->radeon.dri.fd, DRM_RADEON_STIPPLE,
                     &stipple, sizeof(stipple) );
-   UNLOCK_HARDWARE( rmesa );
+   UNLOCK_HARDWARE( &rmesa->radeon );
 }
 
 static void r200PolygonMode( GLcontext *ctx, GLenum face, GLenum mode )
@@ -878,10 +785,10 @@ static void r200PolygonMode( GLcontext *ctx, GLenum face, GLenum mode )
    GLboolean flag = (ctx->_TriangleCaps & DD_TRI_UNFILLED) != 0;
 
    /* Can't generally do unfilled via tcl, but some good special
-    * cases work. 
+    * cases work.
     */
    TCL_FALLBACK( ctx, R200_TCL_FALLBACK_UNFILLED, flag);
-   if (rmesa->TclFallback) {
+   if (rmesa->radeon.TclFallback) {
       r200ChooseRenderState( ctx );
       r200ChooseVertexState( ctx );
    }
@@ -920,34 +827,34 @@ static void r200UpdateSpecular( GLcontext *ctx )
 
    if (ctx->Light.Enabled &&
        ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) {
-      rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] |= 
+      rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] |=
         ((R200_VTX_FP_RGBA << R200_VTX_COLOR_0_SHIFT) |
-         (R200_VTX_FP_RGBA << R200_VTX_COLOR_1_SHIFT));        
+         (R200_VTX_FP_RGBA << R200_VTX_COLOR_1_SHIFT));
       rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] |= R200_OUTPUT_COLOR_0;
       rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] |= R200_OUTPUT_COLOR_1;
       rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] |= R200_LIGHTING_ENABLE;
       p |=  R200_SPECULAR_ENABLE;
-      rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] &= 
+      rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] &=
         ~R200_DIFFUSE_SPECULAR_COMBINE;
    }
    else if (ctx->Light.Enabled) {
-      rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] |= 
-        ((R200_VTX_FP_RGBA << R200_VTX_COLOR_0_SHIFT));        
+      rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] |=
+        ((R200_VTX_FP_RGBA << R200_VTX_COLOR_0_SHIFT));
       rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] |= R200_OUTPUT_COLOR_0;
       rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] |= R200_LIGHTING_ENABLE;
    } else if (ctx->Fog.ColorSumEnabled ) {
-      rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] |= 
+      rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] |=
         ((R200_VTX_FP_RGBA << R200_VTX_COLOR_0_SHIFT) |
-         (R200_VTX_FP_RGBA << R200_VTX_COLOR_1_SHIFT));        
+         (R200_VTX_FP_RGBA << R200_VTX_COLOR_1_SHIFT));
       p |=  R200_SPECULAR_ENABLE;
    } else {
-      rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] |= 
-        ((R200_VTX_FP_RGBA << R200_VTX_COLOR_0_SHIFT));        
+      rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] |=
+        ((R200_VTX_FP_RGBA << R200_VTX_COLOR_0_SHIFT));
    }
 
    if (ctx->Fog.Enabled) {
-      rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] |= 
-        ((R200_VTX_FP_RGBA << R200_VTX_COLOR_1_SHIFT));        
+      rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] |=
+        ((R200_VTX_FP_RGBA << R200_VTX_COLOR_1_SHIFT));
       rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] |= R200_OUTPUT_COLOR_1;
    }
 
@@ -958,7 +865,7 @@ static void r200UpdateSpecular( GLcontext *ctx )
 
    /* Update vertex/render formats
     */
-   if (rmesa->TclFallback) { 
+   if (rmesa->radeon.TclFallback) {
       r200ChooseRenderState( ctx );
       r200ChooseVertexState( ctx );
    }
@@ -970,7 +877,7 @@ static void r200UpdateSpecular( GLcontext *ctx )
  */
 
 
-/* Update on colormaterial, material emmissive/ambient, 
+/* Update on colormaterial, material emmissive/ambient,
  * lightmodel.globalambient
  */
 static void update_global_ambient( GLcontext *ctx )
@@ -984,23 +891,23 @@ static void update_global_ambient( GLcontext *ctx )
     */
    if ((rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_1] &
        ((3 << R200_FRONT_EMISSIVE_SOURCE_SHIFT) |
-       (3 << R200_FRONT_AMBIENT_SOURCE_SHIFT))) == 0) 
+       (3 << R200_FRONT_AMBIENT_SOURCE_SHIFT))) == 0)
    {
-      COPY_3V( &fcmd[GLT_RED], 
+      COPY_3V( &fcmd[GLT_RED],
               ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_EMISSION]);
       ACC_SCALE_3V( &fcmd[GLT_RED],
                   ctx->Light.Model.Ambient,
                   ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_AMBIENT]);
-   } 
+   }
    else
    {
       COPY_3V( &fcmd[GLT_RED], ctx->Light.Model.Ambient );
    }
-   
+
    R200_DB_STATECHANGE(rmesa, &rmesa->hw.glt);
 }
 
-/* Update on change to 
+/* Update on change to
  *    - light[p].colors
  *    - light[p].enabled
  */
@@ -1014,10 +921,10 @@ static void update_light_colors( GLcontext *ctx, GLuint p )
       r200ContextPtr rmesa = R200_CONTEXT(ctx);
       float *fcmd = (float *)R200_DB_STATE( lit[p] );
 
-      COPY_4V( &fcmd[LIT_AMBIENT_RED], l->Ambient );    
+      COPY_4V( &fcmd[LIT_AMBIENT_RED], l->Ambient );
       COPY_4V( &fcmd[LIT_DIFFUSE_RED], l->Diffuse );
       COPY_4V( &fcmd[LIT_SPECULAR_RED], l->Specular );
-      
+
       R200_DB_STATECHANGE( rmesa, &rmesa->hw.lit[p] );
    }
 }
@@ -1037,7 +944,7 @@ static void r200ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
 
    if (ctx->Light.ColorMaterialEnabled) {
       GLuint mask = ctx->Light.ColorMaterialBitmask;
-   
+
       if (mask & MAT_BIT_FRONT_EMISSION) {
         light_model_ctl1 |= (R200_LM1_SOURCE_VERTEX_COLOR_0 <<
                             R200_FRONT_EMISSIVE_SOURCE_SHIFT);
@@ -1053,7 +960,7 @@ static void r200ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
       else
          light_model_ctl1 |= (R200_LM1_SOURCE_MATERIAL_0 <<
                             R200_FRONT_AMBIENT_SOURCE_SHIFT);
-        
+
       if (mask & MAT_BIT_FRONT_DIFFUSE) {
         light_model_ctl1 |= (R200_LM1_SOURCE_VERTEX_COLOR_0 <<
                             R200_FRONT_DIFFUSE_SOURCE_SHIFT);
@@ -1061,7 +968,7 @@ static void r200ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
       else
          light_model_ctl1 |= (R200_LM1_SOURCE_MATERIAL_0 <<
                             R200_FRONT_DIFFUSE_SOURCE_SHIFT);
-   
+
       if (mask & MAT_BIT_FRONT_SPECULAR) {
         light_model_ctl1 |= (R200_LM1_SOURCE_VERTEX_COLOR_0 <<
                             R200_FRONT_SPECULAR_SOURCE_SHIFT);
@@ -1070,7 +977,7 @@ static void r200ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
          light_model_ctl1 |= (R200_LM1_SOURCE_MATERIAL_0 <<
                             R200_FRONT_SPECULAR_SOURCE_SHIFT);
       }
-   
+
       if (mask & MAT_BIT_BACK_EMISSION) {
         light_model_ctl1 |= (R200_LM1_SOURCE_VERTEX_COLOR_0 <<
                             R200_BACK_EMISSIVE_SOURCE_SHIFT);
@@ -1120,8 +1027,8 @@ static void r200ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
       R200_STATECHANGE( rmesa, tcl );
       rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_1] = light_model_ctl1;
    }
-   
-   
+
+
 }
 
 void r200UpdateMaterial( GLcontext *ctx )
@@ -1131,7 +1038,7 @@ void r200UpdateMaterial( GLcontext *ctx )
    GLfloat *fcmd = (GLfloat *)R200_DB_STATE( mtl[0] );
    GLfloat *fcmd2 = (GLfloat *)R200_DB_STATE( mtl[1] );
    GLuint mask = ~0;
-   
+
    /* Might be possible and faster to update everything unconditionally? */
    if (ctx->Light.ColorMaterialEnabled)
       mask &= ~ctx->Light.ColorMaterialBitmask;
@@ -1217,7 +1124,7 @@ void r200UpdateMaterial( GLcontext *ctx )
  *
  * which are calculated in light.c and are correct for the current
  * lighting space (model or eye), hence dependencies on _NEW_MODELVIEW
- * and _MESA_NEW_NEED_EYE_COORDS.  
+ * and _MESA_NEW_NEED_EYE_COORDS.
  */
 static void update_light( GLcontext *ctx )
 {
@@ -1234,8 +1141,8 @@ static void update_light( GLcontext *ctx )
         tmp &= ~R200_LIGHT_IN_MODELSPACE;
       else
         tmp |= R200_LIGHT_IN_MODELSPACE;
-      
-      if (tmp != rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0]) 
+
+      if (tmp != rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0])
       {
         R200_STATECHANGE( rmesa, tcl );
         rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] = tmp;
@@ -1259,10 +1166,10 @@ static void update_light( GLcontext *ctx )
         if (ctx->Light.Light[p].Enabled) {
            struct gl_light *l = &ctx->Light.Light[p];
            GLfloat *fcmd = (GLfloat *)R200_DB_STATE( lit[p] );
-           
+
            if (l->EyePosition[3] == 0.0) {
-              COPY_3FV( &fcmd[LIT_POSITION_X], l->_VP_inf_norm ); 
-              COPY_3FV( &fcmd[LIT_DIRECTION_X], l->_h_inf_norm ); 
+              COPY_3FV( &fcmd[LIT_POSITION_X], l->_VP_inf_norm );
+              COPY_3FV( &fcmd[LIT_DIRECTION_X], l->_h_inf_norm );
               fcmd[LIT_POSITION_W] = 0;
               fcmd[LIT_DIRECTION_W] = 0;
            } else {
@@ -1286,21 +1193,21 @@ static void r200Lightfv( GLcontext *ctx, GLenum light,
    GLint p = light - GL_LIGHT0;
    struct gl_light *l = &ctx->Light.Light[p];
    GLfloat *fcmd = (GLfloat *)rmesa->hw.lit[p].cmd;
-   
+
 
    switch (pname) {
-   case GL_AMBIENT:            
+   case GL_AMBIENT:
    case GL_DIFFUSE:
    case GL_SPECULAR:
       update_light_colors( ctx, p );
       break;
 
-   case GL_SPOT_DIRECTION: 
-      /* picked up in update_light */  
+   case GL_SPOT_DIRECTION:
+      /* picked up in update_light */
       break;
 
    case GL_POSITION: {
-      /* positions picked up in update_light, but can do flag here */  
+      /* positions picked up in update_light, but can do flag here */
       GLuint flag = (p&1)? R200_LIGHT_1_IS_LOCAL : R200_LIGHT_0_IS_LOCAL;
       GLuint idx = TCL_PER_LIGHT_CTL_0 + p/2;
 
@@ -1416,7 +1323,7 @@ static void r200LightModelfv( GLcontext *ctx, GLenum pname,
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
 
    switch (pname) {
-      case GL_LIGHT_MODEL_AMBIENT: 
+      case GL_LIGHT_MODEL_AMBIENT:
         update_global_ambient( ctx );
         break;
 
@@ -1430,7 +1337,7 @@ static void r200LightModelfv( GLcontext *ctx, GLenum pname,
            rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] |= R200_LIGHT_TWOSIDE;
         else
            rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] &= ~(R200_LIGHT_TWOSIDE);
-        if (rmesa->TclFallback) {
+        if (rmesa->radeon.TclFallback) {
            r200ChooseRenderState( ctx );
            r200ChooseVertexState( ctx );
         }
@@ -1675,7 +1582,7 @@ static void r200ClearStencil( GLcontext *ctx, GLint s )
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
 
-   rmesa->state.stencil.clear = 
+   rmesa->radeon.state.stencil.clear =
       ((GLuint) (ctx->Stencil.Clear & 0xff) |
        (0xff << R200_STENCIL_MASK_SHIFT) |
        ((ctx->Stencil.WriteMask[0] & 0xff) << R200_STENCIL_WRITEMASK_SHIFT));
@@ -1700,19 +1607,29 @@ static void r200ClearStencil( GLcontext *ctx, GLint s )
 void r200UpdateWindow( GLcontext *ctx )
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
-   GLfloat xoffset = (GLfloat)dPriv->x;
-   GLfloat yoffset = (GLfloat)dPriv->y + dPriv->h;
+   __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
+   GLfloat xoffset = dPriv ? (GLfloat) dPriv->x : 0;
+   GLfloat yoffset = dPriv ? (GLfloat) dPriv->y + dPriv->h : 0;
    const GLfloat *v = ctx->Viewport._WindowMap.m;
+   const GLboolean render_to_fbo = (ctx->DrawBuffer ? (ctx->DrawBuffer->Name != 0) : 0);
+   const GLfloat depthScale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
+   GLfloat y_scale, y_bias;
+
+   if (render_to_fbo) {
+      y_scale = 1.0;
+      y_bias = 0;
+   } else {
+      y_scale = -1.0;
+      y_bias = yoffset;
+   }
 
    float_ui32_type sx = { v[MAT_SX] };
    float_ui32_type tx = { v[MAT_TX] + xoffset + SUBPIXEL_X };
-   float_ui32_type sy = { - v[MAT_SY] };
-   float_ui32_type ty = { (- v[MAT_TY]) + yoffset + SUBPIXEL_Y };
-   float_ui32_type sz = { v[MAT_SZ] * rmesa->state.depth.scale };
-   float_ui32_type tz = { v[MAT_TZ] * rmesa->state.depth.scale };
+   float_ui32_type sy = { v[MAT_SY] * y_scale };
+   float_ui32_type ty = { (v[MAT_TY] * y_scale) + y_bias + SUBPIXEL_Y };
+   float_ui32_type sz = { v[MAT_SZ] * depthScale };
+   float_ui32_type tz = { v[MAT_TZ] * depthScale };
 
-   R200_FIREVERTICES( rmesa );
    R200_STATECHANGE( rmesa, vpt );
 
    rmesa->hw.vpt.cmd[VPT_SE_VPORT_XSCALE]  = sx.ui32;
@@ -1733,6 +1650,8 @@ static void r200Viewport( GLcontext *ctx, GLint x, GLint y,
     * values, or keep the originals hanging around.
     */
    r200UpdateWindow( ctx );
+
+   radeon_viewport(ctx, x, y, width, height);
 }
 
 static void r200DepthRange( GLcontext *ctx, GLclampd nearval,
@@ -1744,7 +1663,7 @@ static void r200DepthRange( GLcontext *ctx, GLclampd nearval,
 void r200UpdateViewportOffset( GLcontext *ctx )
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+   __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
    GLfloat xoffset = (GLfloat)dPriv->x;
    GLfloat yoffset = (GLfloat)dPriv->y + dPriv->h;
    const GLfloat *v = ctx->Viewport._WindowMap.m;
@@ -1774,8 +1693,8 @@ void r200UpdateViewportOffset( GLcontext *ctx )
                 R200_STIPPLE_Y_OFFSET_MASK);
 
          /* add magic offsets, then invert */
-         stx = 31 - ((rmesa->dri.drawable->x - 1) & R200_STIPPLE_COORD_MASK);
-         sty = 31 - ((rmesa->dri.drawable->y + rmesa->dri.drawable->h - 1)
+         stx = 31 - ((dPriv->x - 1) & R200_STIPPLE_COORD_MASK);
+         sty = 31 - ((dPriv->y + dPriv->h - 1)
                      & R200_STIPPLE_COORD_MASK);
 
          m |= ((stx << R200_STIPPLE_X_OFFSET_SHIFT) |
@@ -1788,7 +1707,7 @@ void r200UpdateViewportOffset( GLcontext *ctx )
       }
    }
 
-   r200UpdateScissor( ctx );
+   radeonUpdateScissor( ctx );
 }
 
 
@@ -1805,7 +1724,7 @@ static void r200ClearColor( GLcontext *ctx, const GLfloat c[4] )
    CLAMPED_FLOAT_TO_UBYTE(color[1], c[1]);
    CLAMPED_FLOAT_TO_UBYTE(color[2], c[2]);
    CLAMPED_FLOAT_TO_UBYTE(color[3], c[3]);
-   rmesa->state.color.clear = r200PackColor( rmesa->r200Screen->cpp,
+   rmesa->radeon.state.color.clear = radeonPackColor( rmesa->radeon.radeonScreen->cpp,
                                              color[0], color[1],
                                              color[2], color[3] );
 }
@@ -1848,96 +1767,6 @@ static void r200LogicOpCode( GLcontext *ctx, GLenum opcode )
    rmesa->hw.msk.cmd[MSK_RB3D_ROPCNTL] = r200_rop_tab[rop];
 }
 
-
-/*
- * Set up the cliprects for either front or back-buffer drawing.
- */
-void r200SetCliprects( r200ContextPtr rmesa )
-{
-   __DRIdrawablePrivate *const drawable = rmesa->dri.drawable;
-   __DRIdrawablePrivate *const readable = rmesa->dri.readable;
-   GLframebuffer *const draw_fb = (GLframebuffer*) drawable->driverPrivate;
-   GLframebuffer *const read_fb = (GLframebuffer*) readable->driverPrivate;
-
-   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 ) {
-         rmesa->numClipRects = drawable->numClipRects;
-         rmesa->pClipRects = drawable->pClipRects;
-      }
-      else {
-         rmesa->numClipRects = drawable->numBackClipRects;
-         rmesa->pClipRects = drawable->pBackClipRects;
-      }
-   }
-   else {
-     /* front buffer (or none, or multiple buffers) */
-     rmesa->numClipRects = drawable->numClipRects;
-     rmesa->pClipRects = drawable->pClipRects;
-  }
-
-   if ((draw_fb->Width != drawable->w) || (draw_fb->Height != drawable->h)) {
-      _mesa_resize_framebuffer(rmesa->glCtx, draw_fb,
-                              drawable->w, drawable->h);
-      draw_fb->Initialized = GL_TRUE;
-   }
-
-   if (drawable != readable) {
-      if ((read_fb->Width != readable->w) ||
-         (read_fb->Height != readable->h)) {
-        _mesa_resize_framebuffer(rmesa->glCtx, read_fb,
-                                 readable->w, readable->h);
-        read_fb->Initialized = GL_TRUE;
-      }
-   }
-
-   if (rmesa->state.scissor.enabled)
-      r200RecalcScissorRects( rmesa );
-
-   rmesa->lastStamp = drawable->lastStamp;
-}
-
-
-static void r200DrawBuffer( GLcontext *ctx, GLenum mode )
-{
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);
-
-   if (R200_DEBUG & DEBUG_DRI)
-      fprintf(stderr, "%s %s\n", __FUNCTION__,
-             _mesa_lookup_enum_by_nr( mode ));
-
-   R200_FIREVERTICES(rmesa);   /* don't pipeline cliprect changes */
-
-   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:
-      FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_TRUE );
-      return;
-   }
-
-   r200SetCliprects( rmesa );
-
-   /* We'll set the drawing engine's offset/pitch parameters later
-    * when we update other state.
-    */
-}
-
-
-static void r200ReadBuffer( GLcontext *ctx, GLenum mode )
-{
-   /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
-}
-
 /* =============================================================
  * State enable/disable
  */
@@ -1979,7 +1808,7 @@ static void r200Enable( GLcontext *ctx, GLenum cap, GLboolean state )
    case GL_CLIP_PLANE2:
    case GL_CLIP_PLANE3:
    case GL_CLIP_PLANE4:
-   case GL_CLIP_PLANE5: 
+   case GL_CLIP_PLANE5:
       p = cap-GL_CLIP_PLANE0;
       R200_STATECHANGE( rmesa, tcl );
       if (state) {
@@ -2013,10 +1842,10 @@ static void r200Enable( GLcontext *ctx, GLenum cap, GLboolean state )
       R200_STATECHANGE(rmesa, ctx );
       if ( state ) {
         rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |=  R200_DITHER_ENABLE;
-        rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~rmesa->state.color.roundEnable;
+        rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~rmesa->radeon.state.color.roundEnable;
       } else {
         rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~R200_DITHER_ENABLE;
-        rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |=  rmesa->state.color.roundEnable;
+        rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |=  rmesa->radeon.state.color.roundEnable;
       }
       break;
 
@@ -2031,7 +1860,7 @@ static void r200Enable( GLcontext *ctx, GLenum cap, GLboolean state )
         rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~R200_TCL_FOG_MASK;
       }
       r200UpdateSpecular( ctx ); /* for PK_SPEC */
-      if (rmesa->TclFallback) 
+      if (rmesa->radeon.TclFallback)
         r200ChooseVertexState( ctx );
       _mesa_allow_light_in_model( ctx, !state );
       break;
@@ -2046,13 +1875,13 @@ static void r200Enable( GLcontext *ctx, GLenum cap, GLboolean state )
    case GL_LIGHT7:
       R200_STATECHANGE(rmesa, tcl);
       p = cap - GL_LIGHT0;
-      if (p&1) 
+      if (p&1)
         flag = (R200_LIGHT_1_ENABLE |
-                R200_LIGHT_1_ENABLE_AMBIENT | 
+                R200_LIGHT_1_ENABLE_AMBIENT |
                 R200_LIGHT_1_ENABLE_SPECULAR);
       else
         flag = (R200_LIGHT_0_ENABLE |
-                R200_LIGHT_0_ENABLE_AMBIENT | 
+                R200_LIGHT_0_ENABLE_AMBIENT |
                 R200_LIGHT_0_ENABLE_SPECULAR);
 
       if (state)
@@ -2060,7 +1889,7 @@ static void r200Enable( GLcontext *ctx, GLenum cap, GLboolean state )
       else
         rmesa->hw.tcl.cmd[p/2 + TCL_PER_LIGHT_CTL_0] &= ~flag;
 
-      /* 
+      /*
        */
       update_light_colors( ctx, p );
       break;
@@ -2068,7 +1897,7 @@ static void r200Enable( GLcontext *ctx, GLenum cap, GLboolean state )
    case GL_LIGHTING:
       r200UpdateSpecular(ctx);
       /* for reflection map fixup - might set recheck_texgen for all units too */
-      rmesa->NewGLState |= _NEW_TEXTURE;
+      rmesa->radeon.NewGLState |= _NEW_TEXTURE;
       break;
 
    case GL_LINE_SMOOTH:
@@ -2181,21 +2010,30 @@ static void r200Enable( GLcontext *ctx, GLenum cap, GLboolean state )
    }
 
    case GL_SCISSOR_TEST:
-      R200_FIREVERTICES( rmesa );
-      rmesa->state.scissor.enabled = state;
-      r200UpdateScissor( ctx );
+      radeon_firevertices(&rmesa->radeon);
+      rmesa->radeon.state.scissor.enabled = state;
+      radeonUpdateScissor( ctx );
       break;
 
    case GL_STENCIL_TEST:
-      if ( rmesa->state.stencil.hwBuffer ) {
-        R200_STATECHANGE( rmesa, ctx );
-        if ( state ) {
-           rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |=  R200_STENCIL_ENABLE;
+      {
+        GLboolean hw_stencil = GL_FALSE;
+        if (ctx->DrawBuffer) {
+           struct radeon_renderbuffer *rrbStencil
+              = radeon_get_renderbuffer(ctx->DrawBuffer, BUFFER_STENCIL);
+           hw_stencil = (rrbStencil && rrbStencil->bo);
+        }
+
+        if (hw_stencil) {
+           R200_STATECHANGE( rmesa, ctx );
+           if ( state ) {
+              rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |=  R200_STENCIL_ENABLE;
+           } else {
+              rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~R200_STENCIL_ENABLE;
+           }
         } else {
-           rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~R200_STENCIL_ENABLE;
+           FALLBACK( rmesa, R200_FALLBACK_STENCIL, state );
         }
-      } else {
-        FALLBACK( rmesa, R200_FALLBACK_STENCIL, state );
       }
       break;
 
@@ -2205,7 +2043,7 @@ static void r200Enable( GLcontext *ctx, GLenum cap, GLboolean state )
    case GL_TEXTURE_GEN_T:
       /* Picked up in r200UpdateTextureState.
        */
-      rmesa->recheck_texgen[ctx->Texture.CurrentUnit] = GL_TRUE; 
+      rmesa->recheck_texgen[ctx->Texture.CurrentUnit] = GL_TRUE;
       break;
 
    case GL_COLOR_SUM_EXT:
@@ -2322,7 +2160,7 @@ void r200LightingSpaceChange( GLcontext *ctx )
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
    GLboolean tmp;
 
-   if (R200_DEBUG & DEBUG_STATE) 
+   if (R200_DEBUG & DEBUG_STATE)
       fprintf(stderr, "%s %d BEFORE %x\n", __FUNCTION__, ctx->_NeedEyeCoords,
              rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0]);
 
@@ -2338,7 +2176,7 @@ void r200LightingSpaceChange( GLcontext *ctx )
       rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] &= ~R200_RESCALE_NORMALS;
    }
 
-   if (R200_DEBUG & DEBUG_STATE) 
+   if (R200_DEBUG & DEBUG_STATE)
       fprintf(stderr, "%s %d AFTER %x\n", __FUNCTION__, ctx->_NeedEyeCoords,
              rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0]);
 }
@@ -2381,7 +2219,7 @@ static void update_texturematrix( GLcontext *ctx )
    GLuint compsel = rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL];
    int unit;
 
-   if (R200_DEBUG & DEBUG_STATE) 
+   if (R200_DEBUG & DEBUG_STATE)
       fprintf(stderr, "%s before COMPSEL: %x\n", __FUNCTION__,
              rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL]);
 
@@ -2389,7 +2227,7 @@ static void update_texturematrix( GLcontext *ctx )
    rmesa->TexMatCompSel = 0;
 
    for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++) {
-      if (!ctx->Texture.Unit[unit]._ReallyEnabled) 
+      if (!ctx->Texture.Unit[unit]._ReallyEnabled)
         continue;
 
       if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY) {
@@ -2399,21 +2237,21 @@ static void update_texturematrix( GLcontext *ctx )
         rmesa->TexMatCompSel |= R200_OUTPUT_TEX_0 << unit;
 
         if (rmesa->TexGenEnabled & (R200_TEXMAT_0_ENABLE << unit)) {
-           /* Need to preconcatenate any active texgen 
+           /* Need to preconcatenate any active texgen
             * obj/eyeplane matrices:
             */
            _math_matrix_mul_matrix( &rmesa->tmpmat,
-                                    ctx->TextureMatrixStack[unit].Top, 
+                                    ctx->TextureMatrixStack[unit].Top,
                                     &rmesa->TexGenMatrix[unit] );
            upload_matrix( rmesa, rmesa->tmpmat.m, R200_MTX_TEX0+unit );
-        } 
+        }
         else {
-           upload_matrix( rmesa, ctx->TextureMatrixStack[unit].Top->m, 
+           upload_matrix( rmesa, ctx->TextureMatrixStack[unit].Top->m,
                           R200_MTX_TEX0+unit );
         }
       }
       else if (rmesa->TexGenEnabled & (R200_TEXMAT_0_ENABLE << unit)) {
-        upload_matrix( rmesa, rmesa->TexGenMatrix[unit].m, 
+        upload_matrix( rmesa, rmesa->TexGenMatrix[unit].m,
                        R200_MTX_TEX0+unit );
       }
    }
@@ -2432,69 +2270,78 @@ static void update_texturematrix( GLcontext *ctx )
    }
 }
 
-
-
-/**
- * Tell the card where to render (offset, pitch).
- * Effected by glDrawBuffer, etc
- */
-void
-r200UpdateDrawBuffer(GLcontext *ctx)
+static GLboolean r200ValidateBuffers(GLcontext *ctx)
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   struct gl_framebuffer *fb = ctx->DrawBuffer;
-   driRenderbuffer *drb;
+   struct radeon_renderbuffer *rrb;
+   int i;
 
-   if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
-      /* draw to front */
-      drb = (driRenderbuffer *) fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
-   }
-   else if (fb->_ColorDrawBufferIndexes[0] == BUFFER_BACK_LEFT) {
-      /* draw to back */
-      drb = (driRenderbuffer *) fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
+   radeon_validate_reset_bos(&rmesa->radeon);
+
+   rrb = radeon_get_colorbuffer(&rmesa->radeon);
+   /* color buffer */
+   if (rrb && rrb->bo) {
+     radeon_validate_bo(&rmesa->radeon, rrb->bo,
+                       0, RADEON_GEM_DOMAIN_VRAM);
    }
-   else {
-      /* drawing to multiple buffers, or none */
-      return;
+
+   /* depth buffer */
+   rrb = radeon_get_depthbuffer(&rmesa->radeon);
+   /* color buffer */
+   if (rrb && rrb->bo) {
+     radeon_validate_bo(&rmesa->radeon, rrb->bo,
+                       0, RADEON_GEM_DOMAIN_VRAM);
    }
 
-   assert(drb);
-   assert(drb->flippedPitch);
+   for (i = 0; i < ctx->Const.MaxTextureImageUnits; ++i) {
+      radeonTexObj *t;
 
-   R200_STATECHANGE( rmesa, ctx );
+      if (!ctx->Texture.Unit[i]._ReallyEnabled)
+        continue;
 
-   /* Note: we used the (possibly) page-flipped values */
-   rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET]
-     = ((drb->flippedOffset + rmesa->r200Screen->fbLocation)
-       & R200_COLOROFFSET_MASK);
-   rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = drb->flippedPitch;
-   if (rmesa->sarea->tiling_enabled) {
-      rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= R200_COLOR_TILE_ENABLE;
+      t = radeon_tex_obj(ctx->Texture.Unit[i]._Current);
+      if (t->image_override && t->bo)
+       radeon_validate_bo(&rmesa->radeon, t->bo,
+                          RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
+      else if (t->mt->bo)
+       radeon_validate_bo(&rmesa->radeon, t->mt->bo,
+                          RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
    }
-}
 
+   if (rmesa->radeon.dma.current)
+      radeon_validate_bo(&rmesa->radeon, rmesa->radeon.dma.current, RADEON_GEM_DOMAIN_GTT, 0);
 
+   return radeon_revalidate_bos(ctx);
+}
 
-void r200ValidateState( GLcontext *ctx )
+GLboolean r200ValidateState( GLcontext *ctx )
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   GLuint new_state = rmesa->NewGLState;
+   GLuint new_state = rmesa->radeon.NewGLState;
 
-   if (new_state & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL)) {
-     r200UpdateDrawBuffer(ctx);
+   if (new_state & _NEW_BUFFERS) {
+      _mesa_update_framebuffer(ctx);
+      /* this updates the DrawBuffer's Width/Height if it's a FBO */
+      _mesa_update_draw_buffer_bounds(ctx);
+
+      R200_STATECHANGE(rmesa, ctx);
    }
 
-   if (new_state & (_NEW_TEXTURE | _NEW_PROGRAM)) {
+   if (new_state & (_NEW_TEXTURE | _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS)) {
       r200UpdateTextureState( ctx );
-      new_state |= rmesa->NewGLState; /* may add TEXTURE_MATRIX */
+      new_state |= rmesa->radeon.NewGLState; /* may add TEXTURE_MATRIX */
       r200UpdateLocalViewer( ctx );
    }
 
+   /* we need to do a space check here */
+   if (!r200ValidateBuffers(ctx))
+     return GL_FALSE;
+
 /* FIXME: don't really need most of these when vertex progs are enabled */
 
    /* Need an event driven matrix update?
     */
-   if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION)) 
+   if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
       upload_matrix( rmesa, ctx->_ModelProjectMatrix.m, R200_MTX_MVP );
 
    /* Need these for lighting (shouldn't upload otherwise)
@@ -2518,11 +2365,12 @@ void r200ValidateState( GLcontext *ctx )
    /* emit all active clip planes if projection matrix changes.
     */
    if (new_state & (_NEW_PROJECTION)) {
-      if (ctx->Transform.ClipPlanesEnabled) 
+      if (ctx->Transform.ClipPlanesEnabled)
         r200UpdateClipPlanes( ctx );
    }
 
    if (new_state & (_NEW_PROGRAM|
+                    _NEW_PROGRAM_CONSTANTS |
    /* need to test for pretty much anything due to possible parameter bindings */
        _NEW_MODELVIEW|_NEW_PROJECTION|_NEW_TRANSFORM|
        _NEW_LIGHT|_NEW_TEXTURE|_NEW_TEXTURE_MATRIX|
@@ -2533,7 +2381,8 @@ void r200ValidateState( GLcontext *ctx )
       else TCL_FALLBACK(ctx, R200_TCL_FALLBACK_VERTEX_PROGRAM, 0);
    }
 
-   rmesa->NewGLState = 0;
+   rmesa->radeon.NewGLState = 0;
+   return GL_TRUE;
 }
 
 
@@ -2544,7 +2393,7 @@ static void r200InvalidateState( GLcontext *ctx, GLuint new_state )
    _vbo_InvalidateState( ctx, new_state );
    _tnl_InvalidateState( ctx, new_state );
    _ae_invalidate_state( ctx, new_state );
-   R200_CONTEXT(ctx)->NewGLState |= new_state;
+   R200_CONTEXT(ctx)->radeon.NewGLState |= new_state;
 }
 
 /* A hack.  The r200 can actually cope just fine with materials
@@ -2573,12 +2422,13 @@ static void r200WrapRunPipeline( GLcontext *ctx )
    GLboolean has_material;
 
    if (0)
-      fprintf(stderr, "%s, newstate: %x\n", __FUNCTION__, rmesa->NewGLState);
+      fprintf(stderr, "%s, newstate: %x\n", __FUNCTION__, rmesa->radeon.NewGLState);
 
    /* Validate state:
     */
-   if (rmesa->NewGLState)
-      r200ValidateState( ctx );
+   if (rmesa->radeon.NewGLState)
+      if (!r200ValidateState( ctx ))
+        FALLBACK(rmesa, RADEON_FALLBACK_TEXTURE, GL_TRUE);
 
    has_material = !ctx->VertexProgram._Enabled && ctx->Light.Enabled && check_material( ctx );
 
@@ -2587,7 +2437,7 @@ static void r200WrapRunPipeline( GLcontext *ctx )
    }
 
    /* Run the pipeline.
-    */ 
+    */
    _tnl_run_pipeline( ctx );
 
    if (has_material) {
@@ -2603,8 +2453,8 @@ void r200InitStateFuncs( struct dd_function_table *functions )
    functions->UpdateState              = r200InvalidateState;
    functions->LightingSpaceChange      = r200LightingSpaceChange;
 
-   functions->DrawBuffer               = r200DrawBuffer;
-   functions->ReadBuffer               = r200ReadBuffer;
+   functions->DrawBuffer               = radeonDrawBuffer;
+   functions->ReadBuffer               = radeonReadBuffer;
 
    functions->AlphaFunc                        = r200AlphaFunc;
    functions->BlendColor               = r200BlendColor;
@@ -2636,7 +2486,7 @@ void r200InitStateFuncs( struct dd_function_table *functions )
    functions->PointParameterfv         = r200PointParameter;
    functions->PointSize                        = r200PointSize;
    functions->RenderMode               = r200RenderMode;
-   functions->Scissor                  = r200Scissor;
+   functions->Scissor                  = radeonScissor;
    functions->ShadeModel               = r200ShadeModel;
    functions->StencilFuncSeparate      = r200StencilFuncSeparate;
    functions->StencilMaskSeparate      = r200StencilMaskSeparate;
index a917163a00ac6ff0cda144820cefda65e49ddb3c..23cf8aea6670cc23cbe7a23f1e52acf61594bb11 100644 (file)
@@ -43,23 +43,17 @@ extern void r200InitTnlFuncs( GLcontext *ctx );
 
 extern void r200UpdateMaterial( GLcontext *ctx );
 
-extern void r200SetCliprects( r200ContextPtr rmesa );
-extern void r200RecalcScissorRects( r200ContextPtr rmesa );
 extern void r200UpdateViewportOffset( GLcontext *ctx );
 extern void r200UpdateWindow( GLcontext *ctx );
 extern void r200UpdateDrawBuffer(GLcontext *ctx);
 
-extern void r200ValidateState( GLcontext *ctx );
-
-extern void r200PrintDirty( r200ContextPtr rmesa,
-                             const char *msg );
-
+extern GLboolean r200ValidateState( GLcontext *ctx );
 
 extern void r200Fallback( GLcontext *ctx, GLuint bit, GLboolean mode );
 #define FALLBACK( rmesa, bit, mode ) do {                              \
    if ( 0 ) fprintf( stderr, "FALLBACK in %s: #%d=%d\n",               \
                     __FUNCTION__, bit, mode );                         \
-   r200Fallback( rmesa->glCtx, bit, mode );                            \
+   r200Fallback( rmesa->radeon.glCtx, bit, mode );                             \
 } while (0)
 
 extern void r200LightingSpaceChange( GLcontext *ctx );
index 9e4677eda404ca60363390c2ab03c6fa253589a1..83920093378ab94f97e2095ece3854b0e66eadc2 100644 (file)
@@ -43,6 +43,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "tnl/t_pipeline.h"
 #include "swrast_setup/swrast_setup.h"
 
+#include "radeon_common.h"
+#include "radeon_mipmap_tree.h"
 #include "r200_context.h"
 #include "r200_ioctl.h"
 #include "r200_state.h"
@@ -52,31 +54,129 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "xmlpool.h"
 
+/* New (1.3) state mechanism.  3 commands (packet, scalar, vector) in
+ * 1.3 cmdbuffers allow all previous state to be updated as well as
+ * the tcl scalar and vector areas.
+ */
+static struct {
+       int start;
+       int len;
+       const char *name;
+} packet[RADEON_MAX_STATE_PACKETS] = {
+       {RADEON_PP_MISC, 7, "RADEON_PP_MISC"},
+       {RADEON_PP_CNTL, 3, "RADEON_PP_CNTL"},
+       {RADEON_RB3D_COLORPITCH, 1, "RADEON_RB3D_COLORPITCH"},
+       {RADEON_RE_LINE_PATTERN, 2, "RADEON_RE_LINE_PATTERN"},
+       {RADEON_SE_LINE_WIDTH, 1, "RADEON_SE_LINE_WIDTH"},
+       {RADEON_PP_LUM_MATRIX, 1, "RADEON_PP_LUM_MATRIX"},
+       {RADEON_PP_ROT_MATRIX_0, 2, "RADEON_PP_ROT_MATRIX_0"},
+       {RADEON_RB3D_STENCILREFMASK, 3, "RADEON_RB3D_STENCILREFMASK"},
+       {RADEON_SE_VPORT_XSCALE, 6, "RADEON_SE_VPORT_XSCALE"},
+       {RADEON_SE_CNTL, 2, "RADEON_SE_CNTL"},
+       {RADEON_SE_CNTL_STATUS, 1, "RADEON_SE_CNTL_STATUS"},
+       {RADEON_RE_MISC, 1, "RADEON_RE_MISC"},
+       {RADEON_PP_TXFILTER_0, 6, "RADEON_PP_TXFILTER_0"},
+       {RADEON_PP_BORDER_COLOR_0, 1, "RADEON_PP_BORDER_COLOR_0"},
+       {RADEON_PP_TXFILTER_1, 6, "RADEON_PP_TXFILTER_1"},
+       {RADEON_PP_BORDER_COLOR_1, 1, "RADEON_PP_BORDER_COLOR_1"},
+       {RADEON_PP_TXFILTER_2, 6, "RADEON_PP_TXFILTER_2"},
+       {RADEON_PP_BORDER_COLOR_2, 1, "RADEON_PP_BORDER_COLOR_2"},
+       {RADEON_SE_ZBIAS_FACTOR, 2, "RADEON_SE_ZBIAS_FACTOR"},
+       {RADEON_SE_TCL_OUTPUT_VTX_FMT, 11, "RADEON_SE_TCL_OUTPUT_VTX_FMT"},
+       {RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED, 17,
+                   "RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED"},
+       {R200_PP_TXCBLEND_0, 4, "R200_PP_TXCBLEND_0"},
+       {R200_PP_TXCBLEND_1, 4, "R200_PP_TXCBLEND_1"},
+       {R200_PP_TXCBLEND_2, 4, "R200_PP_TXCBLEND_2"},
+       {R200_PP_TXCBLEND_3, 4, "R200_PP_TXCBLEND_3"},
+       {R200_PP_TXCBLEND_4, 4, "R200_PP_TXCBLEND_4"},
+       {R200_PP_TXCBLEND_5, 4, "R200_PP_TXCBLEND_5"},
+       {R200_PP_TXCBLEND_6, 4, "R200_PP_TXCBLEND_6"},
+       {R200_PP_TXCBLEND_7, 4, "R200_PP_TXCBLEND_7"},
+       {R200_SE_TCL_LIGHT_MODEL_CTL_0, 6, "R200_SE_TCL_LIGHT_MODEL_CTL_0"},
+       {R200_PP_TFACTOR_0, 6, "R200_PP_TFACTOR_0"},
+       {R200_SE_VTX_FMT_0, 4, "R200_SE_VTX_FMT_0"},
+       {R200_SE_VAP_CNTL, 1, "R200_SE_VAP_CNTL"},
+       {R200_SE_TCL_MATRIX_SEL_0, 5, "R200_SE_TCL_MATRIX_SEL_0"},
+       {R200_SE_TCL_TEX_PROC_CTL_2, 5, "R200_SE_TCL_TEX_PROC_CTL_2"},
+       {R200_SE_TCL_UCP_VERT_BLEND_CTL, 1, "R200_SE_TCL_UCP_VERT_BLEND_CTL"},
+       {R200_PP_TXFILTER_0, 6, "R200_PP_TXFILTER_0"},
+       {R200_PP_TXFILTER_1, 6, "R200_PP_TXFILTER_1"},
+       {R200_PP_TXFILTER_2, 6, "R200_PP_TXFILTER_2"},
+       {R200_PP_TXFILTER_3, 6, "R200_PP_TXFILTER_3"},
+       {R200_PP_TXFILTER_4, 6, "R200_PP_TXFILTER_4"},
+       {R200_PP_TXFILTER_5, 6, "R200_PP_TXFILTER_5"},
+       {R200_PP_TXOFFSET_0, 1, "R200_PP_TXOFFSET_0"},
+       {R200_PP_TXOFFSET_1, 1, "R200_PP_TXOFFSET_1"},
+       {R200_PP_TXOFFSET_2, 1, "R200_PP_TXOFFSET_2"},
+       {R200_PP_TXOFFSET_3, 1, "R200_PP_TXOFFSET_3"},
+       {R200_PP_TXOFFSET_4, 1, "R200_PP_TXOFFSET_4"},
+       {R200_PP_TXOFFSET_5, 1, "R200_PP_TXOFFSET_5"},
+       {R200_SE_VTE_CNTL, 1, "R200_SE_VTE_CNTL"},
+       {R200_SE_TCL_OUTPUT_VTX_COMP_SEL, 1,
+        "R200_SE_TCL_OUTPUT_VTX_COMP_SEL"},
+       {R200_PP_TAM_DEBUG3, 1, "R200_PP_TAM_DEBUG3"},
+       {R200_PP_CNTL_X, 1, "R200_PP_CNTL_X"},
+       {R200_RB3D_DEPTHXY_OFFSET, 1, "R200_RB3D_DEPTHXY_OFFSET"},
+       {R200_RE_AUX_SCISSOR_CNTL, 1, "R200_RE_AUX_SCISSOR_CNTL"},
+       {R200_RE_SCISSOR_TL_0, 2, "R200_RE_SCISSOR_TL_0"},
+       {R200_RE_SCISSOR_TL_1, 2, "R200_RE_SCISSOR_TL_1"},
+       {R200_RE_SCISSOR_TL_2, 2, "R200_RE_SCISSOR_TL_2"},
+       {R200_SE_VAP_CNTL_STATUS, 1, "R200_SE_VAP_CNTL_STATUS"},
+       {R200_SE_VTX_STATE_CNTL, 1, "R200_SE_VTX_STATE_CNTL"},
+       {R200_RE_POINTSIZE, 1, "R200_RE_POINTSIZE"},
+       {R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0, 4,
+                   "R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0"},
+       {R200_PP_CUBIC_FACES_0, 1, "R200_PP_CUBIC_FACES_0"},    /* 61 */
+       {R200_PP_CUBIC_OFFSET_F1_0, 5, "R200_PP_CUBIC_OFFSET_F1_0"}, /* 62 */
+       {R200_PP_CUBIC_FACES_1, 1, "R200_PP_CUBIC_FACES_1"},
+       {R200_PP_CUBIC_OFFSET_F1_1, 5, "R200_PP_CUBIC_OFFSET_F1_1"},
+       {R200_PP_CUBIC_FACES_2, 1, "R200_PP_CUBIC_FACES_2"},
+       {R200_PP_CUBIC_OFFSET_F1_2, 5, "R200_PP_CUBIC_OFFSET_F1_2"},
+       {R200_PP_CUBIC_FACES_3, 1, "R200_PP_CUBIC_FACES_3"},
+       {R200_PP_CUBIC_OFFSET_F1_3, 5, "R200_PP_CUBIC_OFFSET_F1_3"},
+       {R200_PP_CUBIC_FACES_4, 1, "R200_PP_CUBIC_FACES_4"},
+       {R200_PP_CUBIC_OFFSET_F1_4, 5, "R200_PP_CUBIC_OFFSET_F1_4"},
+       {R200_PP_CUBIC_FACES_5, 1, "R200_PP_CUBIC_FACES_5"},
+       {R200_PP_CUBIC_OFFSET_F1_5, 5, "R200_PP_CUBIC_OFFSET_F1_5"},
+       {RADEON_PP_TEX_SIZE_0, 2, "RADEON_PP_TEX_SIZE_0"},
+       {RADEON_PP_TEX_SIZE_1, 2, "RADEON_PP_TEX_SIZE_1"},
+       {RADEON_PP_TEX_SIZE_2, 2, "RADEON_PP_TEX_SIZE_2"},
+       {R200_RB3D_BLENDCOLOR, 3, "R200_RB3D_BLENDCOLOR"},
+       {R200_SE_TCL_POINT_SPRITE_CNTL, 1, "R200_SE_TCL_POINT_SPRITE_CNTL"},
+       {RADEON_PP_CUBIC_FACES_0, 1, "RADEON_PP_CUBIC_FACES_0"},
+       {RADEON_PP_CUBIC_OFFSET_T0_0, 5, "RADEON_PP_CUBIC_OFFSET_T0_0"},
+       {RADEON_PP_CUBIC_FACES_1, 1, "RADEON_PP_CUBIC_FACES_1"},
+       {RADEON_PP_CUBIC_OFFSET_T1_0, 5, "RADEON_PP_CUBIC_OFFSET_T1_0"},
+       {RADEON_PP_CUBIC_FACES_2, 1, "RADEON_PP_CUBIC_FACES_2"},
+       {RADEON_PP_CUBIC_OFFSET_T2_0, 5, "RADEON_PP_CUBIC_OFFSET_T2_0"},
+       {R200_PP_TRI_PERF, 2, "R200_PP_TRI_PERF"},
+       {R200_PP_TXCBLEND_8, 32, "R200_PP_AFS_0"},     /* 85 */
+       {R200_PP_TXCBLEND_0, 32, "R200_PP_AFS_1"},
+       {R200_PP_TFACTOR_0, 8, "R200_ATF_TFACTOR"},
+       {R200_PP_TXFILTER_0, 8, "R200_PP_TXCTLALL_0"},
+       {R200_PP_TXFILTER_1, 8, "R200_PP_TXCTLALL_1"},
+       {R200_PP_TXFILTER_2, 8, "R200_PP_TXCTLALL_2"},
+       {R200_PP_TXFILTER_3, 8, "R200_PP_TXCTLALL_3"},
+       {R200_PP_TXFILTER_4, 8, "R200_PP_TXCTLALL_4"},
+       {R200_PP_TXFILTER_5, 8, "R200_PP_TXCTLALL_5"},
+       {R200_VAP_PVS_CNTL_1, 2, "R200_VAP_PVS_CNTL"},
+};
+
 /* =============================================================
  * State initialization
  */
-
-void r200PrintDirty( r200ContextPtr rmesa, const char *msg )
+static int cmdpkt( r200ContextPtr rmesa, int id ) 
 {
-   struct r200_state_atom *l;
-
-   fprintf(stderr, msg);
-   fprintf(stderr, ": ");
+   drm_radeon_cmd_header_t h;
 
-   foreach(l, &rmesa->hw.atomlist) {
-      if (l->dirty || rmesa->hw.all_dirty)
-        fprintf(stderr, "%s, ", l->name);
+   if (rmesa->radeon.radeonScreen->kernel_mm) {
+     return CP_PACKET0(packet[id].start, packet[id].len - 1);
+   } else {
+     h.i = 0;
+     h.packet.cmd_type = RADEON_CMD_PACKET;
+     h.packet.packet_id = id;
    }
-
-   fprintf(stderr, "\n");
-}
-
-static int cmdpkt( int id ) 
-{
-   drm_radeon_cmd_header_t h;
-   h.i = 0;
-   h.packet.cmd_type = RADEON_CMD_PACKET;
-   h.packet.packet_id = id;
    return h.i;
 }
 
@@ -127,150 +227,467 @@ static int cmdscl2( int offset, int stride, int count )
 }
 
 #define CHECK( NM, FLAG )                              \
-static GLboolean check_##NM( GLcontext *ctx, int idx ) \
+static int check_##NM( GLcontext *ctx, struct radeon_state_atom *atom) \
 {                                                      \
    r200ContextPtr rmesa = R200_CONTEXT(ctx);           \
-   (void) idx;                                         \
    (void) rmesa;                                       \
-   return FLAG;                                                \
+   return (FLAG) ? atom->cmd_size : 0;                 \
 }
 
 #define TCL_CHECK( NM, FLAG )                          \
-static GLboolean check_##NM( GLcontext *ctx, int idx ) \
-{                                                      \
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);           \
-   (void) idx;                                         \
-   return !rmesa->TclFallback && !ctx->VertexProgram._Enabled && (FLAG);       \
+static int check_##NM( GLcontext *ctx, struct radeon_state_atom *atom) \
+{                                                                      \
+   r200ContextPtr rmesa = R200_CONTEXT(ctx);                           \
+   return (!rmesa->radeon.TclFallback && !ctx->VertexProgram._Enabled && (FLAG)) ? atom->cmd_size : 0; \
 }
 
 #define TCL_OR_VP_CHECK( NM, FLAG )                    \
-static GLboolean check_##NM( GLcontext *ctx, int idx ) \
+static int check_##NM( GLcontext *ctx, struct radeon_state_atom *atom ) \
 {                                                      \
    r200ContextPtr rmesa = R200_CONTEXT(ctx);           \
-   (void) idx;                                         \
-   return !rmesa->TclFallback && (FLAG);               \
+   return (!rmesa->radeon.TclFallback && (FLAG)) ? atom->cmd_size : 0; \
 }
 
 #define VP_CHECK( NM, FLAG )                           \
-static GLboolean check_##NM( GLcontext *ctx, int idx ) \
-{                                                      \
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);           \
-   (void) idx;                                         \
-   return !rmesa->TclFallback && ctx->VertexProgram._Enabled && (FLAG);                \
+static int check_##NM( GLcontext *ctx, struct radeon_state_atom *atom ) \
+{                                                                      \
+   r200ContextPtr rmesa = R200_CONTEXT(ctx);                           \
+   (void) atom;                                                                \
+   return (!rmesa->radeon.TclFallback && ctx->VertexProgram._Enabled && (FLAG)) ? atom->cmd_size : 0; \
 }
 
-
 CHECK( always, GL_TRUE )
 CHECK( never, GL_FALSE )
 CHECK( tex_any, ctx->Texture._EnabledUnits )
 CHECK( tf, (ctx->Texture._EnabledUnits && !ctx->ATIFragmentShader._Enabled) );
-CHECK( tex_pair, (rmesa->state.texture.unit[idx].unitneeded | rmesa->state.texture.unit[idx & ~1].unitneeded) )
-CHECK( tex, rmesa->state.texture.unit[idx].unitneeded )
+CHECK( tex_pair, (rmesa->state.texture.unit[atom->idx].unitneeded | rmesa->state.texture.unit[atom->idx & ~1].unitneeded) )
+CHECK( tex, rmesa->state.texture.unit[atom->idx].unitneeded )
 CHECK( pix_zero, !ctx->ATIFragmentShader._Enabled )
-CHECK( texenv, (rmesa->state.envneeded & (1 << idx) && !ctx->ATIFragmentShader._Enabled) )
+   CHECK( texenv, (rmesa->state.envneeded & (1 << (atom->idx)) && !ctx->ATIFragmentShader._Enabled) )
 CHECK( afs_pass1, (ctx->ATIFragmentShader._Enabled && (ctx->ATIFragmentShader.Current->NumPasses > 1)) )
 CHECK( afs, ctx->ATIFragmentShader._Enabled )
-CHECK( tex_cube, rmesa->state.texture.unit[idx].unitneeded & TEXTURE_CUBE_BIT )
+CHECK( tex_cube, rmesa->state.texture.unit[atom->idx].unitneeded & TEXTURE_CUBE_BIT )
 TCL_CHECK( tcl_fog, ctx->Fog.Enabled )
 TCL_CHECK( tcl, GL_TRUE )
-TCL_CHECK( tcl_tex, rmesa->state.texture.unit[idx].unitneeded )
+TCL_CHECK( tcl_tex, rmesa->state.texture.unit[atom->idx].unitneeded )
 TCL_CHECK( tcl_lighting, ctx->Light.Enabled )
-TCL_CHECK( tcl_light, ctx->Light.Enabled && ctx->Light.Light[idx].Enabled )
-TCL_OR_VP_CHECK( tcl_ucp, (ctx->Transform.ClipPlanesEnabled & (1 << idx)) )
+TCL_CHECK( tcl_light, ctx->Light.Enabled && ctx->Light.Light[atom->idx].Enabled )
+TCL_OR_VP_CHECK( tcl_ucp, (ctx->Transform.ClipPlanesEnabled & (1 << (atom->idx))) )
 TCL_OR_VP_CHECK( tcl_or_vp, GL_TRUE )
 VP_CHECK( tcl_vp, GL_TRUE )
 VP_CHECK( tcl_vp_size, ctx->VertexProgram.Current->Base.NumNativeInstructions > 64 )
 VP_CHECK( tcl_vpp_size, ctx->VertexProgram.Current->Base.NumNativeParameters > 96 )
 
+#define OUT_VEC(hdr, data) do {                        \
+    drm_radeon_cmd_header_t h;                                 \
+    h.i = hdr;                                                         \
+    OUT_BATCH(CP_PACKET0(RADEON_SE_TCL_STATE_FLUSH, 0));               \
+    OUT_BATCH(0);                                                      \
+    OUT_BATCH(CP_PACKET0(R200_SE_TCL_VECTOR_INDX_REG, 0));             \
+    OUT_BATCH(h.vectors.offset | (h.vectors.stride << RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT)); \
+    OUT_BATCH(CP_PACKET0_ONE(R200_SE_TCL_VECTOR_DATA_REG, h.vectors.count - 1));       \
+    OUT_BATCH_TABLE((data), h.vectors.count);                          \
+  } while(0)
+
+#define OUT_VECLINEAR(hdr, data) do {                                  \
+    drm_radeon_cmd_header_t h;                                         \
+    uint32_t _start, _sz;                                              \
+    h.i = hdr;                                                         \
+    _start = h.veclinear.addr_lo | (h.veclinear.addr_hi << 8);         \
+    _sz = h.veclinear.count * 4;                                       \
+    if (r200->radeon.radeonScreen->kernel_mm && _sz) { \
+    BEGIN_BATCH_NO_AUTOSTATE(dwords); \
+    OUT_BATCH(CP_PACKET0(RADEON_SE_TCL_STATE_FLUSH, 0));               \
+    OUT_BATCH(0);                                                      \
+    OUT_BATCH(CP_PACKET0(R200_SE_TCL_VECTOR_INDX_REG, 0));             \
+    OUT_BATCH(_start | (1 << RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT));   \
+    OUT_BATCH(CP_PACKET0_ONE(R200_SE_TCL_VECTOR_DATA_REG, _sz - 1));   \
+    OUT_BATCH_TABLE((data), _sz);                                      \
+    END_BATCH(); \
+    } \
+  } while(0)
+
+#define OUT_SCL(hdr, data) do {                                        \
+    drm_radeon_cmd_header_t h;                                         \
+    h.i = hdr;                                                         \
+    OUT_BATCH(CP_PACKET0(R200_SE_TCL_SCALAR_INDX_REG, 0));             \
+    OUT_BATCH((h.scalars.offset) | (h.scalars.stride << RADEON_SCAL_INDX_DWORD_STRIDE_SHIFT)); \
+    OUT_BATCH(CP_PACKET0_ONE(R200_SE_TCL_SCALAR_DATA_REG, h.scalars.count - 1));       \
+    OUT_BATCH_TABLE((data), h.scalars.count);                          \
+  } while(0)
+
+#define OUT_SCL2(hdr, data) do {                                       \
+    drm_radeon_cmd_header_t h;                                         \
+    h.i = hdr;                                                         \
+    OUT_BATCH(CP_PACKET0(R200_SE_TCL_SCALAR_INDX_REG, 0));             \
+    OUT_BATCH((h.scalars.offset + 0x100) | (h.scalars.stride << RADEON_SCAL_INDX_DWORD_STRIDE_SHIFT)); \
+    OUT_BATCH(CP_PACKET0_ONE(R200_SE_TCL_SCALAR_DATA_REG, h.scalars.count - 1));       \
+    OUT_BATCH_TABLE((data), h.scalars.count);                          \
+  } while(0)
+
+static void mtl_emit(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+   r200ContextPtr r200 = R200_CONTEXT(ctx);
+   BATCH_LOCALS(&r200->radeon);
+   uint32_t dwords = atom->cmd_size;
+
+   dwords += 6;
+   BEGIN_BATCH_NO_AUTOSTATE(dwords);
+   OUT_VEC(atom->cmd[MTL_CMD_0], (atom->cmd+1));
+   OUT_SCL2(atom->cmd[MTL_CMD_1], (atom->cmd + 18));
+   END_BATCH();
+}
 
-/* Initialize the context's hardware state.
- */
-void r200InitState( r200ContextPtr rmesa )
+static void lit_emit(GLcontext *ctx, struct radeon_state_atom *atom)
 {
-   GLcontext *ctx = rmesa->glCtx;
-   GLuint color_fmt, depth_fmt, i;
-   GLint drawPitch, drawOffset;
+   r200ContextPtr r200 = R200_CONTEXT(ctx);
+   BATCH_LOCALS(&r200->radeon);
+   uint32_t dwords = atom->cmd_size;
+
+   dwords += 8;
+   BEGIN_BATCH_NO_AUTOSTATE(dwords);
+   OUT_VEC(atom->cmd[LIT_CMD_0], atom->cmd+1);
+   OUT_VEC(atom->cmd[LIT_CMD_1], atom->cmd+LIT_CMD_1+1);
+   END_BATCH();
+}
 
-   switch ( rmesa->r200Screen->cpp ) {
-   case 2:
-      color_fmt = R200_COLOR_FORMAT_RGB565;
-      break;
-   case 4:
-      color_fmt = R200_COLOR_FORMAT_ARGB8888;
-      break;
-   default:
-      fprintf( stderr, "Error: Unsupported pixel depth... exiting\n" );
-      exit( -1 );
+static void ptp_emit(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+   r200ContextPtr r200 = R200_CONTEXT(ctx);
+   BATCH_LOCALS(&r200->radeon);
+   uint32_t dwords = atom->cmd_size;
+
+   dwords += 8;
+   BEGIN_BATCH_NO_AUTOSTATE(dwords);
+   OUT_VEC(atom->cmd[PTP_CMD_0], atom->cmd+1);
+   OUT_VEC(atom->cmd[PTP_CMD_1], atom->cmd+PTP_CMD_1+1);
+   END_BATCH();
+}
+
+static void veclinear_emit(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+   r200ContextPtr r200 = R200_CONTEXT(ctx);
+   BATCH_LOCALS(&r200->radeon);
+   uint32_t dwords = atom->cmd_size;
+
+   dwords += 4;
+   OUT_VECLINEAR(atom->cmd[0], atom->cmd+1);
+}
+
+static void scl_emit(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+   r200ContextPtr r200 = R200_CONTEXT(ctx);
+   BATCH_LOCALS(&r200->radeon);
+   uint32_t dwords = atom->cmd_size;
+
+   dwords += 2;
+   BEGIN_BATCH_NO_AUTOSTATE(dwords);
+   OUT_SCL(atom->cmd[0], atom->cmd+1);
+   END_BATCH();
+}
+
+
+static void vec_emit(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+   r200ContextPtr r200 = R200_CONTEXT(ctx);
+   BATCH_LOCALS(&r200->radeon);
+   uint32_t dwords = atom->cmd_size;
+
+   dwords += 4;
+   BEGIN_BATCH_NO_AUTOSTATE(dwords);
+   OUT_VEC(atom->cmd[0], atom->cmd+1);
+   END_BATCH();
+}
+
+static void ctx_emit(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+   r200ContextPtr r200 = R200_CONTEXT(ctx);
+   BATCH_LOCALS(&r200->radeon);
+   struct radeon_renderbuffer *rrb;
+   uint32_t cbpitch;
+   uint32_t zbpitch, depth_fmt;
+   uint32_t dwords = atom->cmd_size;
+
+   /* output the first 7 bytes of context */
+   BEGIN_BATCH_NO_AUTOSTATE(dwords+2+2);
+   OUT_BATCH_TABLE(atom->cmd, 5);
+
+   rrb = radeon_get_depthbuffer(&r200->radeon);
+   if (!rrb) {
+     OUT_BATCH(0);
+     OUT_BATCH(0);
+   } else {
+     zbpitch = (rrb->pitch / rrb->cpp);
+     if (r200->using_hyperz)
+       zbpitch |= RADEON_DEPTH_HYPERZ;
+     OUT_BATCH_RELOC(0, rrb->bo, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+     OUT_BATCH(zbpitch);
+     if (rrb->cpp == 4) 
+       depth_fmt = RADEON_DEPTH_FORMAT_24BIT_INT_Z; 
+     else 
+       depth_fmt = RADEON_DEPTH_FORMAT_16BIT_INT_Z; 
+     atom->cmd[CTX_RB3D_ZSTENCILCNTL] &= ~RADEON_DEPTH_FORMAT_MASK; 
+     atom->cmd[CTX_RB3D_ZSTENCILCNTL] |= depth_fmt; 
+   }
+     
+   OUT_BATCH(atom->cmd[CTX_RB3D_ZSTENCILCNTL]);
+   OUT_BATCH(atom->cmd[CTX_CMD_1]);
+   OUT_BATCH(atom->cmd[CTX_PP_CNTL]);
+
+   rrb = radeon_get_colorbuffer(&r200->radeon);
+   if (!rrb || !rrb->bo) {
+     OUT_BATCH(atom->cmd[CTX_RB3D_CNTL]);
+     OUT_BATCH(atom->cmd[CTX_RB3D_COLOROFFSET]);
+   } else {
+     atom->cmd[CTX_RB3D_CNTL] &= ~(0xf << 10); 
+     if (rrb->cpp == 4) 
+       atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_ARGB8888; 
+     else 
+       atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_RGB565; 
+     OUT_BATCH(atom->cmd[CTX_RB3D_CNTL]); 
+     OUT_BATCH_RELOC(0, rrb->bo, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
    }
 
-   rmesa->state.color.clear = 0x00000000;
+   OUT_BATCH(atom->cmd[CTX_CMD_2]);
 
-   switch ( ctx->Visual.depthBits ) {
-   case 16:
-      rmesa->state.depth.clear = 0x0000ffff;
-      rmesa->state.depth.scale = 1.0 / (GLfloat)0xffff;
-      depth_fmt = R200_DEPTH_FORMAT_16BIT_INT_Z;
-      rmesa->state.stencil.clear = 0x00000000;
-      break;
-   case 24:
-      rmesa->state.depth.clear = 0x00ffffff;
-      rmesa->state.depth.scale = 1.0 / (GLfloat)0xffffff;
-      depth_fmt = R200_DEPTH_FORMAT_24BIT_INT_Z;
-      rmesa->state.stencil.clear = 0xffff0000;
-      break;
-   default:
-      fprintf( stderr, "Error: Unsupported depth %d... exiting\n",
-              ctx->Visual.depthBits );
-      exit( -1 );
+   if (!rrb || !rrb->bo) {
+     OUT_BATCH(atom->cmd[CTX_RB3D_COLORPITCH]);
+   } else {
+     cbpitch = (rrb->pitch / rrb->cpp);
+     if (rrb->bo->flags & RADEON_BO_FLAGS_MACRO_TILE)
+       cbpitch |= R200_COLOR_TILE_ENABLE;
+     OUT_BATCH(cbpitch);
    }
 
-   /* Only have hw stencil when depth buffer is 24 bits deep */
-   rmesa->state.stencil.hwBuffer = ( ctx->Visual.stencilBits > 0 &&
-                                    ctx->Visual.depthBits == 24 );
+   if (atom->cmd_size == CTX_STATE_SIZE_NEWDRM)
+     OUT_BATCH_TABLE((atom->cmd + 14), 4);
 
-   rmesa->Fallback = 0;
+   END_BATCH();
+}
 
-   if ( ctx->Visual.doubleBufferMode && rmesa->sarea->pfCurrentPage == 0 ) {
-      drawOffset = rmesa->r200Screen->backOffset;
-      drawPitch  = rmesa->r200Screen->backPitch;
-   } else {
-      drawOffset = rmesa->r200Screen->frontOffset;
-      drawPitch  = rmesa->r200Screen->frontPitch;
+static void ctx_emit_cs(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+   r200ContextPtr r200 = R200_CONTEXT(ctx);
+   BATCH_LOCALS(&r200->radeon);
+   struct radeon_renderbuffer *rrb, *drb;
+   uint32_t cbpitch = 0;
+   uint32_t zbpitch = 0;
+   uint32_t dwords = atom->cmd_size;
+   uint32_t depth_fmt;
+
+   rrb = radeon_get_colorbuffer(&r200->radeon);
+   if (!rrb || !rrb->bo) {
+      return;
+   }
+
+   atom->cmd[CTX_RB3D_CNTL] &= ~(0xf << 10);
+   if (rrb->cpp == 4)
+       atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_ARGB8888;
+   else
+       atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_RGB565;
+
+   cbpitch = (rrb->pitch / rrb->cpp);
+   if (rrb->bo->flags & RADEON_BO_FLAGS_MACRO_TILE)
+       cbpitch |= R200_COLOR_TILE_ENABLE;
+
+   drb = radeon_get_depthbuffer(&r200->radeon);
+   if (drb) {
+     zbpitch = (drb->pitch / drb->cpp);
+     if (drb->cpp == 4)
+        depth_fmt = RADEON_DEPTH_FORMAT_24BIT_INT_Z;
+     else
+        depth_fmt = RADEON_DEPTH_FORMAT_16BIT_INT_Z;
+     atom->cmd[CTX_RB3D_ZSTENCILCNTL] &= ~RADEON_DEPTH_FORMAT_MASK;
+     atom->cmd[CTX_RB3D_ZSTENCILCNTL] |= depth_fmt;
+   }
+
+   dwords = 10;
+   if (drb)
+     dwords += 6;
+   if (rrb)
+     dwords += 6;
+   if (atom->cmd_size == CTX_STATE_SIZE_NEWDRM)
+     dwords += 4;
+
+   /* output the first 7 bytes of context */
+   BEGIN_BATCH_NO_AUTOSTATE(dwords);
+
+   /* In the CS case we need to split this up */
+   OUT_BATCH(CP_PACKET0(packet[0].start, 3));
+   OUT_BATCH_TABLE((atom->cmd + 1), 4);
+
+   if (drb) {
+     OUT_BATCH(CP_PACKET0(RADEON_RB3D_DEPTHOFFSET, 0));
+     OUT_BATCH_RELOC(0, drb->bo, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+
+     OUT_BATCH(CP_PACKET0(RADEON_RB3D_DEPTHPITCH, 0));
+     OUT_BATCH(zbpitch);
+   }
+
+   OUT_BATCH(CP_PACKET0(RADEON_RB3D_ZSTENCILCNTL, 0));
+   OUT_BATCH(atom->cmd[CTX_RB3D_ZSTENCILCNTL]);
+   OUT_BATCH(CP_PACKET0(RADEON_PP_CNTL, 1));
+   OUT_BATCH(atom->cmd[CTX_PP_CNTL]);
+   OUT_BATCH(atom->cmd[CTX_RB3D_CNTL]);
+
+
+   if (rrb) {
+     OUT_BATCH(CP_PACKET0(RADEON_RB3D_COLOROFFSET, 0));
+     OUT_BATCH_RELOC(0, rrb->bo, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+
+     OUT_BATCH(CP_PACKET0(RADEON_RB3D_COLORPITCH, 0));
+     OUT_BATCH(cbpitch);
+   }
+
+   if (atom->cmd_size == CTX_STATE_SIZE_NEWDRM) {
+     OUT_BATCH_TABLE((atom->cmd + 14), 4);
    }
-#if 000
-   if ( ctx->Visual.doubleBufferMode && rmesa->sarea->pfCurrentPage == 0 ) {
-      rmesa->state.color.drawOffset = rmesa->r200Screen->backOffset;
-      rmesa->state.color.drawPitch  = rmesa->r200Screen->backPitch;
+
+   END_BATCH();
+}
+
+static void tex_emit(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+   r200ContextPtr r200 = R200_CONTEXT(ctx);
+   BATCH_LOCALS(&r200->radeon);
+   uint32_t dwords = atom->cmd_size;
+   int i = atom->idx;
+   radeonTexObj *t = r200->state.texture.unit[i].texobj;
+   radeon_mipmap_level *lvl;
+
+   if (t && t->mt && !t->image_override)
+     dwords += 2;
+   BEGIN_BATCH_NO_AUTOSTATE(dwords);
+   /* is this ok even with drm older than 1.18? */
+   OUT_BATCH_TABLE(atom->cmd, 10);
+
+   if (t && t->mt && !t->image_override) {
+     OUT_BATCH_RELOC(t->tile_bits, t->mt->bo, 0,
+                 RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);
+   } else if (!t) {
+     /* workaround for old CS mechanism */
+     OUT_BATCH(r200->radeon.radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP]);
    } else {
-      rmesa->state.color.drawOffset = rmesa->r200Screen->frontOffset;
-      rmesa->state.color.drawPitch  = rmesa->r200Screen->frontPitch;
+     OUT_BATCH(t->override_offset);
    }
 
-   rmesa->state.pixel.readOffset = rmesa->state.color.drawOffset;
-   rmesa->state.pixel.readPitch  = rmesa->state.color.drawPitch;
-#endif
+   END_BATCH();
+}
+
+static void tex_emit_cs(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+   r200ContextPtr r200 = R200_CONTEXT(ctx);
+   BATCH_LOCALS(&r200->radeon);
+   uint32_t dwords = atom->cmd_size;
+   int i = atom->idx;
+   radeonTexObj *t = r200->state.texture.unit[i].texobj;
+   radeon_mipmap_level *lvl;
+   int hastexture = 1;
+
+   if (!t)
+       hastexture = 0;
+   else {
+       if (!t->mt && !t->bo)
+               hastexture = 0;
+   }
+
+   if (hastexture)
+     dwords += 2;
+   else
+     dwords -= 2;
+   BEGIN_BATCH_NO_AUTOSTATE(dwords);
+
+   OUT_BATCH(CP_PACKET0(R200_PP_TXFILTER_0 + (32 * i), 7));
+   OUT_BATCH_TABLE((atom->cmd + 1), 8);
+
+   if (hastexture) {
+     OUT_BATCH(CP_PACKET0(R200_PP_TXOFFSET_0 + (24 * i), 0));
+     if (t->mt && !t->image_override) {
+        OUT_BATCH_RELOC(t->tile_bits, t->mt->bo, 0,
+                 RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);
+      } else {
+       if (t->bo)
+            OUT_BATCH_RELOC(t->tile_bits, t->bo, 0,
+                            RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);
+      }
+   }
+   END_BATCH();
+}
 
-   rmesa->hw.max_state_size = 0;
+
+static void cube_emit(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+   r200ContextPtr r200 = R200_CONTEXT(ctx);
+   BATCH_LOCALS(&r200->radeon);
+   uint32_t dwords = 2;
+   int i = atom->idx, j;
+   radeonTexObj *t = r200->state.texture.unit[i].texobj;
+   radeon_mipmap_level *lvl;
+
+   BEGIN_BATCH_NO_AUTOSTATE(dwords + (4 * 5));
+   OUT_BATCH_TABLE(atom->cmd, 2);
+
+   if (t && !t->image_override) {
+     lvl = &t->mt->levels[0];
+     for (j = 1; j <= 5; j++) {
+       OUT_BATCH(CP_PACKET0(R200_PP_CUBIC_OFFSET_F1_0 + (24*i) + (4 * (j-1)), 0));
+       OUT_BATCH_RELOC(lvl->faces[j].offset, t->mt->bo, lvl->faces[j].offset,
+                       RADEON_GEM_DOMAIN_VRAM, 0, 0);
+     }
+   }
+   END_BATCH();
+}
+
+/* Initialize the context's hardware state.
+ */
+void r200InitState( r200ContextPtr rmesa )
+{
+   GLcontext *ctx = rmesa->radeon.glCtx;
+   GLuint i;
+
+   rmesa->radeon.state.color.clear = 0x00000000;
+
+   switch ( ctx->Visual.depthBits ) {
+   case 16:
+      rmesa->radeon.state.depth.clear = 0x0000ffff;
+      rmesa->radeon.state.stencil.clear = 0x00000000;
+      break;
+   case 24:
+   default:
+      rmesa->radeon.state.depth.clear = 0x00ffffff;
+      rmesa->radeon.state.stencil.clear = 0xffff0000;
+      break;
+   }
+
+   rmesa->radeon.Fallback = 0;
+
+   rmesa->radeon.hw.max_state_size = 0;
 
 #define ALLOC_STATE( ATOM, CHK, SZ, NM, IDX )                          \
    do {                                                                \
       rmesa->hw.ATOM.cmd_size = SZ;                            \
-      rmesa->hw.ATOM.cmd = (int *)CALLOC(SZ * sizeof(int));    \
-      rmesa->hw.ATOM.lastcmd = (int *)CALLOC(SZ * sizeof(int));        \
+      rmesa->hw.ATOM.cmd = (GLuint *)CALLOC(SZ * sizeof(int)); \
+      rmesa->hw.ATOM.lastcmd = (GLuint *)CALLOC(SZ * sizeof(int));     \
       rmesa->hw.ATOM.name = NM;                                        \
       rmesa->hw.ATOM.idx = IDX;                                        \
       rmesa->hw.ATOM.check = check_##CHK;                      \
       rmesa->hw.ATOM.dirty = GL_FALSE;                         \
-      rmesa->hw.max_state_size += SZ * sizeof(int);            \
+      rmesa->radeon.hw.max_state_size += SZ * sizeof(int);             \
    } while (0)
 
 
    /* Allocate state buffers:
     */
-   if (rmesa->r200Screen->drmSupportsBlendColor)
+   if (rmesa->radeon.radeonScreen->drmSupportsBlendColor)
       ALLOC_STATE( ctx, always, CTX_STATE_SIZE_NEWDRM, "CTX/context", 0 );
    else
       ALLOC_STATE( ctx, always, CTX_STATE_SIZE_OLDDRM, "CTX/context", 0 );
+
+   if (rmesa->radeon.radeonScreen->kernel_mm)
+     rmesa->hw.ctx.emit = ctx_emit_cs;
+   else
+     rmesa->hw.ctx.emit = ctx_emit;
    ALLOC_STATE( set, always, SET_STATE_SIZE, "SET/setup", 0 );
    ALLOC_STATE( lin, always, LIN_STATE_SIZE, "LIN/line", 0 );
    ALLOC_STATE( msk, always, MSK_STATE_SIZE, "MSK/mask", 0 );
@@ -282,8 +699,8 @@ void r200InitState( r200ContextPtr rmesa )
    ALLOC_STATE( cst, always, CST_STATE_SIZE, "CST/constant", 0 );
    ALLOC_STATE( zbs, always, ZBS_STATE_SIZE, "ZBS/zbias", 0 );
    ALLOC_STATE( tf, tf, TF_STATE_SIZE, "TF/tfactor", 0 );
-   if (rmesa->r200Screen->drmSupportsFragShader) {
-      if (rmesa->r200Screen->chip_family == CHIP_FAMILY_R200) {
+   if (rmesa->radeon.radeonScreen->drmSupportsFragShader) {
+      if (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R200) {
       /* make sure texture units 0/1 are emitted pair-wise for r200 t0 hang workaround */
         ALLOC_STATE( tex[0], tex_pair, TEX_STATE_SIZE_NEWDRM, "TEX/tex-0", 0 );
         ALLOC_STATE( tex[1], tex_pair, TEX_STATE_SIZE_NEWDRM, "TEX/tex-1", 1 );
@@ -303,7 +720,7 @@ void r200InitState( r200ContextPtr rmesa )
       ALLOC_STATE( afs[1], afs, AFS_STATE_SIZE, "AFS/afsinst-1", 1 );
    }
    else {
-      if (rmesa->r200Screen->chip_family == CHIP_FAMILY_R200) {
+      if (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R200) {
         ALLOC_STATE( tex[0], tex_pair, TEX_STATE_SIZE_OLDDRM, "TEX/tex-0", 0 );
         ALLOC_STATE( tex[1], tex_pair, TEX_STATE_SIZE_OLDDRM, "TEX/tex-1", 1 );
         ALLOC_STATE( tam, tex_any, TAM_STATE_SIZE, "TAM/tam", 0 );
@@ -321,13 +738,21 @@ void r200InitState( r200ContextPtr rmesa )
       ALLOC_STATE( afs[0], never, AFS_STATE_SIZE, "AFS/afsinst-0", 0 );
       ALLOC_STATE( afs[1], never, AFS_STATE_SIZE, "AFS/afsinst-1", 1 );
    }
-   if (rmesa->r200Screen->drmSupportsCubeMapsR200) {
+
+   for (i = 0; i < 5; i++)
+      if (rmesa->radeon.radeonScreen->kernel_mm)
+          rmesa->hw.tex[i].emit = tex_emit_cs;
+      else
+          rmesa->hw.tex[i].emit = tex_emit;
+   if (rmesa->radeon.radeonScreen->drmSupportsCubeMapsR200) {
       ALLOC_STATE( cube[0], tex_cube, CUBE_STATE_SIZE, "CUBE/tex-0", 0 );
       ALLOC_STATE( cube[1], tex_cube, CUBE_STATE_SIZE, "CUBE/tex-1", 1 );
       ALLOC_STATE( cube[2], tex_cube, CUBE_STATE_SIZE, "CUBE/tex-2", 2 );
       ALLOC_STATE( cube[3], tex_cube, CUBE_STATE_SIZE, "CUBE/tex-3", 3 );
       ALLOC_STATE( cube[4], tex_cube, CUBE_STATE_SIZE, "CUBE/tex-4", 4 );
       ALLOC_STATE( cube[5], tex_cube, CUBE_STATE_SIZE, "CUBE/tex-5", 5 );
+      for (i = 0; i < 5; i++)
+       rmesa->hw.cube[i].emit = cube_emit;
    }
    else {
       ALLOC_STATE( cube[0], never, CUBE_STATE_SIZE, "CUBE/tex-0", 0 );
@@ -337,7 +762,8 @@ void r200InitState( r200ContextPtr rmesa )
       ALLOC_STATE( cube[4], never, CUBE_STATE_SIZE, "CUBE/tex-4", 4 );
       ALLOC_STATE( cube[5], never, CUBE_STATE_SIZE, "CUBE/tex-5", 5 );
    }
-   if (rmesa->r200Screen->drmSupportsVertexProgram) {
+
+   if (rmesa->radeon.radeonScreen->drmSupportsVertexProgram) {
       ALLOC_STATE( pvs, tcl_vp, PVS_STATE_SIZE, "PVS/pvscntl", 0 );
       ALLOC_STATE( vpi[0], tcl_vp, VPI_STATE_SIZE, "VP/vertexprog-0", 0 );
       ALLOC_STATE( vpi[1], tcl_vp_size, VPI_STATE_SIZE, "VP/vertexprog-1", 1 );
@@ -390,13 +816,13 @@ void r200InitState( r200ContextPtr rmesa )
    ALLOC_STATE( pix[3], texenv, PIX_STATE_SIZE, "PIX/pixstage-3", 3 );
    ALLOC_STATE( pix[4], texenv, PIX_STATE_SIZE, "PIX/pixstage-4", 4 );
    ALLOC_STATE( pix[5], texenv, PIX_STATE_SIZE, "PIX/pixstage-5", 5 );
-   if (rmesa->r200Screen->drmSupportsTriPerf) {
+   if (rmesa->radeon.radeonScreen->drmSupportsTriPerf) {
       ALLOC_STATE( prf, always, PRF_STATE_SIZE, "PRF/performance-tri", 0 );
    }
    else {
       ALLOC_STATE( prf, never, PRF_STATE_SIZE, "PRF/performance-tri", 0 );
    }
-   if (rmesa->r200Screen->drmSupportsPointSprites) {
+   if (rmesa->radeon.radeonScreen->drmSupportsPointSprites) {
       ALLOC_STATE( spr, always, SPR_STATE_SIZE, "SPR/pointsprite", 0 );
       ALLOC_STATE( ptp, tcl, PTP_STATE_SIZE, "PTP/pointparams", 0 );
    }
@@ -409,87 +835,115 @@ void r200InitState( r200ContextPtr rmesa )
 
    /* Fill in the packet headers:
     */
-   rmesa->hw.ctx.cmd[CTX_CMD_0] = cmdpkt(RADEON_EMIT_PP_MISC);
-   rmesa->hw.ctx.cmd[CTX_CMD_1] = cmdpkt(RADEON_EMIT_PP_CNTL);
-   rmesa->hw.ctx.cmd[CTX_CMD_2] = cmdpkt(RADEON_EMIT_RB3D_COLORPITCH);
-   if (rmesa->r200Screen->drmSupportsBlendColor)
-      rmesa->hw.ctx.cmd[CTX_CMD_3] = cmdpkt(R200_EMIT_RB3D_BLENDCOLOR);
-   rmesa->hw.lin.cmd[LIN_CMD_0] = cmdpkt(RADEON_EMIT_RE_LINE_PATTERN);
-   rmesa->hw.lin.cmd[LIN_CMD_1] = cmdpkt(RADEON_EMIT_SE_LINE_WIDTH);
-   rmesa->hw.msk.cmd[MSK_CMD_0] = cmdpkt(RADEON_EMIT_RB3D_STENCILREFMASK);
-   rmesa->hw.vpt.cmd[VPT_CMD_0] = cmdpkt(RADEON_EMIT_SE_VPORT_XSCALE);
-   rmesa->hw.set.cmd[SET_CMD_0] = cmdpkt(RADEON_EMIT_SE_CNTL);
-   rmesa->hw.msc.cmd[MSC_CMD_0] = cmdpkt(RADEON_EMIT_RE_MISC);
-   rmesa->hw.cst.cmd[CST_CMD_0] = cmdpkt(R200_EMIT_PP_CNTL_X);
-   rmesa->hw.cst.cmd[CST_CMD_1] = cmdpkt(R200_EMIT_RB3D_DEPTHXY_OFFSET);
-   rmesa->hw.cst.cmd[CST_CMD_2] = cmdpkt(R200_EMIT_RE_AUX_SCISSOR_CNTL);
-   rmesa->hw.cst.cmd[CST_CMD_3] = cmdpkt(R200_EMIT_RE_SCISSOR_TL_0);
-   rmesa->hw.cst.cmd[CST_CMD_4] = cmdpkt(R200_EMIT_SE_VAP_CNTL_STATUS);
-   rmesa->hw.cst.cmd[CST_CMD_5] = cmdpkt(R200_EMIT_RE_POINTSIZE);
-   rmesa->hw.cst.cmd[CST_CMD_6] = cmdpkt(R200_EMIT_TCL_INPUT_VTX_VECTOR_ADDR_0);
-   rmesa->hw.tam.cmd[TAM_CMD_0] = cmdpkt(R200_EMIT_PP_TAM_DEBUG3);
-   rmesa->hw.tf.cmd[TF_CMD_0] = cmdpkt(R200_EMIT_TFACTOR_0);
-   if (rmesa->r200Screen->drmSupportsFragShader) {
-      rmesa->hw.atf.cmd[ATF_CMD_0] = cmdpkt(R200_EMIT_ATF_TFACTOR);
-      rmesa->hw.tex[0].cmd[TEX_CMD_0] = cmdpkt(R200_EMIT_PP_TXCTLALL_0);
-      rmesa->hw.tex[0].cmd[TEX_CMD_1_NEWDRM] = cmdpkt(R200_EMIT_PP_TXOFFSET_0);
-      rmesa->hw.tex[1].cmd[TEX_CMD_0] = cmdpkt(R200_EMIT_PP_TXCTLALL_1);
-      rmesa->hw.tex[1].cmd[TEX_CMD_1_NEWDRM] = cmdpkt(R200_EMIT_PP_TXOFFSET_1);
-      rmesa->hw.tex[2].cmd[TEX_CMD_0] = cmdpkt(R200_EMIT_PP_TXCTLALL_2);
-      rmesa->hw.tex[2].cmd[TEX_CMD_1_NEWDRM] = cmdpkt(R200_EMIT_PP_TXOFFSET_2);
-      rmesa->hw.tex[3].cmd[TEX_CMD_0] = cmdpkt(R200_EMIT_PP_TXCTLALL_3);
-      rmesa->hw.tex[3].cmd[TEX_CMD_1_NEWDRM] = cmdpkt(R200_EMIT_PP_TXOFFSET_3);
-      rmesa->hw.tex[4].cmd[TEX_CMD_0] = cmdpkt(R200_EMIT_PP_TXCTLALL_4);
-      rmesa->hw.tex[4].cmd[TEX_CMD_1_NEWDRM] = cmdpkt(R200_EMIT_PP_TXOFFSET_4);
-      rmesa->hw.tex[5].cmd[TEX_CMD_0] = cmdpkt(R200_EMIT_PP_TXCTLALL_5);
-      rmesa->hw.tex[5].cmd[TEX_CMD_1_NEWDRM] = cmdpkt(R200_EMIT_PP_TXOFFSET_5);
+   rmesa->hw.ctx.cmd[CTX_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_PP_MISC);
+   rmesa->hw.ctx.cmd[CTX_CMD_1] = cmdpkt(rmesa, RADEON_EMIT_PP_CNTL);
+   rmesa->hw.ctx.cmd[CTX_CMD_2] = cmdpkt(rmesa, RADEON_EMIT_RB3D_COLORPITCH);
+   if (rmesa->radeon.radeonScreen->drmSupportsBlendColor)
+      rmesa->hw.ctx.cmd[CTX_CMD_3] = cmdpkt(rmesa, R200_EMIT_RB3D_BLENDCOLOR);
+   rmesa->hw.lin.cmd[LIN_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_RE_LINE_PATTERN);
+   rmesa->hw.lin.cmd[LIN_CMD_1] = cmdpkt(rmesa, RADEON_EMIT_SE_LINE_WIDTH);
+   rmesa->hw.msk.cmd[MSK_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_RB3D_STENCILREFMASK);
+   rmesa->hw.vpt.cmd[VPT_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_SE_VPORT_XSCALE);
+   rmesa->hw.set.cmd[SET_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_SE_CNTL);
+   rmesa->hw.msc.cmd[MSC_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_RE_MISC);
+   rmesa->hw.cst.cmd[CST_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_CNTL_X);
+   rmesa->hw.cst.cmd[CST_CMD_1] = cmdpkt(rmesa, R200_EMIT_RB3D_DEPTHXY_OFFSET);
+   rmesa->hw.cst.cmd[CST_CMD_2] = cmdpkt(rmesa, R200_EMIT_RE_AUX_SCISSOR_CNTL);
+   rmesa->hw.cst.cmd[CST_CMD_3] = cmdpkt(rmesa, R200_EMIT_RE_SCISSOR_TL_0);
+   rmesa->hw.cst.cmd[CST_CMD_4] = cmdpkt(rmesa, R200_EMIT_SE_VAP_CNTL_STATUS);
+   rmesa->hw.cst.cmd[CST_CMD_5] = cmdpkt(rmesa, R200_EMIT_RE_POINTSIZE);
+   rmesa->hw.cst.cmd[CST_CMD_6] = cmdpkt(rmesa, R200_EMIT_TCL_INPUT_VTX_VECTOR_ADDR_0);
+   rmesa->hw.tam.cmd[TAM_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_TAM_DEBUG3);
+   rmesa->hw.tf.cmd[TF_CMD_0] = cmdpkt(rmesa, R200_EMIT_TFACTOR_0);
+   if (rmesa->radeon.radeonScreen->drmSupportsFragShader) {
+      rmesa->hw.atf.cmd[ATF_CMD_0] = cmdpkt(rmesa, R200_EMIT_ATF_TFACTOR);
+      rmesa->hw.tex[0].cmd[TEX_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_TXCTLALL_0);
+      rmesa->hw.tex[0].cmd[TEX_CMD_1_NEWDRM] = cmdpkt(rmesa, R200_EMIT_PP_TXOFFSET_0);
+      rmesa->hw.tex[1].cmd[TEX_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_TXCTLALL_1);
+      rmesa->hw.tex[1].cmd[TEX_CMD_1_NEWDRM] = cmdpkt(rmesa, R200_EMIT_PP_TXOFFSET_1);
+      rmesa->hw.tex[2].cmd[TEX_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_TXCTLALL_2);
+      rmesa->hw.tex[2].cmd[TEX_CMD_1_NEWDRM] = cmdpkt(rmesa, R200_EMIT_PP_TXOFFSET_2);
+      rmesa->hw.tex[3].cmd[TEX_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_TXCTLALL_3);
+      rmesa->hw.tex[3].cmd[TEX_CMD_1_NEWDRM] = cmdpkt(rmesa, R200_EMIT_PP_TXOFFSET_3);
+      rmesa->hw.tex[4].cmd[TEX_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_TXCTLALL_4);
+      rmesa->hw.tex[4].cmd[TEX_CMD_1_NEWDRM] = cmdpkt(rmesa, R200_EMIT_PP_TXOFFSET_4);
+      rmesa->hw.tex[5].cmd[TEX_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_TXCTLALL_5);
+      rmesa->hw.tex[5].cmd[TEX_CMD_1_NEWDRM] = cmdpkt(rmesa, R200_EMIT_PP_TXOFFSET_5);
    } else {
-      rmesa->hw.tex[0].cmd[TEX_CMD_0] = cmdpkt(R200_EMIT_PP_TXFILTER_0);
-      rmesa->hw.tex[0].cmd[TEX_CMD_1_OLDDRM] = cmdpkt(R200_EMIT_PP_TXOFFSET_0);
-      rmesa->hw.tex[1].cmd[TEX_CMD_0] = cmdpkt(R200_EMIT_PP_TXFILTER_1);
-      rmesa->hw.tex[1].cmd[TEX_CMD_1_OLDDRM] = cmdpkt(R200_EMIT_PP_TXOFFSET_1);
-      rmesa->hw.tex[2].cmd[TEX_CMD_0] = cmdpkt(R200_EMIT_PP_TXFILTER_2);
-      rmesa->hw.tex[2].cmd[TEX_CMD_1_OLDDRM] = cmdpkt(R200_EMIT_PP_TXOFFSET_2);
-      rmesa->hw.tex[3].cmd[TEX_CMD_0] = cmdpkt(R200_EMIT_PP_TXFILTER_3);
-      rmesa->hw.tex[3].cmd[TEX_CMD_1_OLDDRM] = cmdpkt(R200_EMIT_PP_TXOFFSET_3);
-      rmesa->hw.tex[4].cmd[TEX_CMD_0] = cmdpkt(R200_EMIT_PP_TXFILTER_4);
-      rmesa->hw.tex[4].cmd[TEX_CMD_1_OLDDRM] = cmdpkt(R200_EMIT_PP_TXOFFSET_4);
-      rmesa->hw.tex[5].cmd[TEX_CMD_0] = cmdpkt(R200_EMIT_PP_TXFILTER_5);
-      rmesa->hw.tex[5].cmd[TEX_CMD_1_OLDDRM] = cmdpkt(R200_EMIT_PP_TXOFFSET_5);
-   }
-   rmesa->hw.afs[0].cmd[AFS_CMD_0] = cmdpkt(R200_EMIT_PP_AFS_0);
-   rmesa->hw.afs[1].cmd[AFS_CMD_0] = cmdpkt(R200_EMIT_PP_AFS_1);
-   rmesa->hw.pvs.cmd[PVS_CMD_0] = cmdpkt(R200_EMIT_VAP_PVS_CNTL);
-   rmesa->hw.cube[0].cmd[CUBE_CMD_0] = cmdpkt(R200_EMIT_PP_CUBIC_FACES_0);
-   rmesa->hw.cube[0].cmd[CUBE_CMD_1] = cmdpkt(R200_EMIT_PP_CUBIC_OFFSETS_0);
-   rmesa->hw.cube[1].cmd[CUBE_CMD_0] = cmdpkt(R200_EMIT_PP_CUBIC_FACES_1);
-   rmesa->hw.cube[1].cmd[CUBE_CMD_1] = cmdpkt(R200_EMIT_PP_CUBIC_OFFSETS_1);
-   rmesa->hw.cube[2].cmd[CUBE_CMD_0] = cmdpkt(R200_EMIT_PP_CUBIC_FACES_2);
-   rmesa->hw.cube[2].cmd[CUBE_CMD_1] = cmdpkt(R200_EMIT_PP_CUBIC_OFFSETS_2);
-   rmesa->hw.cube[3].cmd[CUBE_CMD_0] = cmdpkt(R200_EMIT_PP_CUBIC_FACES_3);
-   rmesa->hw.cube[3].cmd[CUBE_CMD_1] = cmdpkt(R200_EMIT_PP_CUBIC_OFFSETS_3);
-   rmesa->hw.cube[4].cmd[CUBE_CMD_0] = cmdpkt(R200_EMIT_PP_CUBIC_FACES_4);
-   rmesa->hw.cube[4].cmd[CUBE_CMD_1] = cmdpkt(R200_EMIT_PP_CUBIC_OFFSETS_4);
-   rmesa->hw.cube[5].cmd[CUBE_CMD_0] = cmdpkt(R200_EMIT_PP_CUBIC_FACES_5);
-   rmesa->hw.cube[5].cmd[CUBE_CMD_1] = cmdpkt(R200_EMIT_PP_CUBIC_OFFSETS_5);
-   rmesa->hw.pix[0].cmd[PIX_CMD_0] = cmdpkt(R200_EMIT_PP_TXCBLEND_0);
-   rmesa->hw.pix[1].cmd[PIX_CMD_0] = cmdpkt(R200_EMIT_PP_TXCBLEND_1);
-   rmesa->hw.pix[2].cmd[PIX_CMD_0] = cmdpkt(R200_EMIT_PP_TXCBLEND_2);
-   rmesa->hw.pix[3].cmd[PIX_CMD_0] = cmdpkt(R200_EMIT_PP_TXCBLEND_3);
-   rmesa->hw.pix[4].cmd[PIX_CMD_0] = cmdpkt(R200_EMIT_PP_TXCBLEND_4);
-   rmesa->hw.pix[5].cmd[PIX_CMD_0] = cmdpkt(R200_EMIT_PP_TXCBLEND_5);
-   rmesa->hw.zbs.cmd[ZBS_CMD_0] = cmdpkt(RADEON_EMIT_SE_ZBIAS_FACTOR);
-   rmesa->hw.tcl.cmd[TCL_CMD_0] = cmdpkt(R200_EMIT_TCL_LIGHT_MODEL_CTL_0);
-   rmesa->hw.tcl.cmd[TCL_CMD_1] = cmdpkt(R200_EMIT_TCL_UCP_VERT_BLEND_CTL);
-   rmesa->hw.tcg.cmd[TCG_CMD_0] = cmdpkt(R200_EMIT_TEX_PROC_CTL_2);
-   rmesa->hw.msl.cmd[MSL_CMD_0] = cmdpkt(R200_EMIT_MATRIX_SELECT_0);
-   rmesa->hw.vap.cmd[VAP_CMD_0] = cmdpkt(R200_EMIT_VAP_CTL);
-   rmesa->hw.vtx.cmd[VTX_CMD_0] = cmdpkt(R200_EMIT_VTX_FMT_0);
-   rmesa->hw.vtx.cmd[VTX_CMD_1] = cmdpkt(R200_EMIT_OUTPUT_VTX_COMP_SEL);
-   rmesa->hw.vtx.cmd[VTX_CMD_2] = cmdpkt(R200_EMIT_SE_VTX_STATE_CNTL);
-   rmesa->hw.vte.cmd[VTE_CMD_0] = cmdpkt(R200_EMIT_VTE_CNTL);
-   rmesa->hw.prf.cmd[PRF_CMD_0] = cmdpkt(R200_EMIT_PP_TRI_PERF_CNTL);
-   rmesa->hw.spr.cmd[SPR_CMD_0] = cmdpkt(R200_EMIT_TCL_POINT_SPRITE_CNTL);
+      rmesa->hw.tex[0].cmd[TEX_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_TXFILTER_0);
+      rmesa->hw.tex[0].cmd[TEX_CMD_1_OLDDRM] = cmdpkt(rmesa, R200_EMIT_PP_TXOFFSET_0);
+      rmesa->hw.tex[1].cmd[TEX_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_TXFILTER_1);
+      rmesa->hw.tex[1].cmd[TEX_CMD_1_OLDDRM] = cmdpkt(rmesa, R200_EMIT_PP_TXOFFSET_1);
+      rmesa->hw.tex[2].cmd[TEX_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_TXFILTER_2);
+      rmesa->hw.tex[2].cmd[TEX_CMD_1_OLDDRM] = cmdpkt(rmesa, R200_EMIT_PP_TXOFFSET_2);
+      rmesa->hw.tex[3].cmd[TEX_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_TXFILTER_3);
+      rmesa->hw.tex[3].cmd[TEX_CMD_1_OLDDRM] = cmdpkt(rmesa, R200_EMIT_PP_TXOFFSET_3);
+      rmesa->hw.tex[4].cmd[TEX_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_TXFILTER_4);
+      rmesa->hw.tex[4].cmd[TEX_CMD_1_OLDDRM] = cmdpkt(rmesa, R200_EMIT_PP_TXOFFSET_4);
+      rmesa->hw.tex[5].cmd[TEX_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_TXFILTER_5);
+      rmesa->hw.tex[5].cmd[TEX_CMD_1_OLDDRM] = cmdpkt(rmesa, R200_EMIT_PP_TXOFFSET_5);
+   }
+   rmesa->hw.afs[0].cmd[AFS_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_AFS_0);
+   rmesa->hw.afs[1].cmd[AFS_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_AFS_1);
+   rmesa->hw.pvs.cmd[PVS_CMD_0] = cmdpkt(rmesa, R200_EMIT_VAP_PVS_CNTL);
+   rmesa->hw.cube[0].cmd[CUBE_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_CUBIC_FACES_0);
+   rmesa->hw.cube[0].cmd[CUBE_CMD_1] = cmdpkt(rmesa, R200_EMIT_PP_CUBIC_OFFSETS_0);
+   rmesa->hw.cube[1].cmd[CUBE_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_CUBIC_FACES_1);
+   rmesa->hw.cube[1].cmd[CUBE_CMD_1] = cmdpkt(rmesa, R200_EMIT_PP_CUBIC_OFFSETS_1);
+   rmesa->hw.cube[2].cmd[CUBE_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_CUBIC_FACES_2);
+   rmesa->hw.cube[2].cmd[CUBE_CMD_1] = cmdpkt(rmesa, R200_EMIT_PP_CUBIC_OFFSETS_2);
+   rmesa->hw.cube[3].cmd[CUBE_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_CUBIC_FACES_3);
+   rmesa->hw.cube[3].cmd[CUBE_CMD_1] = cmdpkt(rmesa, R200_EMIT_PP_CUBIC_OFFSETS_3);
+   rmesa->hw.cube[4].cmd[CUBE_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_CUBIC_FACES_4);
+   rmesa->hw.cube[4].cmd[CUBE_CMD_1] = cmdpkt(rmesa, R200_EMIT_PP_CUBIC_OFFSETS_4);
+   rmesa->hw.cube[5].cmd[CUBE_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_CUBIC_FACES_5);
+   rmesa->hw.cube[5].cmd[CUBE_CMD_1] = cmdpkt(rmesa, R200_EMIT_PP_CUBIC_OFFSETS_5);
+   rmesa->hw.pix[0].cmd[PIX_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_TXCBLEND_0);
+   rmesa->hw.pix[1].cmd[PIX_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_TXCBLEND_1);
+   rmesa->hw.pix[2].cmd[PIX_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_TXCBLEND_2);
+   rmesa->hw.pix[3].cmd[PIX_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_TXCBLEND_3);
+   rmesa->hw.pix[4].cmd[PIX_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_TXCBLEND_4);
+   rmesa->hw.pix[5].cmd[PIX_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_TXCBLEND_5);
+   rmesa->hw.zbs.cmd[ZBS_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_SE_ZBIAS_FACTOR);
+   rmesa->hw.tcl.cmd[TCL_CMD_0] = cmdpkt(rmesa, R200_EMIT_TCL_LIGHT_MODEL_CTL_0);
+   rmesa->hw.tcl.cmd[TCL_CMD_1] = cmdpkt(rmesa, R200_EMIT_TCL_UCP_VERT_BLEND_CTL);
+   rmesa->hw.tcg.cmd[TCG_CMD_0] = cmdpkt(rmesa, R200_EMIT_TEX_PROC_CTL_2);
+   rmesa->hw.msl.cmd[MSL_CMD_0] = cmdpkt(rmesa, R200_EMIT_MATRIX_SELECT_0);
+   rmesa->hw.vap.cmd[VAP_CMD_0] = cmdpkt(rmesa, R200_EMIT_VAP_CTL);
+   rmesa->hw.vtx.cmd[VTX_CMD_0] = cmdpkt(rmesa, R200_EMIT_VTX_FMT_0);
+   rmesa->hw.vtx.cmd[VTX_CMD_1] = cmdpkt(rmesa, R200_EMIT_OUTPUT_VTX_COMP_SEL);
+   rmesa->hw.vtx.cmd[VTX_CMD_2] = cmdpkt(rmesa, R200_EMIT_SE_VTX_STATE_CNTL);
+   rmesa->hw.vte.cmd[VTE_CMD_0] = cmdpkt(rmesa, R200_EMIT_VTE_CNTL);
+   rmesa->hw.prf.cmd[PRF_CMD_0] = cmdpkt(rmesa, R200_EMIT_PP_TRI_PERF_CNTL);
+   rmesa->hw.spr.cmd[SPR_CMD_0] = cmdpkt(rmesa, R200_EMIT_TCL_POINT_SPRITE_CNTL);
+   if (rmesa->radeon.radeonScreen->kernel_mm) {
+       rmesa->hw.mtl[0].emit = mtl_emit;
+       rmesa->hw.mtl[1].emit = mtl_emit;
+
+       rmesa->hw.vpi[0].emit = veclinear_emit;
+       rmesa->hw.vpi[1].emit = veclinear_emit;
+       rmesa->hw.vpp[0].emit = veclinear_emit;
+       rmesa->hw.vpp[1].emit = veclinear_emit;
+
+       rmesa->hw.grd.emit = scl_emit;
+       rmesa->hw.fog.emit = vec_emit;
+       rmesa->hw.glt.emit = vec_emit;
+       rmesa->hw.eye.emit = vec_emit;
+
+       for (i = R200_MTX_MV; i <= R200_MTX_TEX5; i++)
+         rmesa->hw.mat[i].emit = vec_emit;
+
+       for (i = 0; i < 8; i++)
+         rmesa->hw.lit[i].emit = lit_emit;
+
+       for (i = 0; i < 6; i++)
+         rmesa->hw.ucp[i].emit = vec_emit;
+
+       rmesa->hw.ptp.emit = ptp_emit;
+   }
+
+
+   
    rmesa->hw.mtl[0].cmd[MTL_CMD_0] = 
       cmdvec( R200_VS_MAT_0_EMISS, 1, 16 );
    rmesa->hw.mtl[0].cmd[MTL_CMD_1] = 
@@ -567,7 +1021,7 @@ void r200InitState( r200ContextPtr rmesa )
                                (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
                                (R200_BLEND_GL_ZERO << R200_DST_BLEND_SHIFT));
 
-   if (rmesa->r200Screen->drmSupportsBlendColor) {
+   if (rmesa->radeon.radeonScreen->drmSupportsBlendColor) {
       rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCOLOR] = 0x00000000;
       rmesa->hw.ctx.cmd[CTX_RB3D_ABLENDCNTL] = (R200_COMB_FCN_ADD_CLAMP |
                                (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
@@ -578,18 +1032,17 @@ void r200InitState( r200ContextPtr rmesa )
    }
 
    rmesa->hw.ctx.cmd[CTX_RB3D_DEPTHOFFSET] =
-      rmesa->r200Screen->depthOffset + rmesa->r200Screen->fbLocation;
+      rmesa->radeon.radeonScreen->depthOffset + rmesa->radeon.radeonScreen->fbLocation;
 
    rmesa->hw.ctx.cmd[CTX_RB3D_DEPTHPITCH] = 
-      ((rmesa->r200Screen->depthPitch &
+      ((rmesa->radeon.radeonScreen->depthPitch &
        R200_DEPTHPITCH_MASK) |
        R200_DEPTH_ENDIAN_NO_SWAP);
    
    if (rmesa->using_hyperz)
       rmesa->hw.ctx.cmd[CTX_RB3D_DEPTHPITCH] |= R200_DEPTH_HYPERZ;
 
-   rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] = (depth_fmt |
-                                              R200_Z_TEST_LESS |
+   rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] = (R200_Z_TEST_LESS |
                                               R200_STENCIL_TEST_ALWAYS |
                                               R200_STENCIL_FAIL_KEEP |
                                               R200_STENCIL_ZPASS_KEEP |
@@ -599,15 +1052,14 @@ void r200InitState( r200ContextPtr rmesa )
    if (rmesa->using_hyperz) {
       rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_Z_COMPRESSION_ENABLE |
                                                  R200_Z_DECOMPRESSION_ENABLE;
-/*      if (rmesa->r200Screen->chip_family == CHIP_FAMILY_R200)
+/*      if (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R200)
         rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_Z_HIERARCHY_ENABLE;*/
    }
 
    rmesa->hw.ctx.cmd[CTX_PP_CNTL] = (R200_ANTI_ALIAS_NONE 
                                     | R200_TEX_BLEND_0_ENABLE);
 
-   rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] = color_fmt;
-   switch ( driQueryOptioni( &rmesa->optionCache, "dither_mode" ) ) {
+   switch ( driQueryOptioni( &rmesa->radeon.optionCache, "dither_mode" ) ) {
    case DRI_CONF_DITHER_XERRORDIFFRESET:
       rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= R200_DITHER_INIT;
       break;
@@ -615,41 +1067,19 @@ void r200InitState( r200ContextPtr rmesa )
       rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= R200_SCALE_DITHER_ENABLE;
       break;
    }
-   if ( driQueryOptioni( &rmesa->optionCache, "round_mode" ) ==
+   if ( driQueryOptioni( &rmesa->radeon.optionCache, "round_mode" ) ==
        DRI_CONF_ROUND_ROUND )
-      rmesa->state.color.roundEnable = R200_ROUND_ENABLE;
+      rmesa->radeon.state.color.roundEnable = R200_ROUND_ENABLE;
    else
-      rmesa->state.color.roundEnable = 0;
-   if ( driQueryOptioni (&rmesa->optionCache, "color_reduction" ) ==
+      rmesa->radeon.state.color.roundEnable = 0;
+   if ( driQueryOptioni (&rmesa->radeon.optionCache, "color_reduction" ) ==
        DRI_CONF_COLOR_REDUCTION_DITHER )
       rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= R200_DITHER_ENABLE;
    else
-      rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= rmesa->state.color.roundEnable;
-
-#if 000
-   rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = ((rmesa->state.color.drawOffset +
-                                              rmesa->r200Screen->fbLocation)
-                                             & R200_COLOROFFSET_MASK);
-
-   rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = ((rmesa->state.color.drawPitch &
-                                             R200_COLORPITCH_MASK) |
-                                            R200_COLOR_ENDIAN_NO_SWAP);
-#else
-   rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = ((drawOffset +
-                                              rmesa->r200Screen->fbLocation)
-                                             & R200_COLOROFFSET_MASK);
-
-   rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = ((drawPitch &
-                                             R200_COLORPITCH_MASK) |
-                                            R200_COLOR_ENDIAN_NO_SWAP);
-#endif
-   /* (fixed size) sarea is initialized to zero afaics so can omit version check. Phew! */
-   if (rmesa->sarea->tiling_enabled) {
-      rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= R200_COLOR_TILE_ENABLE;
-   }
+      rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= rmesa->radeon.state.color.roundEnable;
 
    rmesa->hw.prf.cmd[PRF_PP_TRI_PERF] = R200_TRI_CUTOFF_MASK - R200_TRI_CUTOFF_MASK * 
-                       driQueryOptionf (&rmesa->optionCache,"texture_blend_quality");
+                       driQueryOptionf (&rmesa->radeon.optionCache,"texture_blend_quality");
    rmesa->hw.prf.cmd[PRF_PP_PERF_CNTL] = 0;
 
    rmesa->hw.set.cmd[SET_SE_CNTL] = (R200_FFACE_CULL_CCW |
@@ -704,7 +1134,7 @@ void r200InitState( r200ContextPtr rmesa )
                                                R200_VC_NO_SWAP;
 #endif
 
-   if (!(rmesa->r200Screen->chip_flags & RADEON_CHIPSET_TCL)) {
+   if (!(rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL)) {
       /* Bypass TCL */
       rmesa->hw.cst.cmd[CST_SE_VAP_CNTL_STATUS] |= (1<<8);
    }
@@ -743,28 +1173,28 @@ void r200InitState( r200ContextPtr rmesa )
       rmesa->hw.tex[i].cmd[TEX_PP_TXFORMAT_X] =
          (/* R200_TEXCOORD_PROJ | */
           0x100000);   /* Small default bias */
-      if (rmesa->r200Screen->drmSupportsFragShader) {
+      if (rmesa->radeon.radeonScreen->drmSupportsFragShader) {
         rmesa->hw.tex[i].cmd[TEX_PP_TXOFFSET_NEWDRM] =
-            rmesa->r200Screen->texOffset[RADEON_LOCAL_TEX_HEAP];
+            rmesa->radeon.radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP];
         rmesa->hw.tex[i].cmd[TEX_PP_CUBIC_FACES] = 0;
         rmesa->hw.tex[i].cmd[TEX_PP_TXMULTI_CTL] = 0;
       }
       else {
          rmesa->hw.tex[i].cmd[TEX_PP_TXOFFSET_OLDDRM] =
-            rmesa->r200Screen->texOffset[RADEON_LOCAL_TEX_HEAP];
+            rmesa->radeon.radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP];
      }
 
       rmesa->hw.cube[i].cmd[CUBE_PP_CUBIC_FACES] = 0;
       rmesa->hw.cube[i].cmd[CUBE_PP_CUBIC_OFFSET_F1] =
-         rmesa->r200Screen->texOffset[RADEON_LOCAL_TEX_HEAP];
+         rmesa->radeon.radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP];
       rmesa->hw.cube[i].cmd[CUBE_PP_CUBIC_OFFSET_F2] =
-         rmesa->r200Screen->texOffset[RADEON_LOCAL_TEX_HEAP];
+         rmesa->radeon.radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP];
       rmesa->hw.cube[i].cmd[CUBE_PP_CUBIC_OFFSET_F3] =
-         rmesa->r200Screen->texOffset[RADEON_LOCAL_TEX_HEAP];
+         rmesa->radeon.radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP];
       rmesa->hw.cube[i].cmd[CUBE_PP_CUBIC_OFFSET_F4] =
-         rmesa->r200Screen->texOffset[RADEON_LOCAL_TEX_HEAP];
+         rmesa->radeon.radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP];
       rmesa->hw.cube[i].cmd[CUBE_PP_CUBIC_OFFSET_F5] =
-         rmesa->r200Screen->texOffset[RADEON_LOCAL_TEX_HEAP];
+         rmesa->radeon.radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP];
 
       rmesa->hw.pix[i].cmd[PIX_PP_TXCBLEND] =
          (R200_TXC_ARG_A_ZERO |
@@ -967,5 +1397,7 @@ void r200InitState( r200ContextPtr rmesa )
 
    r200LightingSpaceChange( ctx );
 
-   rmesa->hw.all_dirty = GL_TRUE;
+   rmesa->radeon.hw.all_dirty = GL_TRUE;
+
+   rcommonInitCmdBuf(&rmesa->radeon);
 }
index b25f0282445a75ff3ffc196749e73f6c0fa8f061..83e70b586d7f7b00c4c9544e67f00e46c347a619 100644 (file)
@@ -55,27 +55,24 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r200_tcl.h"
 
 
-static void flush_last_swtcl_prim( r200ContextPtr rmesa  );
-
-
 /***********************************************************************
- *                         Initialization 
+ *                         Initialization
  ***********************************************************************/
 
 #define EMIT_ATTR( ATTR, STYLE, F0 )                                   \
 do {                                                                   \
-   rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].attrib = (ATTR);  \
-   rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].format = (STYLE); \
-   rmesa->swtcl.vertex_attr_count++;                                   \
+   rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].attrib = (ATTR);    \
+   rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].format = (STYLE);   \
+   rmesa->radeon.swtcl.vertex_attr_count++;                                    \
    fmt_0 |= F0;                                                                \
 } while (0)
 
 #define EMIT_PAD( N )                                                  \
 do {                                                                   \
-   rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].attrib = 0;               \
-   rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].format = EMIT_PAD;        \
-   rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].offset = (N);             \
-   rmesa->swtcl.vertex_attr_count++;                                   \
+   rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].attrib = 0;         \
+   rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].format = EMIT_PAD;  \
+   rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].offset = (N);               \
+   rmesa->radeon.swtcl.vertex_attr_count++;                                    \
 } while (0)
 
 static void r200SetVertexFormat( GLcontext *ctx )
@@ -100,7 +97,7 @@ static void r200SetVertexFormat( GLcontext *ctx )
    }
 
    assert( VB->AttribPtr[VERT_ATTRIB_POS] != NULL );
-   rmesa->swtcl.vertex_attr_count = 0;
+   rmesa->radeon.swtcl.vertex_attr_count = 0;
 
    /* EMIT_ATTR's must be in order as they tell t_vertex.c how to
     * build up a hardware vertex.
@@ -121,7 +118,7 @@ static void r200SetVertexFormat( GLcontext *ctx )
    }
 
    rmesa->swtcl.coloroffset = offset;
-#if MESA_LITTLE_ENDIAN 
+#if MESA_LITTLE_ENDIAN
    EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_RGBA, (R200_VTX_PK_RGBA << R200_VTX_COLOR_0_SHIFT) );
 #else
    EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_ABGR, (R200_VTX_PK_RGBA << R200_VTX_COLOR_0_SHIFT) );
@@ -132,7 +129,7 @@ static void r200SetVertexFormat( GLcontext *ctx )
    if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 ) ||
        RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) {
 
-#if MESA_LITTLE_ENDIAN 
+#if MESA_LITTLE_ENDIAN
       if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) {
         rmesa->swtcl.specoffset = offset;
         EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_RGB, (R200_VTX_PK_RGBA << R200_VTX_COLOR_1_SHIFT) );
@@ -185,7 +182,7 @@ static void r200SetVertexFormat( GLcontext *ctx )
       rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] |= R200_FOG_USE_SPEC_ALPHA;
    }
 
-   if (!RENDERINPUTS_EQUAL( rmesa->tnl_index_bitset, index_bitset ) ||
+   if (!RENDERINPUTS_EQUAL( rmesa->radeon.tnl_index_bitset, index_bitset ) ||
        (rmesa->hw.vtx.cmd[VTX_VTXFMT_0] != fmt_0) ||
        (rmesa->hw.vtx.cmd[VTX_VTXFMT_1] != fmt_1) ) {
       R200_NEWPRIM(rmesa);
@@ -193,26 +190,20 @@ static void r200SetVertexFormat( GLcontext *ctx )
       rmesa->hw.vtx.cmd[VTX_VTXFMT_0] = fmt_0;
       rmesa->hw.vtx.cmd[VTX_VTXFMT_1] = fmt_1;
 
-      rmesa->swtcl.vertex_size =
+      rmesa->radeon.swtcl.vertex_size =
          _tnl_install_attrs( ctx,
-                             rmesa->swtcl.vertex_attrs, 
-                             rmesa->swtcl.vertex_attr_count,
+                             rmesa->radeon.swtcl.vertex_attrs,
+                             rmesa->radeon.swtcl.vertex_attr_count,
                              NULL, 0 );
-      rmesa->swtcl.vertex_size /= 4;
-      RENDERINPUTS_COPY( rmesa->tnl_index_bitset, index_bitset );
+      rmesa->radeon.swtcl.vertex_size /= 4;
+      RENDERINPUTS_COPY( rmesa->radeon.tnl_index_bitset, index_bitset );
    }
 }
 
 
 static void r200RenderStart( GLcontext *ctx )
 {
-   r200ContextPtr rmesa = R200_CONTEXT( ctx );
-
    r200SetVertexFormat( ctx );
-
-   if (rmesa->dma.flush != 0 && 
-       rmesa->dma.flush != flush_last_swtcl_prim)
-      rmesa->dma.flush( rmesa );
 }
 
 
@@ -232,7 +223,7 @@ void r200ChooseVertexState( GLcontext *ctx )
     * rasterization fallback.  As this function will be called again when we
     * leave a rasterization fallback, we can just skip it for now.
     */
-   if (rmesa->Fallback != 0)
+   if (rmesa->radeon.Fallback != 0)
       return;
 
    vte = rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL];
@@ -273,78 +264,27 @@ void r200ChooseVertexState( GLcontext *ctx )
    }
 }
 
-
-/* Flush vertices in the current dma region.
- */
-static void flush_last_swtcl_prim( r200ContextPtr rmesa  )
+void r200_swtcl_flush(GLcontext *ctx, uint32_t current_offset)
 {
-   if (R200_DEBUG & DEBUG_IOCTL)
-      fprintf(stderr, "%s\n", __FUNCTION__);
-
-   rmesa->dma.flush = NULL;
-
-   if (rmesa->dma.current.buf) {
-      struct r200_dma_region *current = &rmesa->dma.current;
-      GLuint current_offset = (rmesa->r200Screen->gart_buffer_offset +
-                              current->buf->buf->idx * RADEON_BUFFER_SIZE + 
-                              current->start);
-
-      assert (!(rmesa->swtcl.hw_primitive & R200_VF_PRIM_WALK_IND));
-
-      assert (current->start + 
-             rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 ==
-             current->ptr);
-
-      if (rmesa->dma.current.start != rmesa->dma.current.ptr) {
-        r200EnsureCmdBufSpace( rmesa, VERT_AOS_BUFSZ +
-                               rmesa->hw.max_state_size + VBUF_BUFSZ );
-        r200EmitVertexAOS( rmesa,
-                             rmesa->swtcl.vertex_size,
-                             current_offset);
-
-        r200EmitVbufPrim( rmesa,
-                          rmesa->swtcl.hw_primitive,
-                          rmesa->swtcl.numverts);
-      }
-
-      rmesa->swtcl.numverts = 0;
-      current->start = current->ptr;
-   }
-}
-
-
-/* Alloc space in the current dma region.
- */
-static INLINE void *
-r200AllocDmaLowVerts( r200ContextPtr rmesa, int nverts, int vsize )
-{
-   GLuint bytes = vsize * nverts;
-
-   if ( rmesa->dma.current.ptr + bytes > rmesa->dma.current.end ) 
-      r200RefillCurrentDmaRegion( rmesa );
+   r200ContextPtr rmesa = R200_CONTEXT(ctx);
+   rcommonEnsureCmdBufSpace(&rmesa->radeon,
+                           rmesa->radeon.hw.max_state_size + (12*sizeof(int)),
+                           __FUNCTION__);
 
-   if (!rmesa->dma.flush) {
-      rmesa->glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
-      rmesa->dma.flush = flush_last_swtcl_prim;
-   }
 
-   ASSERT( vsize == rmesa->swtcl.vertex_size * 4 );
-   ASSERT( rmesa->dma.flush == flush_last_swtcl_prim );
-   ASSERT( rmesa->dma.current.start + 
-          rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 ==
-          rmesa->dma.current.ptr );
+   radeonEmitState(&rmesa->radeon);
+   r200EmitVertexAOS( rmesa,
+                     rmesa->radeon.swtcl.vertex_size,
+                     rmesa->radeon.dma.current,
+                     current_offset);
 
 
-   {
-      GLubyte *head = (GLubyte *) (rmesa->dma.current.address + rmesa->dma.current.ptr);
-      rmesa->dma.current.ptr += bytes;
-      rmesa->swtcl.numverts += nverts;
-      return head;
-   }
+   r200EmitVbufPrim( rmesa,
+                    rmesa->radeon.swtcl.hw_primitive,
+                    rmesa->radeon.swtcl.numverts);
 
 }
 
-
 /**************************************************************************/
 
 
@@ -392,13 +332,13 @@ static void r200ResetLineStipple( GLcontext *ctx );
 #undef LOCAL_VARS
 #undef ALLOC_VERTS
 #define CTX_ARG r200ContextPtr rmesa
-#define GET_VERTEX_DWORDS() rmesa->swtcl.vertex_size
-#define ALLOC_VERTS( n, size ) r200AllocDmaLowVerts( rmesa, n, size * 4 )
+#define GET_VERTEX_DWORDS() rmesa->radeon.swtcl.vertex_size
+#define ALLOC_VERTS( n, size ) rcommonAllocDmaLowVerts( &rmesa->radeon, n, size * 4 )
 #define LOCAL_VARS                                             \
    r200ContextPtr rmesa = R200_CONTEXT(ctx);           \
-   const char *r200verts = (char *)rmesa->swtcl.verts;
-#define VERT(x) (r200Vertex *)(r200verts + ((x) * vertsize * sizeof(int)))
-#define VERTEX r200Vertex 
+   const char *r200verts = (char *)rmesa->radeon.swtcl.verts;
+#define VERT(x) (radeonVertex *)(r200verts + ((x) * vertsize * sizeof(int)))
+#define VERTEX radeonVertex
 #define DO_DEBUG_VERTS (1 && (R200_DEBUG & DEBUG_VERTS))
 
 #undef TAG
@@ -456,11 +396,11 @@ static struct {
 #define VERT_Y(_v) _v->v.y
 #define VERT_Z(_v) _v->v.z
 #define AREA_IS_CCW( a ) (a < 0)
-#define GET_VERTEX(e) (rmesa->swtcl.verts + (e*rmesa->swtcl.vertex_size*sizeof(int)))
+#define GET_VERTEX(e) (rmesa->radeon.swtcl.verts + (e*rmesa->radeon.swtcl.vertex_size*sizeof(int)))
 
 #define VERT_SET_RGBA( v, c )                                          \
 do {                                                           \
-   r200_color_t *color = (r200_color_t *)&((v)->ui[coloroffset]);      \
+   radeon_color_t *color = (radeon_color_t *)&((v)->ui[coloroffset]);  \
    UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]);               \
    UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]);             \
    UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]);              \
@@ -472,7 +412,7 @@ do {                                                                \
 #define VERT_SET_SPEC( v, c )                                  \
 do {                                                           \
    if (specoffset) {                                           \
-      r200_color_t *spec = (r200_color_t *)&((v)->ui[specoffset]);     \
+      radeon_color_t *spec = (radeon_color_t *)&((v)->ui[specoffset]); \
       UNCLAMPED_FLOAT_TO_UBYTE(spec->red, (c)[0]);     \
       UNCLAMPED_FLOAT_TO_UBYTE(spec->green, (c)[1]);   \
       UNCLAMPED_FLOAT_TO_UBYTE(spec->blue, (c)[2]);    \
@@ -481,8 +421,8 @@ do {                                                                \
 #define VERT_COPY_SPEC( v0, v1 )                       \
 do {                                                   \
    if (specoffset) {                                   \
-      r200_color_t *spec0 = (r200_color_t *)&((v0)->ui[specoffset]);   \
-      r200_color_t *spec1 = (r200_color_t *)&((v1)->ui[specoffset]);   \
+      radeon_color_t *spec0 = (radeon_color_t *)&((v0)->ui[specoffset]);       \
+      radeon_color_t *spec1 = (radeon_color_t *)&((v1)->ui[specoffset]);       \
       spec0->red   = spec1->red;       \
       spec0->green = spec1->green;     \
       spec0->blue  = spec1->blue;      \
@@ -513,7 +453,7 @@ do {                                                        \
  ***********************************************************************/
 
 #define RASTERIZE(x) r200RasterPrimitive( ctx, reduced_hw_prim(ctx, x) )
-#define RENDER_PRIMITIVE rmesa->swtcl.render_primitive
+#define RENDER_PRIMITIVE rmesa->radeon.swtcl.render_primitive
 #undef TAG
 #define TAG(x) x
 #include "tnl_dd/t_dd_unfilled.h"
@@ -569,8 +509,8 @@ static void init_rast_tab( void )
 #undef LOCAL_VARS
 #define LOCAL_VARS                                             \
    r200ContextPtr rmesa = R200_CONTEXT(ctx);           \
-   const GLuint vertsize = rmesa->swtcl.vertex_size;           \
-   const char *r200verts = (char *)rmesa->swtcl.verts;         \
+   const GLuint vertsize = rmesa->radeon.swtcl.vertex_size;            \
+   const char *r200verts = (char *)rmesa->radeon.swtcl.verts;          \
    const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts;       \
    const GLboolean stipple = ctx->Line.StippleFlag;            \
    (void) elt; (void) stipple;
@@ -599,13 +539,13 @@ void r200ChooseRenderState( GLcontext *ctx )
    GLuint index = 0;
    GLuint flags = ctx->_TriangleCaps;
 
-   if (!rmesa->TclFallback || rmesa->Fallback) 
+   if (!rmesa->radeon.TclFallback || rmesa->radeon.Fallback)
       return;
 
    if (flags & DD_TRI_LIGHT_TWOSIDE) index |= R200_TWOSIDE_BIT;
    if (flags & DD_TRI_UNFILLED)      index |= R200_UNFILLED_BIT;
 
-   if (index != rmesa->swtcl.RenderIndex) {
+   if (index != rmesa->radeon.swtcl.RenderIndex) {
       tnl->Driver.Render.Points = rast_tab[index].points;
       tnl->Driver.Render.Line = rast_tab[index].line;
       tnl->Driver.Render.ClippedLine = rast_tab[index].line;
@@ -622,7 +562,7 @@ void r200ChooseRenderState( GLcontext *ctx )
         tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon;
       }
 
-      rmesa->swtcl.RenderIndex = index;
+      rmesa->radeon.swtcl.RenderIndex = index;
    }
 }
 
@@ -636,7 +576,7 @@ static void r200RasterPrimitive( GLcontext *ctx, GLuint hwprim )
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
 
-   if (rmesa->swtcl.hw_primitive != hwprim) {
+   if (rmesa->radeon.swtcl.hw_primitive != hwprim) {
       /* need to disable perspective-correct texturing for point sprites */
       if ((hwprim & 0xf) == R200_VF_PRIM_POINT_SPRITES && ctx->Point.PointSprite) {
         if (rmesa->hw.set.cmd[SET_RE_CNTL] & R200_PERSPECTIVE_ENABLE) {
@@ -649,15 +589,15 @@ static void r200RasterPrimitive( GLcontext *ctx, GLuint hwprim )
         rmesa->hw.set.cmd[SET_RE_CNTL] |= R200_PERSPECTIVE_ENABLE;
       }
       R200_NEWPRIM( rmesa );
-      rmesa->swtcl.hw_primitive = hwprim;
+      rmesa->radeon.swtcl.hw_primitive = hwprim;
    }
 }
 
 static void r200RenderPrimitive( GLcontext *ctx, GLenum prim )
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   rmesa->swtcl.render_primitive = prim;
-   if (prim < GL_TRIANGLES || !(ctx->_TriangleCaps & DD_TRI_UNFILLED)) 
+   rmesa->radeon.swtcl.render_primitive = prim;
+   if (prim < GL_TRIANGLES || !(ctx->_TriangleCaps & DD_TRI_UNFILLED))
       r200RasterPrimitive( ctx, reduced_hw_prim(ctx, prim) );
 }
 
@@ -701,15 +641,15 @@ void r200Fallback( GLcontext *ctx, GLuint bit, GLboolean mode )
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
-   GLuint oldfallback = rmesa->Fallback;
+   GLuint oldfallback = rmesa->radeon.Fallback;
 
    if (mode) {
-      rmesa->Fallback |= bit;
+      rmesa->radeon.Fallback |= bit;
       if (oldfallback == 0) {
-        R200_FIREVERTICES( rmesa );
+        radeon_firevertices(&rmesa->radeon);
         TCL_FALLBACK( ctx, R200_TCL_FALLBACK_RASTER, GL_TRUE );
         _swsetup_Wakeup( ctx );
-        rmesa->swtcl.RenderIndex = ~0;
+        rmesa->radeon.swtcl.RenderIndex = ~0;
          if (R200_DEBUG & DEBUG_FALLBACKS) {
             fprintf(stderr, "R200 begin rasterization fallback: 0x%x %s\n",
                     bit, getFallbackString(bit));
@@ -717,7 +657,7 @@ void r200Fallback( GLcontext *ctx, GLuint bit, GLboolean mode )
       }
    }
    else {
-      rmesa->Fallback &= ~bit;
+      rmesa->radeon.Fallback &= ~bit;
       if (oldfallback == bit) {
 
         _swrast_flush( ctx );
@@ -731,14 +671,14 @@ void r200Fallback( GLcontext *ctx, GLuint bit, GLboolean mode )
 
         tnl->Driver.Render.ResetLineStipple = r200ResetLineStipple;
         TCL_FALLBACK( ctx, R200_TCL_FALLBACK_RASTER, GL_FALSE );
-        if (rmesa->TclFallback) {
-           /* These are already done if rmesa->TclFallback goes to
+        if (rmesa->radeon.TclFallback) {
+           /* These are already done if rmesa->radeon.TclFallback goes to
             * zero above. But not if it doesn't (R200_NO_TCL for
             * example?)
             */
            _tnl_invalidate_vertex_state( ctx, ~0 );
            _tnl_invalidate_vertices( ctx, ~0 );
-           RENDERINPUTS_ZERO( rmesa->tnl_index_bitset );
+           RENDERINPUTS_ZERO( rmesa->radeon.tnl_index_bitset );
            r200ChooseVertexState( ctx );
            r200ChooseRenderState( ctx );
         }
@@ -755,7 +695,7 @@ void r200Fallback( GLcontext *ctx, GLuint bit, GLboolean mode )
 
 /**
  * Cope with depth operations by drawing individual pixels as points.
- * 
+ *
  * \todo
  * The way the vertex state is set in this routine is hokey.  It seems to
  * work, but it's very hackish.  This whole routine is pretty hackish.  If
@@ -770,14 +710,14 @@ r200PointsBitmap( GLcontext *ctx, GLint px, GLint py,
                  const GLubyte *bitmap )
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   const GLfloat *rc = ctx->Current.RasterColor; 
+   const GLfloat *rc = ctx->Current.RasterColor;
    GLint row, col;
-   r200Vertex vert;
+   radeonVertex vert;
    GLuint orig_vte;
    GLuint h;
 
 
-   /* Turn off tcl.  
+   /* Turn off tcl.
     */
    TCL_FALLBACK( ctx, R200_TCL_FALLBACK_BITMAP, 1 );
 
@@ -794,7 +734,7 @@ r200PointsBitmap( GLcontext *ctx, GLint px, GLint py,
       vte |= R200_VTX_W0_FMT;
       vap &= ~R200_VAP_FORCE_W_TO_ONE;
 
-      rmesa->swtcl.vertex_size = 5;
+      rmesa->radeon.swtcl.vertex_size = 5;
 
       if ( (rmesa->hw.vtx.cmd[VTX_VTXFMT_0] != fmt_0)
           || (rmesa->hw.vtx.cmd[VTX_VTXFMT_1] != fmt_1) ) {
@@ -828,7 +768,7 @@ r200PointsBitmap( GLcontext *ctx, GLint px, GLint py,
                                           R200_VPORT_Z_SCALE_ENA |
                                           R200_VPORT_X_OFFSET_ENA |
                                           R200_VPORT_Y_OFFSET_ENA |
-                                          R200_VPORT_Z_OFFSET_ENA); 
+                                          R200_VPORT_Z_OFFSET_ENA);
 
    /* Turn off other stuff:  Stipple?, texture?, blending?, etc.
     */
@@ -871,16 +811,16 @@ r200PointsBitmap( GLcontext *ctx, GLint px, GLint py,
 
    /* Update window height
     */
-   LOCK_HARDWARE( rmesa );
-   UNLOCK_HARDWARE( rmesa );
-   h = rmesa->dri.drawable->h + rmesa->dri.drawable->y;
-   px += rmesa->dri.drawable->x;
+   LOCK_HARDWARE( &rmesa->radeon );
+   UNLOCK_HARDWARE( &rmesa->radeon );
+   h = radeon_get_drawable(&rmesa->radeon)->h + radeon_get_drawable(&rmesa->radeon)->y;
+   px += radeon_get_drawable(&rmesa->radeon)->x;
 
    /* Clipping handled by existing mechansims in r200_ioctl.c?
     */
    for (row=0; row<height; row++) {
-      const GLubyte *src = (const GLubyte *) 
-        _mesa_image_address2d(unpack, bitmap, width, height, 
+      const GLubyte *src = (const GLubyte *)
+        _mesa_image_address2d(unpack, bitmap, width, height,
                                GL_COLOR_INDEX, GL_BITMAP, row, 0 );
 
       if (unpack->LsbFirst) {
@@ -929,7 +869,7 @@ r200PointsBitmap( GLcontext *ctx, GLint px, GLint py,
 
    /* Need to restore vertexformat?
     */
-   if (rmesa->TclFallback)
+   if (rmesa->radeon.TclFallback)
       r200ChooseVertexState( ctx );
 }
 
@@ -959,20 +899,12 @@ void r200InitSwtcl( GLcontext *ctx )
    tnl->Driver.Render.Interp = _tnl_interp;
 
    /* FIXME: what are these numbers? */
-   _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12, 
+   _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
                       36 * sizeof(GLfloat) );
-   
-   rmesa->swtcl.verts = (GLubyte *)tnl->clipspace.vertex_buf;
-   rmesa->swtcl.RenderIndex = ~0;
-   rmesa->swtcl.render_primitive = GL_TRIANGLES;
-   rmesa->swtcl.hw_primitive = 0;
-}
-
 
-void r200DestroySwtcl( GLcontext *ctx )
-{
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);
-
-   if (rmesa->swtcl.indexed_verts.buf) 
-      r200ReleaseDmaRegion( rmesa, &rmesa->swtcl.indexed_verts, __FUNCTION__ );
+   rmesa->radeon.swtcl.verts = (GLubyte *)tnl->clipspace.vertex_buf;
+   rmesa->radeon.swtcl.RenderIndex = ~0;
+   rmesa->radeon.swtcl.render_primitive = GL_TRIANGLES;
+   rmesa->radeon.swtcl.hw_primitive = 0;
 }
+
index 8c29fd0c999ca874474dfb1a6c7de162865165ea..b0905879d7aed567c55f57ac1ff323c429e361d0 100644 (file)
@@ -39,7 +39,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r200_context.h"
 
 extern void r200InitSwtcl( GLcontext *ctx );
-extern void r200DestroySwtcl( GLcontext *ctx );
 
 extern void r200ChooseRenderState( GLcontext *ctx );
 extern void r200ChooseVertexState( GLcontext *ctx );
@@ -52,15 +51,11 @@ extern void r200BuildVertices( GLcontext *ctx, GLuint start, GLuint count,
 extern void r200PrintSetupFlags(char *msg, GLuint flags );
 
 
-extern void r200_emit_indexed_verts( GLcontext *ctx,
-                                      GLuint start,
-                                      GLuint count );
-
 extern void r200_translate_vertex( GLcontext *ctx, 
-                                    const r200Vertex *src, 
+                                    const radeonVertex *src, 
                                     SWvertex *dst );
 
-extern void r200_print_vertex( GLcontext *ctx, const r200Vertex *v );
+extern void r200_print_vertex( GLcontext *ctx, const radeonVertex *v );
 
 extern void r200_import_float_colors( GLcontext *ctx );
 extern void r200_import_float_spec_colors( GLcontext *ctx );
@@ -70,5 +65,5 @@ extern void r200PointsBitmap( GLcontext *ctx, GLint px, GLint py,
                              const struct gl_pixelstore_attrib *unpack,
                              const GLubyte *bitmap );
 
-
+void r200_swtcl_flush(GLcontext *ctx, uint32_t current_offset);
 #endif
index 99aecfe1e90050171534de7b225247c3b0852a89..580370933ee4612230ac332ca4b364ff16649388 100644 (file)
@@ -123,7 +123,7 @@ static GLboolean discrete_prim[0x10] = {
 
 #define RESET_STIPPLE() do {                   \
    R200_STATECHANGE( rmesa, lin );             \
-   r200EmitState( rmesa );                     \
+   radeonEmitState(&rmesa->radeon);                    \
 } while (0)
 
 #define AUTO_STIPPLE( mode )  do {             \
@@ -134,7 +134,7 @@ static GLboolean discrete_prim[0x10] = {
    else                                                \
       rmesa->hw.lin.cmd[LIN_RE_LINE_PATTERN] &=        \
         ~R200_LINE_PATTERN_AUTO_RESET; \
-   r200EmitState( rmesa );                     \
+   radeonEmitState(&rmesa->radeon);                    \
 } while (0)
 
 
@@ -142,26 +142,24 @@ static GLboolean discrete_prim[0x10] = {
 
 static GLushort *r200AllocElts( r200ContextPtr rmesa, GLuint nr ) 
 {
-   if (rmesa->dma.flush == r200FlushElts &&
-       rmesa->store.cmd_used + nr*2 < R200_CMD_BUF_SZ) {
+   if (rmesa->radeon.dma.flush == r200FlushElts &&
+       rmesa->tcl.elt_used + nr*2 < R200_ELT_BUF_SZ) {
 
-      GLushort *dest = (GLushort *)(rmesa->store.cmd_buf +
-                                   rmesa->store.cmd_used);
+      GLushort *dest = (GLushort *)(rmesa->radeon.tcl.elt_dma_bo->ptr +
+                                   rmesa->tcl.elt_used);
 
-      rmesa->store.cmd_used += nr*2;
+      rmesa->tcl.elt_used += nr*2;
 
       return dest;
    }
    else {
-      if (rmesa->dma.flush)
-        rmesa->dma.flush( rmesa );
+      if (rmesa->radeon.dma.flush)
+        rmesa->radeon.dma.flush( rmesa->radeon.glCtx );
 
-      r200EnsureCmdBufSpace( rmesa, AOS_BUFSZ(rmesa->tcl.nr_aos_components) +
-                            rmesa->hw.max_state_size + ELTS_BUFSZ(nr) );
+      rcommonEnsureCmdBufSpace(&rmesa->radeon, AOS_BUFSZ(rmesa->radeon.tcl.aos_count), __FUNCTION__);
 
       r200EmitAOS( rmesa,
-                  rmesa->tcl.aos_components,
-                  rmesa->tcl.nr_aos_components, 0 );
+                  rmesa->radeon.tcl.aos_count, 0 );
 
       return r200AllocEltsOpenEnded( rmesa, rmesa->tcl.hw_primitive, nr );
    }
@@ -188,13 +186,14 @@ static void r200EmitPrim( GLcontext *ctx,
    r200ContextPtr rmesa = R200_CONTEXT( ctx );
    r200TclPrimitive( ctx, prim, hwprim );
    
-   r200EnsureCmdBufSpace( rmesa, AOS_BUFSZ(rmesa->tcl.nr_aos_components) +
-                         rmesa->hw.max_state_size + VBUF_BUFSZ );
+   //   fprintf(stderr,"Emit prim %d\n", rmesa->radeon.tcl.aos_count);
+   rcommonEnsureCmdBufSpace( &rmesa->radeon,
+                            AOS_BUFSZ(rmesa->radeon.tcl.aos_count) +
+                            rmesa->radeon.hw.max_state_size + VBUF_BUFSZ, __FUNCTION__ );
 
    r200EmitAOS( rmesa,
-                 rmesa->tcl.aos_components,
-                 rmesa->tcl.nr_aos_components,
-                 start );
+               rmesa->radeon.tcl.aos_count,
+               start );
    
    /* Why couldn't this packet have taken an offset param?
     */
@@ -394,7 +393,7 @@ static GLboolean r200_run_tcl_render( GLcontext *ctx,
 
    /* TODO: separate this from the swtnl pipeline 
     */
-   if (rmesa->TclFallback)
+   if (rmesa->radeon.TclFallback)
       return GL_TRUE;  /* fallback to software t&l */
 
    if (R200_DEBUG & DEBUG_PRIMS)
@@ -405,8 +404,9 @@ static GLboolean r200_run_tcl_render( GLcontext *ctx,
 
    /* Validate state:
     */
-   if (rmesa->NewGLState)
-      r200ValidateState( ctx );
+   if (rmesa->radeon.NewGLState)
+      if (!r200ValidateState( ctx ))
+         return GL_TRUE; /* fallback to sw t&l */
 
    if (!ctx->VertexProgram._Enabled) {
    /* NOTE: inputs != tnl->render_inputs - these are the untransformed
@@ -481,7 +481,7 @@ static GLboolean r200_run_tcl_render( GLcontext *ctx,
 
    /* Do the actual work:
     */
-   r200ReleaseArrays( ctx, ~0 /* stage->changed_inputs */ );
+   radeonReleaseArrays( ctx, ~0 /* stage->changed_inputs */ );
    r200EmitArrays( ctx, vimap_rev );
 
    rmesa->tcl.Elts = VB->Elts;
@@ -545,7 +545,7 @@ static void transition_to_swtnl( GLcontext *ctx )
    tnl->Driver.NotifyMaterialChange = 
       _mesa_validate_all_lighting_tables;
 
-   r200ReleaseArrays( ctx, ~0 );
+   radeonReleaseArrays( ctx, ~0 );
 
    /* Still using the D3D based hardware-rasterizer from the radeon;
     * need to put the card into D3D mode to make it work:
@@ -565,15 +565,11 @@ static void transition_to_hwtnl( GLcontext *ctx )
 
    tnl->Driver.NotifyMaterialChange = r200UpdateMaterial;
 
-   if ( rmesa->dma.flush )                     
-      rmesa->dma.flush( rmesa );       
+   if ( rmesa->radeon.dma.flush )                      
+      rmesa->radeon.dma.flush( rmesa->radeon.glCtx );  
 
-   rmesa->dma.flush = NULL;
+   rmesa->radeon.dma.flush = NULL;
    
-   if (rmesa->swtcl.indexed_verts.buf) 
-      r200ReleaseDmaRegion( rmesa, &rmesa->swtcl.indexed_verts, 
-                             __FUNCTION__ );
-
    R200_STATECHANGE( rmesa, vap );
    rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] |= R200_VAP_TCL_ENABLE;
    rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] &= ~R200_VAP_FORCE_W_TO_ONE;
@@ -631,10 +627,10 @@ static char *getFallbackString(GLuint bit)
 void r200TclFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   GLuint oldfallback = rmesa->TclFallback;
+   GLuint oldfallback = rmesa->radeon.TclFallback;
 
    if (mode) {
-      rmesa->TclFallback |= bit;
+      rmesa->radeon.TclFallback |= bit;
       if (oldfallback == 0) {
         if (R200_DEBUG & DEBUG_FALLBACKS) 
            fprintf(stderr, "R200 begin tcl fallback %s\n",
@@ -643,7 +639,7 @@ void r200TclFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
       }
    }
    else {
-      rmesa->TclFallback &= ~bit;
+      rmesa->radeon.TclFallback &= ~bit;
       if (oldfallback == bit) {
         if (R200_DEBUG & DEBUG_FALLBACKS) 
            fprintf(stderr, "R200 end tcl fallback %s\n",
index 259f35a34c3638c223821e72b675b7f5035135f1..9f791579158e59128e8a9de67b9cdc59aa1bdecb 100644 (file)
@@ -43,8 +43,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/teximage.h"
 #include "main/texobj.h"
 
-#include "texmem.h"
-
+#include "radeon_mipmap_tree.h"
 #include "r200_context.h"
 #include "r200_state.h"
 #include "r200_ioctl.h"
@@ -63,10 +62,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  * \param twrap Wrap mode for the \a t texture coordinate
  */
 
-static void r200SetTexWrap( r200TexObjPtr t, GLenum swrap, GLenum twrap, GLenum rwrap )
+static void r200SetTexWrap( radeonTexObjPtr t, GLenum swrap, GLenum twrap, GLenum rwrap )
 {
    GLboolean  is_clamp = GL_FALSE;
    GLboolean  is_clamp_to_border = GL_FALSE;
+   struct gl_texture_object *tObj = &t->base;
 
    t->pp_txfilter &= ~(R200_CLAMP_S_MASK | R200_CLAMP_T_MASK | R200_BORDER_MODE_D3D);
 
@@ -103,7 +103,7 @@ static void r200SetTexWrap( r200TexObjPtr t, GLenum swrap, GLenum twrap, GLenum
       _mesa_problem(NULL, "bad S wrap mode in %s", __FUNCTION__);
    }
 
-   if (t->base.tObj->Target != GL_TEXTURE_1D) {
+   if (tObj->Target != GL_TEXTURE_1D) {
       switch ( twrap ) {
       case GL_REPEAT:
          t->pp_txfilter |= R200_CLAMP_T_WRAP;
@@ -180,7 +180,7 @@ static void r200SetTexWrap( r200TexObjPtr t, GLenum swrap, GLenum twrap, GLenum
    t->border_fallback = (is_clamp && is_clamp_to_border);
 }
 
-static void r200SetTexMaxAnisotropy( r200TexObjPtr t, GLfloat max )
+static void r200SetTexMaxAnisotropy( radeonTexObjPtr t, GLfloat max )
 {
    t->pp_txfilter &= ~R200_MAX_ANISO_MASK;
 
@@ -205,10 +205,13 @@ static void r200SetTexMaxAnisotropy( r200TexObjPtr t, GLfloat max )
  * \param magf Texture magnification mode
  */
 
-static void r200SetTexFilter( r200TexObjPtr t, GLenum minf, GLenum magf )
+static void r200SetTexFilter( radeonTexObjPtr t, GLenum minf, GLenum magf )
 {
    GLuint anisotropy = (t->pp_txfilter & R200_MAX_ANISO_MASK);
 
+   /* Force revalidation to account for switches from/to mipmapping. */
+   t->validated = GL_FALSE;
+
    t->pp_txfilter &= ~(R200_MIN_FILTER_MASK | R200_MAG_FILTER_MASK);
    t->pp_txformat_x &= ~R200_VOLUME_FILTER_MASK;
 
@@ -267,701 +270,16 @@ static void r200SetTexFilter( r200TexObjPtr t, GLenum minf, GLenum magf )
    }
 }
 
-static void r200SetTexBorderColor( r200TexObjPtr t, const GLfloat color[4] )
+static void r200SetTexBorderColor( radeonTexObjPtr t, const GLfloat color[4] )
 {
    GLubyte c[4];
    CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]);
    CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]);
    CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]);
    CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]);
-   t->pp_border_color = r200PackColor( 4, c[0], c[1], c[2], c[3] );
-}
-
-
-/**
- * Allocate space for and load the mesa images into the texture memory block.
- * This will happen before drawing with a new texture, or drawing with a
- * texture after it was swapped out or teximaged again.
- */
-
-static r200TexObjPtr r200AllocTexObj( struct gl_texture_object *texObj )
-{
-   r200TexObjPtr t;
-
-   t = CALLOC_STRUCT( r200_tex_obj );
-   texObj->DriverData = t;
-   if ( t != NULL ) {
-      if ( R200_DEBUG & DEBUG_TEXTURE ) {
-        fprintf( stderr, "%s( %p, %p )\n", __FUNCTION__, (void *)texObj, 
-                 (void *)t );
-      }
-
-      /* Initialize non-image-dependent parts of the state:
-       */
-      t->base.tObj = texObj;
-      t->border_fallback = GL_FALSE;
-
-      make_empty_list( & t->base );
-
-      r200SetTexWrap( t, texObj->WrapS, texObj->WrapT, texObj->WrapR );
-      r200SetTexMaxAnisotropy( t, texObj->MaxAnisotropy );
-      r200SetTexFilter( t, texObj->MinFilter, texObj->MagFilter );
-      r200SetTexBorderColor( t, texObj->BorderColor );
-   }
-
-   return t;
-}
-
-/* try to find a format which will only need a memcopy */
-static const struct gl_texture_format *
-r200Choose8888TexFormat( GLenum srcFormat, GLenum srcType )
-{
-   const GLuint ui = 1;
-   const GLubyte littleEndian = *((const GLubyte *) &ui);
-
-   if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
-       (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
-       (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
-       (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && littleEndian)) {
-      return &_mesa_texformat_rgba8888;
-   }
-   else if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
-       (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && littleEndian) ||
-       (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
-       (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && !littleEndian)) {
-      return &_mesa_texformat_rgba8888_rev;
-   }
-   else return _dri_texformat_argb8888;
-}
-
-static const struct gl_texture_format *
-r200ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
-                           GLenum format, GLenum type )
-{
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   const GLboolean do32bpt =
-       ( rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32 );
-   const GLboolean force16bpt =
-       ( rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16 );
-   (void) format;
-
-   switch ( internalFormat ) {
-   case 4:
-   case GL_RGBA:
-   case GL_COMPRESSED_RGBA:
-      switch ( type ) {
-      case GL_UNSIGNED_INT_10_10_10_2:
-      case GL_UNSIGNED_INT_2_10_10_10_REV:
-        return do32bpt ? _dri_texformat_argb8888 : _dri_texformat_argb1555;
-      case GL_UNSIGNED_SHORT_4_4_4_4:
-      case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-        return _dri_texformat_argb4444;
-      case GL_UNSIGNED_SHORT_5_5_5_1:
-      case GL_UNSIGNED_SHORT_1_5_5_5_REV:
-        return _dri_texformat_argb1555;
-      default:
-         return do32bpt ?
-           r200Choose8888TexFormat(format, type) : _dri_texformat_argb4444;
-      }
-
-   case 3:
-   case GL_RGB:
-   case GL_COMPRESSED_RGB:
-      switch ( type ) {
-      case GL_UNSIGNED_SHORT_4_4_4_4:
-      case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-        return _dri_texformat_argb4444;
-      case GL_UNSIGNED_SHORT_5_5_5_1:
-      case GL_UNSIGNED_SHORT_1_5_5_5_REV:
-        return _dri_texformat_argb1555;
-      case GL_UNSIGNED_SHORT_5_6_5:
-      case GL_UNSIGNED_SHORT_5_6_5_REV:
-        return _dri_texformat_rgb565;
-      default:
-         return do32bpt ? _dri_texformat_argb8888 : _dri_texformat_rgb565;
-      }
-
-   case GL_RGBA8:
-   case GL_RGB10_A2:
-   case GL_RGBA12:
-   case GL_RGBA16:
-      return !force16bpt ?
-         r200Choose8888TexFormat(format, type) : _dri_texformat_argb4444;
-
-   case GL_RGBA4:
-   case GL_RGBA2:
-      return _dri_texformat_argb4444;
-
-   case GL_RGB5_A1:
-      return _dri_texformat_argb1555;
-
-   case GL_RGB8:
-   case GL_RGB10:
-   case GL_RGB12:
-   case GL_RGB16:
-      return !force16bpt ? _dri_texformat_argb8888 : _dri_texformat_rgb565;
-
-   case GL_RGB5:
-   case GL_RGB4:
-   case GL_R3_G3_B2:
-      return _dri_texformat_rgb565;
-
-   case GL_ALPHA:
-   case GL_ALPHA4:
-   case GL_ALPHA8:
-   case GL_ALPHA12:
-   case GL_ALPHA16:
-   case GL_COMPRESSED_ALPHA:
-   /* can't use a8 format since interpreting hw I8 as a8 would result
-      in wrong rgb values (same as alpha value instead of 0). */
-      return _dri_texformat_al88;
-
-   case 1:
-   case GL_LUMINANCE:
-   case GL_LUMINANCE4:
-   case GL_LUMINANCE8:
-   case GL_LUMINANCE12:
-   case GL_LUMINANCE16:
-   case GL_COMPRESSED_LUMINANCE:
-      return _dri_texformat_l8;
-
-   case 2:
-   case GL_LUMINANCE_ALPHA:
-   case GL_LUMINANCE4_ALPHA4:
-   case GL_LUMINANCE6_ALPHA2:
-   case GL_LUMINANCE8_ALPHA8:
-   case GL_LUMINANCE12_ALPHA4:
-   case GL_LUMINANCE12_ALPHA12:
-   case GL_LUMINANCE16_ALPHA16:
-   case GL_COMPRESSED_LUMINANCE_ALPHA:
-      return _dri_texformat_al88;
-
-   case GL_INTENSITY:
-   case GL_INTENSITY4:
-   case GL_INTENSITY8:
-   case GL_INTENSITY12:
-   case GL_INTENSITY16:
-   case GL_COMPRESSED_INTENSITY:
-       return _dri_texformat_i8;
-
-   case GL_YCBCR_MESA:
-      if (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
-          type == GL_UNSIGNED_BYTE)
-         return &_mesa_texformat_ycbcr;
-      else
-         return &_mesa_texformat_ycbcr_rev;
-
-   case GL_RGB_S3TC:
-   case GL_RGB4_S3TC:
-   case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-      return &_mesa_texformat_rgb_dxt1;
-
-   case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-      return &_mesa_texformat_rgba_dxt1;
-
-   case GL_RGBA_S3TC:
-   case GL_RGBA4_S3TC:
-   case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
-      return &_mesa_texformat_rgba_dxt3;
-
-   case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
-      return &_mesa_texformat_rgba_dxt5;
-
-   default:
-      _mesa_problem(ctx,
-         "unexpected internalFormat 0x%x in r200ChooseTextureFormat",
-         (int) internalFormat);
-      return NULL;
-   }
-
-   return NULL; /* never get here */
-}
-
-
-static GLboolean
-r200ValidateClientStorage( GLcontext *ctx, GLenum target,
-                          GLint internalFormat,
-                          GLint srcWidth, GLint srcHeight, 
-                           GLenum format, GLenum type,  const void *pixels,
-                          const struct gl_pixelstore_attrib *packing,
-                          struct gl_texture_object *texObj,
-                          struct gl_texture_image *texImage)
-
-{
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);
-
-   if ( R200_DEBUG & DEBUG_TEXTURE )
-      fprintf(stderr, "intformat %s format %s type %s\n",
-             _mesa_lookup_enum_by_nr( internalFormat ),
-             _mesa_lookup_enum_by_nr( format ),
-             _mesa_lookup_enum_by_nr( type ));
-
-   if (!ctx->Unpack.ClientStorage)
-      return 0;
-
-   if (ctx->_ImageTransferState ||
-       texImage->IsCompressed ||
-       texObj->GenerateMipmap)
-      return 0;
-
-
-   /* This list is incomplete, may be different on ppc???
-    */
-   switch ( internalFormat ) {
-   case GL_RGBA:
-      if ( format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV ) {
-        texImage->TexFormat = _dri_texformat_argb8888;
-      }
-      else
-        return 0;
-      break;
-
-   case GL_RGB:
-      if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
-        texImage->TexFormat = _dri_texformat_rgb565;
-      }
-      else
-        return 0;
-      break;
-
-   case GL_YCBCR_MESA:
-      if ( format == GL_YCBCR_MESA && 
-          type == GL_UNSIGNED_SHORT_8_8_REV_APPLE ) {
-        texImage->TexFormat = &_mesa_texformat_ycbcr_rev;
-      }
-      else if ( format == GL_YCBCR_MESA && 
-               (type == GL_UNSIGNED_SHORT_8_8_APPLE || 
-                type == GL_UNSIGNED_BYTE)) {
-        texImage->TexFormat = &_mesa_texformat_ycbcr;
-      }
-      else
-        return 0;
-      break;
-
-   default:
-      return 0;
-   }
-
-   /* Could deal with these packing issues, but currently don't:
-    */
-   if (packing->SkipPixels || 
-       packing->SkipRows || 
-       packing->SwapBytes ||
-       packing->LsbFirst) {
-      return 0;
-   }
-
-   {      
-      GLint srcRowStride = _mesa_image_row_stride(packing, srcWidth,
-                                                 format, type);
-
-      
-      if ( R200_DEBUG & DEBUG_TEXTURE )
-        fprintf(stderr, "%s: srcRowStride %d/%x\n", 
-                __FUNCTION__, srcRowStride, srcRowStride);
-
-      /* Could check this later in upload, pitch restrictions could be
-       * relaxed, but would need to store the image pitch somewhere,
-       * as packing details might change before image is uploaded:
-       */
-      if (!r200IsGartMemory( rmesa, pixels, srcHeight * srcRowStride ) ||
-         (srcRowStride & 63))
-        return 0;
-
-
-      /* Have validated that _mesa_transfer_teximage would be a straight
-       * memcpy at this point.  NOTE: future calls to TexSubImage will
-       * overwrite the client data.  This is explicitly mentioned in the
-       * extension spec.
-       */
-      texImage->Data = (void *)pixels;
-      texImage->IsClientData = GL_TRUE;
-      texImage->RowStride = srcRowStride / texImage->TexFormat->TexelBytes;
-
-      return 1;
-   }
-}
-
-
-static void r200TexImage1D( GLcontext *ctx, GLenum target, GLint level,
-                              GLint internalFormat,
-                              GLint width, GLint border,
-                              GLenum format, GLenum type, const GLvoid *pixels,
-                              const struct gl_pixelstore_attrib *packing,
-                              struct gl_texture_object *texObj,
-                              struct gl_texture_image *texImage )
-{
-   driTextureObject * t = (driTextureObject *) texObj->DriverData;
-
-   if ( t ) {
-      driSwapOutTextureObject( t );
-   }
-   else {
-      t = (driTextureObject *) r200AllocTexObj( texObj );
-      if (!t) {
-         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
-         return;
-      }
-   }
-
-   /* Note, this will call ChooseTextureFormat */
-   _mesa_store_teximage1d(ctx, target, level, internalFormat,
-                          width, border, format, type, pixels,
-                          &ctx->Unpack, texObj, texImage);
-
-   t->dirty_images[0] |= (1 << level);
-}
-
-
-static void r200TexSubImage1D( GLcontext *ctx, GLenum target, GLint level,
-                                 GLint xoffset,
-                                 GLsizei width,
-                                 GLenum format, GLenum type,
-                                 const GLvoid *pixels,
-                                 const struct gl_pixelstore_attrib *packing,
-                                 struct gl_texture_object *texObj,
-                                 struct gl_texture_image *texImage )
-{
-   driTextureObject * t = (driTextureObject *) texObj->DriverData;
-
-   assert( t ); /* this _should_ be true */
-   if ( t ) {
-      driSwapOutTextureObject( t );
-   }
-   else {
-      t = (driTextureObject *) r200AllocTexObj( texObj );
-      if (!t) {
-         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
-         return;
-      }
-   }
-
-   _mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
-                            format, type, pixels, packing, texObj,
-                            texImage);
-
-   t->dirty_images[0] |= (1 << level);
-}
-
-
-static void r200TexImage2D( GLcontext *ctx, GLenum target, GLint level,
-                              GLint internalFormat,
-                              GLint width, GLint height, GLint border,
-                              GLenum format, GLenum type, const GLvoid *pixels,
-                              const struct gl_pixelstore_attrib *packing,
-                              struct gl_texture_object *texObj,
-                              struct gl_texture_image *texImage )
-{
-   driTextureObject * t = (driTextureObject *) texObj->DriverData;
-   GLuint face;
-
-   /* which cube face or ordinary 2D image */
-   switch (target) {
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
-      face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
-      ASSERT(face < 6);
-      break;
-   default:
-      face = 0;
-   }
-
-   if ( t != NULL ) {
-      driSwapOutTextureObject( t );
-   }
-   else {
-      t = (driTextureObject *) r200AllocTexObj( texObj );
-      if (!t) {
-         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
-         return;
-      }
-   }
-
-   texImage->IsClientData = GL_FALSE;
-
-   if (r200ValidateClientStorage( ctx, target, 
-                                 internalFormat, 
-                                 width, height, 
-                                 format, type, pixels, 
-                                 packing, texObj, texImage)) {
-      if (R200_DEBUG & DEBUG_TEXTURE)
-        fprintf(stderr, "%s: Using client storage\n", __FUNCTION__); 
-   }
-   else {
-      if (R200_DEBUG & DEBUG_TEXTURE)
-        fprintf(stderr, "%s: Using normal storage\n", __FUNCTION__); 
-
-      /* Normal path: copy (to cached memory) and eventually upload
-       * via another copy to GART memory and then a blit...  Could
-       * eliminate one copy by going straight to (permanent) GART.
-       *
-       * Note, this will call r200ChooseTextureFormat.
-       */
-      _mesa_store_teximage2d(ctx, target, level, internalFormat,
-                            width, height, border, format, type, pixels,
-                            &ctx->Unpack, texObj, texImage);
-      
-      t->dirty_images[face] |= (1 << level);
-   }
-}
-
-
-static void r200TexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
-                                 GLint xoffset, GLint yoffset,
-                                 GLsizei width, GLsizei height,
-                                 GLenum format, GLenum type,
-                                 const GLvoid *pixels,
-                                 const struct gl_pixelstore_attrib *packing,
-                                 struct gl_texture_object *texObj,
-                                 struct gl_texture_image *texImage )
-{
-   driTextureObject * t = (driTextureObject *) texObj->DriverData;
-   GLuint face;
-
-   /* which cube face or ordinary 2D image */
-   switch (target) {
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
-      face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
-      ASSERT(face < 6);
-      break;
-   default:
-      face = 0;
-   }
-
-   assert( t ); /* this _should_ be true */
-   if ( t ) {
-      driSwapOutTextureObject( t );
-   }
-   else {
-      t = (driTextureObject *) r200AllocTexObj( texObj );
-      if (!t) {
-         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
-         return;
-      }
-   }
-
-   _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
-                            height, format, type, pixels, packing, texObj,
-                            texImage);
-
-   t->dirty_images[face] |= (1 << level);
-}
-
-
-static void r200CompressedTexImage2D( GLcontext *ctx, GLenum target, GLint level,
-                              GLint internalFormat,
-                              GLint width, GLint height, GLint border,
-                              GLsizei imageSize, const GLvoid *data,
-                              struct gl_texture_object *texObj,
-                              struct gl_texture_image *texImage )
-{
-   driTextureObject * t = (driTextureObject *) texObj->DriverData;
-   GLuint face;
-
-   /* which cube face or ordinary 2D image */
-   switch (target) {
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
-      face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
-      ASSERT(face < 6);
-      break;
-   default:
-      face = 0;
-   }
-
-   if ( t != NULL ) {
-      driSwapOutTextureObject( t );
-   }
-   else {
-      t = (driTextureObject *) r200AllocTexObj( texObj );
-      if (!t) {
-         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
-         return;
-      }
-   }
-
-   texImage->IsClientData = GL_FALSE;
-/* can't call this, different parameters. Would never evaluate to true anyway currently
-   if (r200ValidateClientStorage( ctx, target, 
-                                 internalFormat,
-                                 width, height,
-                                 format, type, pixels,
-                                 packing, texObj, texImage)) {
-      if (R200_DEBUG & DEBUG_TEXTURE)
-        fprintf(stderr, "%s: Using client storage\n", __FUNCTION__);
-   }
-   else */{
-      if (R200_DEBUG & DEBUG_TEXTURE)
-        fprintf(stderr, "%s: Using normal storage\n", __FUNCTION__);
-
-      /* Normal path: copy (to cached memory) and eventually upload
-       * via another copy to GART memory and then a blit...  Could
-       * eliminate one copy by going straight to (permanent) GART.
-       *
-       * Note, this will call r200ChooseTextureFormat.
-       */
-      _mesa_store_compressed_teximage2d(ctx, target, level, internalFormat, width,
-                                 height, border, imageSize, data, texObj, texImage);
-
-      t->dirty_images[face] |= (1 << level);
-   }
+   t->pp_border_color = radeonPackColor( 4, c[0], c[1], c[2], c[3] );
 }
 
-
-static void r200CompressedTexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
-                                 GLint xoffset, GLint yoffset,
-                                 GLsizei width, GLsizei height,
-                                 GLenum format,
-                                 GLsizei imageSize, const GLvoid *data,
-                                 struct gl_texture_object *texObj,
-                                 struct gl_texture_image *texImage )
-{
-   driTextureObject * t = (driTextureObject *) texObj->DriverData;
-   GLuint face;
-
-
-   /* which cube face or ordinary 2D image */
-   switch (target) {
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
-      face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
-      ASSERT(face < 6);
-      break;
-   default:
-      face = 0;
-   }
-
-   assert( t ); /* this _should_ be true */
-   if ( t ) {
-      driSwapOutTextureObject( t );
-   }
-   else {
-      t = (driTextureObject *) r200AllocTexObj( texObj );
-      if (!t) {
-         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2D");
-         return;
-      }
-   }
-
-   _mesa_store_compressed_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
-                            height, format, imageSize, data, texObj, texImage);
-
-   t->dirty_images[face] |= (1 << level);
-}
-
-
-#if ENABLE_HW_3D_TEXTURE
-static void r200TexImage3D( GLcontext *ctx, GLenum target, GLint level,
-                            GLint internalFormat,
-                            GLint width, GLint height, GLint depth,
-                            GLint border,
-                            GLenum format, GLenum type, const GLvoid *pixels,
-                            const struct gl_pixelstore_attrib *packing,
-                            struct gl_texture_object *texObj,
-                            struct gl_texture_image *texImage )
-{
-   driTextureObject * t = (driTextureObject *) texObj->DriverData;
-
-   if ( t ) {
-      driSwapOutTextureObject( t );
-   }
-   else {
-      t = (driTextureObject *) r200AllocTexObj( texObj );
-      if (!t) {
-         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
-         return;
-      }
-   }
-
-   texImage->IsClientData = GL_FALSE;
-
-#if 0
-   if (r200ValidateClientStorage( ctx, target, 
-                                 internalFormat, 
-                                 width, height, 
-                                 format, type, pixels, 
-                                 packing, texObj, texImage)) {
-      if (R200_DEBUG & DEBUG_TEXTURE)
-        fprintf(stderr, "%s: Using client storage\n", __FUNCTION__); 
-   }
-   else
-#endif
-   {
-      if (R200_DEBUG & DEBUG_TEXTURE)
-        fprintf(stderr, "%s: Using normal storage\n", __FUNCTION__); 
-
-      /* Normal path: copy (to cached memory) and eventually upload
-       * via another copy to GART memory and then a blit...  Could
-       * eliminate one copy by going straight to (permanent) GART.
-       *
-       * Note, this will call r200ChooseTextureFormat.
-       */
-      _mesa_store_teximage3d(ctx, target, level, internalFormat,
-                            width, height, depth, border,
-                             format, type, pixels,
-                            &ctx->Unpack, texObj, texImage);
-      
-      t->dirty_images[0] |= (1 << level);
-   }
-}
-#endif
-
-
-#if ENABLE_HW_3D_TEXTURE
-static void
-r200TexSubImage3D( GLcontext *ctx, GLenum target, GLint level,
-                   GLint xoffset, GLint yoffset, GLint zoffset,
-                   GLsizei width, GLsizei height, GLsizei depth,
-                   GLenum format, GLenum type,
-                   const GLvoid *pixels,
-                   const struct gl_pixelstore_attrib *packing,
-                   struct gl_texture_object *texObj,
-                   struct gl_texture_image *texImage )
-{
-   driTextureObject * t = (driTextureObject *) texObj->DriverData;
-
-/*     fprintf(stderr, "%s\n", __FUNCTION__); */
-
-   assert( t ); /* this _should_ be true */
-   if ( t ) {
-      driSwapOutTextureObject( t );
-   }
-   else {
-      t = (driTextureObject *) r200AllocTexObj( texObj );
-      if (!t) {
-         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage3D");
-         return;
-      }
-      texObj->DriverData = t;
-   }
-
-   _mesa_store_texsubimage3d(ctx, target, level, xoffset, yoffset, zoffset,
-                             width, height, depth,
-                             format, type, pixels, packing, texObj, texImage);
-
-   t->dirty_images[0] |= (1 << level);
-}
-#endif
-
-
-
 static void r200TexEnv( GLcontext *ctx, GLenum target,
                          GLenum pname, const GLfloat *param )
 {
@@ -983,7 +301,7 @@ static void r200TexEnv( GLcontext *ctx, GLenum target,
       GLubyte c[4];
       GLuint envColor;
       UNCLAMPED_FLOAT_TO_RGBA_CHAN( c, texUnit->EnvColor );
-      envColor = r200PackColor( 4, c[0], c[1], c[2], c[3] );
+      envColor = radeonPackColor( 4, c[0], c[1], c[2], c[3] );
       if ( rmesa->hw.tf.cmd[TF_TFACTOR_0 + unit] != envColor ) {
         R200_STATECHANGE( rmesa, tf );
         rmesa->hw.tf.cmd[TF_TFACTOR_0 + unit] = envColor;
@@ -1002,7 +320,7 @@ static void r200TexEnv( GLcontext *ctx, GLenum target,
        * NOTE: Add a small bias to the bias for conform mipsel.c test.
        */
       bias = *param + .01;
-      min = driQueryOptionb (&rmesa->optionCache, "no_neg_lod_bias") ?
+      min = driQueryOptionb (&rmesa->radeon.optionCache, "no_neg_lod_bias") ?
          0.0 : -16.0;
       bias = CLAMP( bias, min, 16.0 );
       b = (int)(bias * fixed_one) & R200_LOD_BIAS_MASK;
@@ -1039,7 +357,7 @@ static void r200TexParameter( GLcontext *ctx, GLenum target,
                                struct gl_texture_object *texObj,
                                GLenum pname, const GLfloat *params )
 {
-   r200TexObjPtr t = (r200TexObjPtr) texObj->DriverData;
+   radeonTexObj* t = radeon_tex_obj(texObj);
 
    if ( R200_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {
       fprintf( stderr, "%s( %s )\n", __FUNCTION__,
@@ -1073,59 +391,46 @@ static void r200TexParameter( GLcontext *ctx, GLenum target,
        * we just have to rely on loading the right subset of mipmap levels
        * to simulate a clamped LOD.
        */
-      driSwapOutTextureObject( (driTextureObject *) t );
+      if (t->mt) {
+         radeon_miptree_unreference(t->mt);
+        t->mt = 0;
+        t->validated = GL_FALSE;
+      }
       break;
 
    default:
       return;
    }
-
-   /* Mark this texobj as dirty (one bit per tex unit)
-    */
-   t->dirty_state = TEX_ALL;
 }
 
 
-
-static void r200BindTexture( GLcontext *ctx, GLenum target,
-                              struct gl_texture_object *texObj )
-{
-   if ( R200_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {
-      fprintf( stderr, "%s( %p ) unit=%d\n", __FUNCTION__, (void *)texObj,
-              ctx->Texture.CurrentUnit );
-   }
-
-   if ( (target == GL_TEXTURE_1D)
-       || (target == GL_TEXTURE_2D) 
-#if ENABLE_HW_3D_TEXTURE
-       || (target == GL_TEXTURE_3D)
-#endif
-       || (target == GL_TEXTURE_CUBE_MAP)
-       || (target == GL_TEXTURE_RECTANGLE_NV) ) {
-      assert( texObj->DriverData != NULL );
-   }
-}
-
-
-static void r200DeleteTexture( GLcontext *ctx,
-                                struct gl_texture_object *texObj )
+static void r200DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   driTextureObject * t = (driTextureObject *) texObj->DriverData;
-
-   if ( R200_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {
-      fprintf( stderr, "%s( %p (target = %s) )\n", __FUNCTION__, (void *)texObj,
-              _mesa_lookup_enum_by_nr( texObj->Target ) );
+   radeonTexObj* t = radeon_tex_obj(texObj);
+
+   if (RADEON_DEBUG & (DEBUG_STATE | DEBUG_TEXTURE)) {
+      fprintf(stderr, "%s( %p (target = %s) )\n", __FUNCTION__,
+             (void *)texObj,
+             _mesa_lookup_enum_by_nr(texObj->Target));
+   }
+   
+   if (rmesa) {
+      int i;
+      radeon_firevertices(&rmesa->radeon);
+      for ( i = 0 ; i < rmesa->radeon.glCtx->Const.MaxTextureUnits ; i++ ) {
+        if ( t == rmesa->state.texture.unit[i].texobj ) {
+           rmesa->state.texture.unit[i].texobj = NULL;
+           rmesa->hw.tex[i].dirty = GL_FALSE;
+           rmesa->hw.cube[i].dirty = GL_FALSE;
+        }
+      }      
    }
-
-   if ( t != NULL ) {
-      if ( rmesa ) {
-         R200_FIREVERTICES( rmesa );
-      }
-
-      driDestroyTextureObject( t );
+   
+   if (t->mt) {
+      radeon_miptree_unreference(t->mt);
+      t->mt = 0;
    }
-   /* Free mipmap images and the texture object itself */
    _mesa_delete_texture_object(ctx, texObj);
 }
 
@@ -1155,46 +460,59 @@ static void r200TexGen( GLcontext *ctx,
  * Called via ctx->Driver.NewTextureObject.
  * Note: this function will be called during context creation to
  * allocate the default texture objects.
- * Note: we could use containment here to 'derive' the driver-specific
- * texture object from the core mesa gl_texture_object.  Not done at this time.
  * Fixup MaxAnisotropy according to user preference.
  */
-static struct gl_texture_object *
-r200NewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
+static struct gl_texture_object *r200NewTextureObject(GLcontext * ctx,
+                                                     GLuint name,
+                                                     GLenum target)
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   struct gl_texture_object *obj;
-   obj = _mesa_new_texture_object(ctx, name, target);
-   if (!obj)
-      return NULL;
-   obj->MaxAnisotropy = rmesa->initialMaxAnisotropy;
-   r200AllocTexObj( obj );
-   return obj;
+   radeonTexObj* t = CALLOC_STRUCT(radeon_tex_obj);
+
+
+   if (RADEON_DEBUG & (DEBUG_STATE | DEBUG_TEXTURE)) {
+     fprintf(stderr, "%s( %p (target = %s) )\n", __FUNCTION__,
+            t, _mesa_lookup_enum_by_nr(target));
+   }
+
+   _mesa_initialize_texture_object(&t->base, name, target);
+   t->base.MaxAnisotropy = rmesa->radeon.initialMaxAnisotropy;
+
+   /* Initialize hardware state */
+   r200SetTexWrap( t, t->base.WrapS, t->base.WrapT, t->base.WrapR );
+   r200SetTexMaxAnisotropy( t, t->base.MaxAnisotropy );
+   r200SetTexFilter(t, t->base.MinFilter, t->base.MagFilter);
+   r200SetTexBorderColor(t, t->base.BorderColor);
+
+   return &t->base;
 }
 
 
+
 void r200InitTextureFuncs( struct dd_function_table *functions )
 {
    /* Note: we only plug in the functions we implement in the driver
     * since _mesa_init_driver_functions() was already called.
     */
-   functions->ChooseTextureFormat      = r200ChooseTextureFormat;
-   functions->TexImage1D               = r200TexImage1D;
-   functions->TexImage2D               = r200TexImage2D;
+   functions->ChooseTextureFormat      = radeonChooseTextureFormat_mesa;
+   functions->TexImage1D               = radeonTexImage1D;
+   functions->TexImage2D               = radeonTexImage2D;
 #if ENABLE_HW_3D_TEXTURE
-   functions->TexImage3D               = r200TexImage3D;
+   functions->TexImage3D               = radeonTexImage3D;
 #else
    functions->TexImage3D               = _mesa_store_teximage3d;
 #endif
-   functions->TexSubImage1D            = r200TexSubImage1D;
-   functions->TexSubImage2D            = r200TexSubImage2D;
+   functions->TexSubImage1D            = radeonTexSubImage1D;
+   functions->TexSubImage2D            = radeonTexSubImage2D;
 #if ENABLE_HW_3D_TEXTURE
-   functions->TexSubImage3D            = r200TexSubImage3D;
+   functions->TexSubImage3D            = radeonTexSubImage3D;
 #else
    functions->TexSubImage3D            = _mesa_store_texsubimage3d;
 #endif
+   functions->GetTexImage               = radeonGetTexImage;
+   functions->GetCompressedTexImage     = radeonGetCompressedTexImage;
    functions->NewTextureObject         = r200NewTextureObject;
-   functions->BindTexture              = r200BindTexture;
+   //   functions->BindTexture         = r200BindTexture;
    functions->DeleteTexture            = r200DeleteTexture;
    functions->IsTextureResident                = driIsTextureResident;
 
@@ -1202,22 +520,16 @@ void r200InitTextureFuncs( struct dd_function_table *functions )
    functions->TexParameter             = r200TexParameter;
    functions->TexGen                   = r200TexGen;
 
-   functions->CompressedTexImage2D     = r200CompressedTexImage2D;
-   functions->CompressedTexSubImage2D  = r200CompressedTexSubImage2D;
+   functions->CompressedTexImage2D     = radeonCompressedTexImage2D;
+   functions->CompressedTexSubImage2D  = radeonCompressedTexSubImage2D;
 
-   driInitTextureFormats();
+   functions->GenerateMipmap = radeonGenerateMipmap;
 
-#if 000
-   /* moved or obsolete code */
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   driInitTextureObjects( ctx, & rmesa->swapped,
-                         DRI_TEXMGR_DO_TEXTURE_1D
-                         | DRI_TEXMGR_DO_TEXTURE_2D );
+   functions->NewTextureImage = radeonNewTextureImage;
+   functions->FreeTexImageData = radeonFreeTexImageData;
+   functions->MapTexture = radeonMapTexture;
+   functions->UnmapTexture = radeonUnmapTexture;
+
+   driInitTextureFormats();
 
-   /* Hack: r200NewTextureObject is not yet installed when the
-    * default textures are created. Therefore set MaxAnisotropy of the
-    * default 2D texture now. */
-   ctx->Shared->Default2D->MaxAnisotropy = driQueryOptionf (&rmesa->optionCache,
-                                                           "def_max_anisotropy");
-#endif
 }
index 10ff8e8a6604d9b03c01d6316e80ca9227d6fd05..e122de6e5edd7665df7a3d23001c2db12c866070 100644 (file)
@@ -35,15 +35,18 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #ifndef __R200_TEX_H__
 #define __R200_TEX_H__
 
+extern void r200SetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv);
+extern void r200SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_format,
+                             __DRIdrawable *dPriv);
 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 );
+extern int r200UploadTexImages( r200ContextPtr rmesa, radeonTexObjPtr t, GLuint face );
 
-extern void r200DestroyTexObj( r200ContextPtr rmesa, r200TexObjPtr t );
+extern void r200DestroyTexObj( r200ContextPtr rmesa, radeonTexObjPtr t );
 
 extern void r200InitTextureFuncs( struct dd_function_table *functions );
 
diff --git a/src/mesa/drivers/dri/r200/r200_texmem.c b/src/mesa/drivers/dri/r200/r200_texmem.c
deleted file mode 100644 (file)
index 3b81ac0..0000000
+++ /dev/null
@@ -1,530 +0,0 @@
-/**************************************************************************
-
-Copyright (C) Tungsten Graphics 2002.  All Rights Reserved.  
-The Weather Channel, Inc. funded Tungsten Graphics to develop the
-initial release of the Radeon 8500 driver under the XFree86
-license. This notice must be preserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation on the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR THEIR
-SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <martin@valinux.com>
- *   Gareth Hughes <gareth@valinux.com>
- *
- */
-#include <errno.h>
-
-#include "main/glheader.h"
-#include "main/imports.h"
-#include "main/context.h"
-#include "main/colormac.h"
-#include "main/macros.h"
-#include "r200_context.h"
-#include "r200_ioctl.h"
-#include "r200_tex.h"
-#include "radeon_reg.h"
-
-#include <unistd.h>  /* for usleep() */
-
-
-/**
- * Destroy any device-dependent state associated with the texture.  This may
- * include NULLing out hardware state that points to the texture.
- */
-void
-r200DestroyTexObj( r200ContextPtr rmesa, r200TexObjPtr t )
-{
-   if ( R200_DEBUG & DEBUG_TEXTURE ) {
-      fprintf( stderr, "%s( %p, %p )\n", __FUNCTION__, 
-              (void *)t, (void *)t->base.tObj );
-   }
-
-   if ( rmesa != NULL ) {
-      unsigned   i;
-
-
-      for ( i = 0 ; i < rmesa->glCtx->Const.MaxTextureUnits ; i++ ) {
-        if ( t == rmesa->state.texture.unit[i].texobj ) {
-           rmesa->state.texture.unit[i].texobj = NULL;
-           rmesa->hw.tex[i].dirty = GL_FALSE;
-           rmesa->hw.cube[i].dirty = GL_FALSE;
-        }
-      }
-   }
-}
-
-
-/* ------------------------------------------------------------
- * Texture image conversions
- */
-
-
-static void r200UploadGARTClientSubImage( r200ContextPtr rmesa,
-                                         r200TexObjPtr t, 
-                                         struct gl_texture_image *texImage,
-                                         GLint hwlevel,
-                                         GLint x, GLint y, 
-                                         GLint width, GLint height )
-{
-   const struct gl_texture_format *texFormat = texImage->TexFormat;
-   GLuint srcPitch, dstPitch;
-   int blit_format;
-   int srcOffset;
-
-   /*
-    * XXX it appears that we always upload the full image, not a subimage.
-    * I.e. x==0, y==0, width=texWidth, height=texWidth.  If this is ever
-    * changed, the src pitch will have to change.
-    */
-   switch ( texFormat->TexelBytes ) {
-   case 1:
-      blit_format = R200_CP_COLOR_FORMAT_CI8;
-      srcPitch = t->image[0][0].width * texFormat->TexelBytes;
-      dstPitch = t->image[0][0].width * texFormat->TexelBytes;
-      break;
-   case 2:
-      blit_format = R200_CP_COLOR_FORMAT_RGB565;
-      srcPitch = t->image[0][0].width * texFormat->TexelBytes;
-      dstPitch = t->image[0][0].width * texFormat->TexelBytes;
-      break;
-   case 4:
-      blit_format = R200_CP_COLOR_FORMAT_ARGB8888;
-      srcPitch = t->image[0][0].width * texFormat->TexelBytes;
-      dstPitch = t->image[0][0].width * texFormat->TexelBytes;
-      break;
-   default:
-      return;
-   }
-
-   t->image[0][hwlevel].data = texImage->Data;
-   srcOffset = r200GartOffsetFromVirtual( rmesa, texImage->Data );
-
-   assert( srcOffset != ~0 );
-
-   /* Don't currently need to cope with small pitches?
-    */
-   width = texImage->Width;
-   height = texImage->Height;
-
-   r200EmitWait( rmesa, RADEON_WAIT_3D );
-
-   r200EmitBlit( rmesa, blit_format, 
-                srcPitch,  
-                srcOffset,   
-                dstPitch,
-                t->bufAddr,
-                x, 
-                y, 
-                t->image[0][hwlevel].x + x,
-                t->image[0][hwlevel].y + y, 
-                width,
-                height );
-
-   r200EmitWait( rmesa, RADEON_WAIT_2D );
-}
-
-static void r200UploadRectSubImage( r200ContextPtr rmesa,
-                                   r200TexObjPtr t, 
-                                   struct gl_texture_image *texImage,
-                                   GLint x, GLint y, 
-                                   GLint width, GLint height )
-{
-   const struct gl_texture_format *texFormat = texImage->TexFormat;
-   int blit_format, dstPitch, done;
-
-   switch ( texFormat->TexelBytes ) {
-   case 1:
-      blit_format = R200_CP_COLOR_FORMAT_CI8;
-      break;
-   case 2:
-      blit_format = R200_CP_COLOR_FORMAT_RGB565;
-      break;
-   case 4:
-      blit_format = R200_CP_COLOR_FORMAT_ARGB8888;
-      break;
-   default:
-      return;
-   }
-
-   t->image[0][0].data = texImage->Data;
-
-   /* Currently don't need to cope with small pitches.
-    */
-   width = texImage->Width;
-   height = texImage->Height;
-   dstPitch = t->pp_txpitch + 32;
-
-   if (rmesa->prefer_gart_client_texturing && texImage->IsClientData) {
-      /* In this case, could also use GART texturing.  This is
-       * currently disabled, but has been tested & works.
-       */
-      if ( !t->image_override )
-         t->pp_txoffset = r200GartOffsetFromVirtual( rmesa, texImage->Data );
-      t->pp_txpitch = texImage->RowStride * texFormat->TexelBytes - 32;
-
-      if (R200_DEBUG & DEBUG_TEXTURE)
-        fprintf(stderr, 
-                "Using GART texturing for rectangular client texture\n");
-
-      /* Release FB memory allocated for this image:
-       */
-      /* FIXME This may not be correct as driSwapOutTextureObject sets
-       * FIXME dirty_images.  It may be fine, though.
-       */
-      if ( t->base.memBlock ) {
-        driSwapOutTextureObject( (driTextureObject *) t );
-      }
-   }
-   else if (texImage->IsClientData) {
-      /* Data already in GART memory, with usable pitch.
-       */
-      GLuint srcPitch;
-      srcPitch = texImage->RowStride * texFormat->TexelBytes;
-      r200EmitBlit( rmesa, 
-                   blit_format, 
-                   srcPitch,
-                   r200GartOffsetFromVirtual( rmesa, texImage->Data ),   
-                   dstPitch, t->bufAddr,
-                   0, 0, 
-                   0, 0, 
-                   width, height );
-   }
-   else {
-      /* Data not in GART memory, or bad pitch.
-       */
-      for (done = 0; done < height ; ) {
-        struct r200_dma_region region;
-        int lines = MIN2( height - done, RADEON_BUFFER_SIZE / dstPitch );
-        int src_pitch;
-        char *tex;
-
-         src_pitch = texImage->RowStride * texFormat->TexelBytes;
-
-        tex = (char *)texImage->Data + done * src_pitch;
-
-        memset(&region, 0, sizeof(region));
-        r200AllocDmaRegion( rmesa, &region, lines * dstPitch, 1024 );
-
-        /* Copy texdata to dma:
-         */
-        if (0)
-           fprintf(stderr, "%s: src_pitch %d dst_pitch %d\n",
-                   __FUNCTION__, src_pitch, dstPitch);
-
-        if (src_pitch == dstPitch) {
-           memcpy( region.address + region.start, tex, lines * src_pitch );
-        } 
-        else {
-           char *buf = region.address + region.start;
-           int i;
-           for (i = 0 ; i < lines ; i++) {
-              memcpy( buf, tex, src_pitch );
-              buf += dstPitch;
-              tex += src_pitch;
-           }
-        }
-
-        r200EmitWait( rmesa, RADEON_WAIT_3D );
-
-        /* Blit to framebuffer
-         */
-        r200EmitBlit( rmesa,
-                      blit_format,
-                      dstPitch, GET_START( &region ),
-                      dstPitch | (t->tile_bits >> 16),
-                      t->bufAddr,
-                      0, 0,
-                      0, done,
-                      width, lines );
-        
-        r200EmitWait( rmesa, RADEON_WAIT_2D );
-
-        r200ReleaseDmaRegion( rmesa, &region, __FUNCTION__ );
-        done += lines;
-      }
-   }
-}
-
-
-/**
- * Upload the texture image associated with texture \a t at the specified
- * level at the address relative to \a start.
- */
-static void uploadSubImage( r200ContextPtr rmesa, r200TexObjPtr t, 
-                           GLint hwlevel,
-                           GLint x, GLint y, GLint width, GLint height,
-                           GLuint face )
-{
-   struct gl_texture_image *texImage = NULL;
-   GLuint offset;
-   GLint imageWidth, imageHeight;
-   GLint ret;
-   drm_radeon_texture_t tex;
-   drm_radeon_tex_image_t tmp;
-   const int level = hwlevel + t->base.firstLevel;
-
-   if ( R200_DEBUG & DEBUG_TEXTURE ) {
-      fprintf( stderr, "%s( %p, %p ) level/width/height/face = %d/%d/%d/%u\n", 
-              __FUNCTION__, (void *)t, (void *)t->base.tObj,
-              level, width, height, face );
-   }
-
-   ASSERT(face < 6);
-
-   /* Ensure we have a valid texture to upload */
-   if ( ( hwlevel < 0 ) || ( hwlevel >= RADEON_MAX_TEXTURE_LEVELS ) ) {
-      _mesa_problem(NULL, "bad texture level in %s", __FUNCTION__);
-      return;
-   }
-
-   texImage = t->base.tObj->Image[face][level];
-
-   if ( !texImage ) {
-      if ( R200_DEBUG & DEBUG_TEXTURE )
-        fprintf( stderr, "%s: texImage %d is NULL!\n", __FUNCTION__, level );
-      return;
-   }
-   if ( !texImage->Data ) {
-      if ( R200_DEBUG & DEBUG_TEXTURE )
-        fprintf( stderr, "%s: image data is NULL!\n", __FUNCTION__ );
-      return;
-   }
-
-
-   if (t->base.tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
-      assert(level == 0);
-      assert(hwlevel == 0);
-      if ( R200_DEBUG & DEBUG_TEXTURE )
-        fprintf( stderr, "%s: image data is rectangular\n", __FUNCTION__);
-      r200UploadRectSubImage( rmesa, t, texImage, x, y, width, height );
-      return;
-   }
-   else if (texImage->IsClientData) {
-      if ( R200_DEBUG & DEBUG_TEXTURE )
-        fprintf( stderr, "%s: image data is in GART client storage\n",
-                 __FUNCTION__);
-      r200UploadGARTClientSubImage( rmesa, t, texImage, hwlevel,
-                                  x, y, width, height );
-      return;
-   }
-   else if ( R200_DEBUG & DEBUG_TEXTURE )
-      fprintf( stderr, "%s: image data is in normal memory\n",
-              __FUNCTION__);
-      
-
-   imageWidth = texImage->Width;
-   imageHeight = texImage->Height;
-
-   offset = t->bufAddr + t->base.totalSize / 6 * face;
-
-   if ( R200_DEBUG & (DEBUG_TEXTURE|DEBUG_IOCTL) ) {
-      GLint imageX = 0;
-      GLint imageY = 0;
-      GLint blitX = t->image[face][hwlevel].x;
-      GLint blitY = t->image[face][hwlevel].y;
-      GLint blitWidth = t->image[face][hwlevel].width;
-      GLint blitHeight = t->image[face][hwlevel].height;
-      fprintf( stderr, "   upload image: %d,%d at %d,%d\n",
-              imageWidth, imageHeight, imageX, imageY );
-      fprintf( stderr, "   upload  blit: %d,%d at %d,%d\n",
-              blitWidth, blitHeight, blitX, blitY );
-      fprintf( stderr, "       blit ofs: 0x%07x level: %d/%d\n",
-              (GLuint)offset, hwlevel, level );
-   }
-
-   t->image[face][hwlevel].data = texImage->Data;
-
-   /* Init the DRM_RADEON_TEXTURE command / drm_radeon_texture_t struct.
-    * NOTE: we're always use a 1KB-wide blit and I8 texture format.
-    * We used to use 1, 2 and 4-byte texels and used to use the texture
-    * width to dictate the blit width - but that won't work for compressed
-    * textures. (Brian)
-    * NOTE: can't do that with texture tiling. (sroland)
-    */
-   tex.offset = offset;
-   tex.image = &tmp;
-   /* copy (x,y,width,height,data) */
-   memcpy( &tmp, &t->image[face][hwlevel], sizeof(tmp) );
-   
-   if (texImage->TexFormat->TexelBytes) {
-      /* use multi-byte upload scheme */
-      tex.height = imageHeight;
-      tex.width = imageWidth;
-      tex.format = t->pp_txformat & R200_TXFORMAT_FORMAT_MASK;
-      if (tex.format == R200_TXFORMAT_ABGR8888) {
-        /* drm will refuse abgr8888 textures. */
-        tex.format = R200_TXFORMAT_ARGB8888;
-      }
-      tex.pitch = MAX2((texImage->Width * texImage->TexFormat->TexelBytes) / 64, 1);
-      tex.offset += tmp.x & ~1023;
-      tmp.x = tmp.x % 1024;
-      if (t->tile_bits & R200_TXO_MICRO_TILE) {
-        /* need something like "tiled coordinates" ? */
-        tmp.y = tmp.x / (tex.pitch * 128) * 2;
-        tmp.x = tmp.x % (tex.pitch * 128) / 2 / texImage->TexFormat->TexelBytes;
-        tex.pitch |= RADEON_DST_TILE_MICRO >> 22;
-      }
-      else {
-        tmp.x = tmp.x >> (texImage->TexFormat->TexelBytes >> 1);
-      }
-      if ((t->tile_bits & R200_TXO_MACRO_TILE) &&
-        (texImage->Width * texImage->TexFormat->TexelBytes >= 256) &&
-        ((!(t->tile_bits & R200_TXO_MICRO_TILE) && (texImage->Height >= 8)) ||
-           (texImage->Height >= 16))) {
-        /* weird: R200 disables macro tiling if mip width is smaller than 256 bytes,
-           OR if height is smaller than 8 automatically, but if micro tiling is active
-           the limit is height 16 instead ? */
-        tex.pitch |= RADEON_DST_TILE_MACRO >> 22;
-      }
-   }
-   else {
-      /* In case of for instance 8x8 texture (2x2 dxt blocks), padding after the first two blocks is
-         needed (only with dxt1 since 2 dxt3/dxt5 blocks already use 32 Byte). */
-      /* set tex.height to 1/4 since 1 "macropixel" (dxt-block) has 4 real pixels. Needed
-         so the kernel module reads the right amount of data. */
-      tex.format = R200_TXFORMAT_I8; /* any 1-byte texel format */
-      tex.pitch = (BLIT_WIDTH_BYTES / 64);
-      tex.height = (imageHeight + 3) / 4;
-      tex.width = (imageWidth + 3) / 4;
-      switch (t->pp_txformat & R200_TXFORMAT_FORMAT_MASK) {
-      case R200_TXFORMAT_DXT1:
-           tex.width *= 8;
-           break;
-      case R200_TXFORMAT_DXT23:
-      case R200_TXFORMAT_DXT45:
-           tex.width *= 16;
-           break;
-      default:
-          fprintf(stderr, "unknown compressed tex format in uploadSubImage\n");
-      }
-   }
-
-   LOCK_HARDWARE( rmesa );
-   do {
-      ret = drmCommandWriteRead( rmesa->dri.fd, DRM_RADEON_TEXTURE,
-                                 &tex, sizeof(drm_radeon_texture_t) );
-      if (ret) {
-        if (R200_DEBUG & DEBUG_IOCTL)
-           fprintf(stderr, "DRM_RADEON_TEXTURE:  again!\n");
-        usleep(1);
-      }
-   } while ( ret == -EAGAIN );
-
-   UNLOCK_HARDWARE( rmesa );
-
-   if ( ret ) {
-      fprintf( stderr, "DRM_RADEON_TEXTURE: return = %d\n", ret );
-      fprintf( stderr, "   offset=0x%08x\n",
-              offset );
-      fprintf( stderr, "   image width=%d height=%d\n",
-              imageWidth, imageHeight );
-      fprintf( stderr, "    blit width=%d height=%d data=%p\n",
-              t->image[face][hwlevel].width, t->image[face][hwlevel].height,
-              t->image[face][hwlevel].data );
-      exit( 1 );
-   }
-}
-
-
-/**
- * Upload the texture images associated with texture \a t.  This might
- * require the allocation of texture memory.
- * 
- * \param rmesa Context pointer
- * \param t Texture to be uploaded
- * \param face Cube map face to be uploaded.  Zero for non-cube maps.
- */
-
-int r200UploadTexImages( r200ContextPtr rmesa, r200TexObjPtr t, GLuint face )
-{
-   const int numLevels = t->base.lastLevel - t->base.firstLevel + 1;
-
-   if ( R200_DEBUG & (DEBUG_TEXTURE|DEBUG_IOCTL) ) {
-      fprintf( stderr, "%s( %p, %p ) sz=%d lvls=%d-%d\n", __FUNCTION__,
-              (void *)rmesa->glCtx, (void *)t->base.tObj, t->base.totalSize,
-              t->base.firstLevel, t->base.lastLevel );
-   }
-
-   if ( !t || t->base.totalSize == 0 || t->image_override )
-      return 0;
-
-   if (R200_DEBUG & DEBUG_SYNC) {
-      fprintf(stderr, "%s: Syncing\n", __FUNCTION__ );
-      r200Finish( rmesa->glCtx );
-   }
-
-   LOCK_HARDWARE( rmesa );
-
-   if ( t->base.memBlock == NULL ) {
-      int heap;
-
-      heap = driAllocateTexture( rmesa->texture_heaps, rmesa->nr_heaps,
-                                (driTextureObject *) t );
-      if ( heap == -1 ) {
-        UNLOCK_HARDWARE( rmesa );
-        return -1;
-      }
-
-      /* Set the base offset of the texture image */
-      t->bufAddr = rmesa->r200Screen->texOffset[heap] 
-          + t->base.memBlock->ofs;
-      t->pp_txoffset = t->bufAddr;
-       
-      if (!(t->base.tObj->Image[0][0]->IsClientData)) {
-        /* hope it's safe to add that here... */
-        t->pp_txoffset |= t->tile_bits;
-      }
-
-      /* Mark this texobj as dirty on all units:
-       */
-      t->dirty_state = TEX_ALL;
-   }
-
-   /* Let the world know we've used this memory recently.
-    */
-   driUpdateTextureLRU( (driTextureObject *) t );
-   UNLOCK_HARDWARE( rmesa );
-
-   /* Upload any images that are new */
-   if (t->base.dirty_images[face]) {
-      int i;
-      for ( i = 0 ; i < numLevels ; i++ ) {
-         if ( (t->base.dirty_images[face] & (1 << (i+t->base.firstLevel))) != 0 ) {
-            uploadSubImage( rmesa, t, i, 0, 0, t->image[face][i].width,
-                           t->image[face][i].height, face );
-         }
-      }
-      t->base.dirty_images[face] = 0;
-   }
-
-
-   if (R200_DEBUG & DEBUG_SYNC) {
-      fprintf(stderr, "%s: Syncing\n", __FUNCTION__ );
-      r200Finish( rmesa->glCtx );
-   }
-
-   return 0;
-}
index 0ad5651cd476ea1a607bd541cc08cfd75bac27ca..ed1995e147c3a099f5b76158086c68fe75f28cd1 100644 (file)
@@ -37,9 +37,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/context.h"
 #include "main/macros.h"
 #include "main/texformat.h"
+#include "main/teximage.h"
 #include "main/texobj.h"
 #include "main/enums.h"
 
+#include "radeon_common.h"
+#include "radeon_mipmap_tree.h"
 #include "r200_context.h"
 #include "r200_state.h"
 #include "r200_ioctl.h"
@@ -139,257 +142,6 @@ static const struct tx_table tx_table_le[] =
 #undef _ALPHA
 #undef _INVALID
 
-/**
- * This function computes the number of bytes of storage needed for
- * the given texture object (all mipmap levels, all cube faces).
- * The \c image[face][level].x/y/width/height parameters for upload/blitting
- * are computed here.  \c pp_txfilter, \c pp_txformat, etc. will be set here
- * too.
- * 
- * \param rmesa Context pointer
- * \param tObj GL texture object whose images are to be posted to
- *                 hardware state.
- */
-static void r200SetTexImages( r200ContextPtr rmesa,
-                             struct gl_texture_object *tObj )
-{
-   r200TexObjPtr t = (r200TexObjPtr)tObj->DriverData;
-   const struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel];
-   GLint curOffset, blitWidth;
-   GLint i, texelBytes;
-   GLint numLevels;
-   GLint log2Width, log2Height, log2Depth;
-
-   /* Set the hardware texture format
-    */
-   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 |= table[ baseImage->TexFormat->MesaFormat ].format;
-        t->pp_txfilter |= table[ baseImage->TexFormat->MesaFormat ].filter;
-      }
-      else {
-         _mesa_problem(NULL, "unexpected texture format in %s", __FUNCTION__);
-         return;
-      }
-   }
-
-   texelBytes = baseImage->TexFormat->TexelBytes;
-
-   /* Compute which mipmap levels we really want to send to the hardware.
-    */
-
-   driCalculateTextureFirstLastLevel( (driTextureObject *) t );
-   log2Width  = tObj->Image[0][t->base.firstLevel]->WidthLog2;
-   log2Height = tObj->Image[0][t->base.firstLevel]->HeightLog2;
-   log2Depth  = tObj->Image[0][t->base.firstLevel]->DepthLog2;
-
-   numLevels = t->base.lastLevel - t->base.firstLevel + 1;
-
-   assert(numLevels <= RADEON_MAX_TEXTURE_LEVELS);
-
-   /* Calculate mipmap offsets and dimensions for blitting (uploading)
-    * The idea is that we lay out the mipmap levels within a block of
-    * memory organized as a rectangle of width BLIT_WIDTH_BYTES.
-    */
-   curOffset = 0;
-   blitWidth = BLIT_WIDTH_BYTES;
-   t->tile_bits = 0;
-
-   /* figure out if this texture is suitable for tiling. */
-   if (texelBytes) {
-      if (rmesa->texmicrotile  && (tObj->Target != GL_TEXTURE_RECTANGLE_NV) &&
-      /* texrect might be able to use micro tiling too in theory? */
-        (baseImage->Height > 1)) {
-        /* allow 32 (bytes) x 1 mip (which will use two times the space
-        the non-tiled version would use) max if base texture is large enough */
-        if ((numLevels == 1) ||
-          (((baseImage->Width * texelBytes / baseImage->Height) <= 32) &&
-              (baseImage->Width * texelBytes > 64)) ||
-           ((baseImage->Width * texelBytes / baseImage->Height) <= 16)) {
-           t->tile_bits |= R200_TXO_MICRO_TILE;
-        }
-      }
-      if (tObj->Target != GL_TEXTURE_RECTANGLE_NV) {
-        /* we can set macro tiling even for small textures, they will be untiled anyway */
-        t->tile_bits |= R200_TXO_MACRO_TILE;
-      }
-   }
-
-   for (i = 0; i < numLevels; i++) {
-      const struct gl_texture_image *texImage;
-      GLuint size;
-
-      texImage = tObj->Image[0][i + t->base.firstLevel];
-      if ( !texImage )
-        break;
-
-      /* find image size in bytes */
-      if (texImage->IsCompressed) {
-      /* need to calculate the size AFTER padding even though the texture is
-         submitted without padding.
-         Only handle pot textures currently - don't know if npot is even possible,
-         size calculation would certainly need (trivial) adjustments.
-         Align (and later pad) to 32byte, not sure what that 64byte blit width is
-         good for? */
-         if ((t->pp_txformat & R200_TXFORMAT_FORMAT_MASK) == R200_TXFORMAT_DXT1) {
-            /* RGB_DXT1/RGBA_DXT1, 8 bytes per block */
-            if ((texImage->Width + 3) < 8) /* width one block */
-               size = texImage->CompressedSize * 4;
-            else if ((texImage->Width + 3) < 16)
-               size = texImage->CompressedSize * 2;
-            else size = texImage->CompressedSize;
-         }
-         else /* DXT3/5, 16 bytes per block */
-            if ((texImage->Width + 3) < 8)
-               size = texImage->CompressedSize * 2;
-            else size = texImage->CompressedSize;
-      }
-      else if (tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
-        size = ((texImage->Width * texelBytes + 63) & ~63) * texImage->Height;
-      }
-      else if (t->tile_bits & R200_TXO_MICRO_TILE) {
-        /* tile pattern is 16 bytes x2. mipmaps stay 32 byte aligned,
-           though the actual offset may be different (if texture is less than
-           32 bytes width) to the untiled case */
-        int w = (texImage->Width * texelBytes * 2 + 31) & ~31;
-        size = (w * ((texImage->Height + 1) / 2)) * texImage->Depth;
-        blitWidth = MAX2(texImage->Width, 64 / texelBytes);
-      }
-      else {
-        int w = (texImage->Width * texelBytes + 31) & ~31;
-        size = w * texImage->Height * texImage->Depth;
-        blitWidth = MAX2(texImage->Width, 64 / texelBytes);
-      }
-      assert(size > 0);
-
-      /* Align to 32-byte offset.  It is faster to do this unconditionally
-       * (no branch penalty).
-       */
-
-      curOffset = (curOffset + 0x1f) & ~0x1f;
-
-      if (texelBytes) {
-        t->image[0][i].x = curOffset; /* fix x and y coords up later together with offset */
-        t->image[0][i].y = 0;
-        t->image[0][i].width = MIN2(size / texelBytes, blitWidth);
-        t->image[0][i].height = (size / texelBytes) / t->image[0][i].width;
-      }
-      else {
-         t->image[0][i].x = curOffset % BLIT_WIDTH_BYTES;
-         t->image[0][i].y = curOffset / BLIT_WIDTH_BYTES;
-         t->image[0][i].width  = MIN2(size, BLIT_WIDTH_BYTES);
-         t->image[0][i].height = size / t->image[0][i].width;     
-      }
-
-#if 0
-      /* for debugging only and only  applicable to non-rectangle targets */
-      assert(size % t->image[0][i].width == 0);
-      assert(t->image[0][i].x == 0
-             || (size < BLIT_WIDTH_BYTES && t->image[0][i].height == 1));
-#endif
-
-      if (0)
-         fprintf(stderr,
-                 "level %d: %dx%d x=%d y=%d w=%d h=%d size=%d at %d\n",
-                 i, texImage->Width, texImage->Height,
-                 t->image[0][i].x, t->image[0][i].y,
-                 t->image[0][i].width, t->image[0][i].height, size, curOffset);
-
-      curOffset += size;
-
-   }
-
-   /* Align the total size of texture memory block.
-    */
-   t->base.totalSize = (curOffset + RADEON_OFFSET_MASK) & ~RADEON_OFFSET_MASK;
-
-   /* Setup remaining cube face blits, if needed */
-   if (tObj->Target == GL_TEXTURE_CUBE_MAP) {
-      const GLuint faceSize = t->base.totalSize;
-      GLuint face;
-      /* reuse face 0 x/y/width/height - just update the offset when uploading */
-      for (face = 1; face < 6; face++) {
-         for (i = 0; i < numLevels; i++) {
-            t->image[face][i].x =  t->image[0][i].x;
-            t->image[face][i].y =  t->image[0][i].y;
-            t->image[face][i].width  = t->image[0][i].width;
-            t->image[face][i].height = t->image[0][i].height;
-         }
-      }
-      t->base.totalSize = 6 * faceSize; /* total texmem needed */
-   }
-
-
-   /* Hardware state:
-    */
-   t->pp_txfilter &= ~R200_MAX_MIP_LEVEL_MASK;
-   t->pp_txfilter |= (numLevels - 1) << R200_MAX_MIP_LEVEL_SHIFT;
-
-   t->pp_txformat &= ~(R200_TXFORMAT_WIDTH_MASK |
-                      R200_TXFORMAT_HEIGHT_MASK |
-                       R200_TXFORMAT_CUBIC_MAP_ENABLE |
-                       R200_TXFORMAT_F5_WIDTH_MASK |
-                       R200_TXFORMAT_F5_HEIGHT_MASK);
-   t->pp_txformat |= ((log2Width << R200_TXFORMAT_WIDTH_SHIFT) |
-                     (log2Height << R200_TXFORMAT_HEIGHT_SHIFT));
-
-   t->pp_txformat_x &= ~(R200_DEPTH_LOG2_MASK | R200_TEXCOORD_MASK);
-   if (tObj->Target == GL_TEXTURE_3D) {
-      t->pp_txformat_x |= (log2Depth << R200_DEPTH_LOG2_SHIFT);
-      t->pp_txformat_x |= R200_TEXCOORD_VOLUME;
-   }
-   else if (tObj->Target == GL_TEXTURE_CUBE_MAP) {
-      ASSERT(log2Width == log2Height);
-      t->pp_txformat |= ((log2Width << R200_TXFORMAT_F5_WIDTH_SHIFT) |
-                         (log2Height << R200_TXFORMAT_F5_HEIGHT_SHIFT) |
-/* don't think we need this bit, if it exists at all - fglrx does not set it */
-                         (R200_TXFORMAT_CUBIC_MAP_ENABLE));
-      t->pp_txformat_x |= R200_TEXCOORD_CUBIC_ENV;
-      t->pp_cubic_faces = ((log2Width << R200_FACE_WIDTH_1_SHIFT) |
-                           (log2Height << R200_FACE_HEIGHT_1_SHIFT) |
-                           (log2Width << R200_FACE_WIDTH_2_SHIFT) |
-                           (log2Height << R200_FACE_HEIGHT_2_SHIFT) |
-                           (log2Width << R200_FACE_WIDTH_3_SHIFT) |
-                           (log2Height << R200_FACE_HEIGHT_3_SHIFT) |
-                           (log2Width << R200_FACE_WIDTH_4_SHIFT) |
-                           (log2Height << R200_FACE_HEIGHT_4_SHIFT));
-   }
-   else {
-      /* If we don't in fact send enough texture coordinates, q will be 1,
-       * making TEXCOORD_PROJ act like TEXCOORD_NONPROJ (Right?)
-       */
-      t->pp_txformat_x |= R200_TEXCOORD_PROJ;
-   }
-
-   t->pp_txsize = (((tObj->Image[0][t->base.firstLevel]->Width - 1) << 0) |
-                   ((tObj->Image[0][t->base.firstLevel]->Height - 1) << 16));
-
-   /* Only need to round to nearest 32 for textures, but the blitter
-    * requires 64-byte aligned pitches, and we may/may not need the
-    * blitter.   NPOT only!
-    */
-   if ( !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;
-
-   /* FYI: r200UploadTexImages( rmesa, t ) used to be called here */
-}
-
-
-
 /* ================================================================
  * Texture combine functions
  */
@@ -981,20 +733,19 @@ void r200SetTexOffset(__DRIcontext * pDRICtx, GLint texname,
 {
        r200ContextPtr rmesa = pDRICtx->driverPrivate;
        struct gl_texture_object *tObj =
-           _mesa_lookup_texture(rmesa->glCtx, texname);
-       r200TexObjPtr t;
+           _mesa_lookup_texture(rmesa->radeon.glCtx, texname);
+       radeonTexObjPtr t = radeon_tex_obj(tObj);
 
        if (!tObj)
                return;
 
-       t = (r200TexObjPtr) tObj->DriverData;
-
        t->image_override = GL_TRUE;
 
        if (!offset)
                return;
 
-       t->pp_txoffset = offset;
+       t->bo = NULL;
+       t->override_offset = offset;
        t->pp_txpitch = pitch - 32;
 
        switch (depth) {
@@ -1014,6 +765,125 @@ void r200SetTexOffset(__DRIcontext * pDRICtx, GLint texname,
        }
 }
 
+void r200SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_format,
+                      __DRIdrawable *dPriv)
+{
+       struct gl_texture_unit *texUnit;
+       struct gl_texture_object *texObj;
+       struct gl_texture_image *texImage;
+       struct radeon_renderbuffer *rb;
+       radeon_texture_image *rImage;
+       radeonContextPtr radeon;
+       r200ContextPtr rmesa;
+       struct radeon_framebuffer *rfb;
+       radeonTexObjPtr t;
+       uint32_t pitch_val;
+       uint32_t internalFormat, type, format;
+
+       type = GL_BGRA;
+       format = GL_UNSIGNED_BYTE;
+       internalFormat = (glx_texture_format == GLX_TEXTURE_FORMAT_RGB_EXT ? 3 : 4);
+
+       radeon = pDRICtx->driverPrivate;
+       rmesa = pDRICtx->driverPrivate;
+
+       rfb = dPriv->driverPrivate;
+        texUnit = &radeon->glCtx->Texture.Unit[radeon->glCtx->Texture.CurrentUnit];
+       texObj = _mesa_select_tex_object(radeon->glCtx, texUnit, target);
+        texImage = _mesa_get_tex_image(radeon->glCtx, texObj, target, 0);
+
+       rImage = get_radeon_texture_image(texImage);
+       t = radeon_tex_obj(texObj);
+        if (t == NULL) {
+           return;
+       }
+
+       radeon_update_renderbuffers(pDRICtx, dPriv);
+       /* back & depth buffer are useless free them right away */
+       rb = (void*)rfb->base.Attachment[BUFFER_DEPTH].Renderbuffer;
+       if (rb && rb->bo) {
+               radeon_bo_unref(rb->bo);
+        rb->bo = NULL;
+       }
+       rb = (void*)rfb->base.Attachment[BUFFER_BACK_LEFT].Renderbuffer;
+       if (rb && rb->bo) {
+               radeon_bo_unref(rb->bo);
+               rb->bo = NULL;
+       }
+       rb = rfb->color_rb[0];
+       if (rb->bo == NULL) {
+               /* Failed to BO for the buffer */
+               return;
+       }
+       
+       _mesa_lock_texture(radeon->glCtx, texObj);
+       if (t->bo) {
+               radeon_bo_unref(t->bo);
+               t->bo = NULL;
+       }
+       if (rImage->bo) {
+               radeon_bo_unref(rImage->bo);
+               rImage->bo = NULL;
+       }
+       if (t->mt) {
+               radeon_miptree_unreference(t->mt);
+               t->mt = NULL;
+       }
+       if (rImage->mt) {
+               radeon_miptree_unreference(rImage->mt);
+               rImage->mt = NULL;
+       }
+       _mesa_init_teximage_fields(radeon->glCtx, target, texImage,
+                                  rb->width, rb->height, 1, 0, rb->cpp);
+       texImage->RowStride = rb->pitch / rb->cpp;
+       texImage->TexFormat = radeonChooseTextureFormat(radeon->glCtx,
+                                                       internalFormat,
+                                                       type, format, 0);
+       rImage->bo = rb->bo;
+       radeon_bo_ref(rImage->bo);
+       t->bo = rb->bo;
+       radeon_bo_ref(t->bo);
+       t->tile_bits = 0;
+       t->image_override = GL_TRUE;
+       t->override_offset = 0;
+       t->pp_txpitch &= (1 << 13) -1;
+       pitch_val = rb->pitch;
+       switch (rb->cpp) {
+       case 4:
+               if (glx_texture_format == GLX_TEXTURE_FORMAT_RGB_EXT)
+                       t->pp_txformat = tx_table_le[MESA_FORMAT_RGB888].format;
+               else
+                       t->pp_txformat = tx_table_le[MESA_FORMAT_ARGB8888].format;
+               t->pp_txfilter |= tx_table_le[MESA_FORMAT_ARGB8888].filter;
+               break;
+       case 3:
+       default:
+               t->pp_txformat = tx_table_le[MESA_FORMAT_RGB888].format;
+               t->pp_txfilter |= tx_table_le[MESA_FORMAT_RGB888].filter;
+               break;
+       case 2:
+               t->pp_txformat = tx_table_le[MESA_FORMAT_RGB565].format;
+               t->pp_txfilter |= tx_table_le[MESA_FORMAT_RGB565].filter;
+               break;
+       }
+        t->pp_txsize = ((rb->width - 1) << RADEON_TEX_USIZE_SHIFT)
+                  | ((rb->height - 1) << RADEON_TEX_VSIZE_SHIFT);
+        t->pp_txformat |= R200_TXFORMAT_NON_POWER2;
+       t->pp_txpitch = pitch_val;
+        t->pp_txpitch -= 32;
+
+       t->validated = GL_TRUE;
+       _mesa_unlock_texture(radeon->glCtx, texObj);
+       return;
+}
+
+
+void r200SetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
+{
+        r200SetTexBuffer2(pDRICtx, target, GLX_TEXTURE_FORMAT_RGBA_EXT, dPriv);
+}
+
+
 #define REF_COLOR 1
 #define REF_ALPHA 2
 
@@ -1207,12 +1077,41 @@ static GLboolean r200UpdateAllTexEnv( GLcontext *ctx )
                                 R200_VOLUME_FILTER_MASK)
 
 
+static void disable_tex_obj_state( r200ContextPtr rmesa, 
+                                  int unit )
+{
+   
+   R200_STATECHANGE( rmesa, vtx );
+   rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_1] &= ~(7 << (unit * 3));
+
+   if (rmesa->radeon.TclFallback & (R200_TCL_FALLBACK_TEXGEN_0<<unit)) {
+      TCL_FALLBACK( rmesa->radeon.glCtx, (R200_TCL_FALLBACK_TEXGEN_0<<unit), GL_FALSE);
+   }
+
+   /* Actually want to keep all units less than max active texture
+    * enabled, right?  Fix this for >2 texunits.
+    */
+
+   {
+      GLuint tmp = rmesa->TexGenEnabled;
+
+      rmesa->TexGenEnabled &= ~(R200_TEXGEN_TEXMAT_0_ENABLE<<unit);
+      rmesa->TexGenEnabled &= ~(R200_TEXMAT_0_ENABLE<<unit);
+      rmesa->TexGenNeedNormals[unit] = GL_FALSE;
+      rmesa->TexGenCompSel &= ~(R200_OUTPUT_TEX_0 << unit);
+
+      if (tmp != rmesa->TexGenEnabled) {
+        rmesa->recheck_texgen[unit] = GL_TRUE;
+        rmesa->radeon.NewGLState |= _NEW_TEXTURE_MATRIX;
+      }
+   }
+}
 static void import_tex_obj_state( r200ContextPtr rmesa,
                                  int unit,
-                                 r200TexObjPtr texobj )
+                                 radeonTexObjPtr texobj )
 {
 /* do not use RADEON_DB_STATE to avoid stale texture caches */
-   int *cmd = &rmesa->hw.tex[unit].cmd[TEX_CMD_0];
+   GLuint *cmd = &rmesa->hw.tex[unit].cmd[TEX_CMD_0];
 
    R200_STATECHANGE( rmesa, tex[unit] );
 
@@ -1225,36 +1124,21 @@ static void import_tex_obj_state( r200ContextPtr rmesa,
    cmd[TEX_PP_TXSIZE] = texobj->pp_txsize; /* NPOT only! */
    cmd[TEX_PP_TXPITCH] = texobj->pp_txpitch; /* NPOT only! */
    cmd[TEX_PP_BORDER_COLOR] = texobj->pp_border_color;
-   if (rmesa->r200Screen->drmSupportsFragShader) {
-      cmd[TEX_PP_TXOFFSET_NEWDRM] = texobj->pp_txoffset;
-   }
-   else {
-      cmd[TEX_PP_TXOFFSET_OLDDRM] = texobj->pp_txoffset;
-   }
 
-   if (texobj->base.tObj->Target == GL_TEXTURE_CUBE_MAP) {
-      int *cube_cmd = &rmesa->hw.cube[unit].cmd[CUBE_CMD_0];
-      GLuint bytesPerFace = texobj->base.totalSize / 6;
-      ASSERT(texobj->base.totalSize % 6 == 0);
+   if (texobj->base.Target == GL_TEXTURE_CUBE_MAP) {
+      GLuint *cube_cmd = &rmesa->hw.cube[unit].cmd[CUBE_CMD_0];
 
       R200_STATECHANGE( rmesa, cube[unit] );
       cube_cmd[CUBE_PP_CUBIC_FACES] = texobj->pp_cubic_faces;
-      if (rmesa->r200Screen->drmSupportsFragShader) {
+      if (rmesa->radeon.radeonScreen->drmSupportsFragShader) {
         /* that value is submitted twice. could change cube atom
            to not include that command when new drm is used */
         cmd[TEX_PP_CUBIC_FACES] = texobj->pp_cubic_faces;
       }
-      cube_cmd[CUBE_PP_CUBIC_OFFSET_F1] = texobj->pp_txoffset + 1 * bytesPerFace;
-      cube_cmd[CUBE_PP_CUBIC_OFFSET_F2] = texobj->pp_txoffset + 2 * bytesPerFace;
-      cube_cmd[CUBE_PP_CUBIC_OFFSET_F3] = texobj->pp_txoffset + 3 * bytesPerFace;
-      cube_cmd[CUBE_PP_CUBIC_OFFSET_F4] = texobj->pp_txoffset + 4 * bytesPerFace;
-      cube_cmd[CUBE_PP_CUBIC_OFFSET_F5] = texobj->pp_txoffset + 5 * bytesPerFace;
    }
 
-   texobj->dirty_state &= ~(1<<unit);
 }
 
-
 static void set_texgen_matrix( r200ContextPtr rmesa, 
                               GLuint unit,
                               const GLfloat *s_plane,
@@ -1377,7 +1261,6 @@ static GLboolean r200_validate_texgen( GLcontext *ctx, GLuint unit )
    } else {
       tgcm |= R200_TEXGEN_COMP_T << (unit * 4);
    }
-
    if (texUnit->TexGenEnabled & R_BIT) {
       if (texUnit->GenR.Mode != mode)
         mixed_fallback = GL_TRUE;
@@ -1517,52 +1400,6 @@ static GLboolean r200_validate_texgen( GLcontext *ctx, GLuint unit )
    return GL_TRUE;
 }
 
-
-static void disable_tex( GLcontext *ctx, int unit )
-{
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);
-
-   if (rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (R200_TEX_0_ENABLE<<unit)) {
-      /* Texture unit disabled */
-      if ( rmesa->state.texture.unit[unit].texobj != NULL ) {
-        /* The old texture is no longer bound to this texture unit.
-         * Mark it as such.
-         */
-
-        rmesa->state.texture.unit[unit].texobj->base.bound &= ~(1UL << unit);
-        rmesa->state.texture.unit[unit].texobj = NULL;
-      }
-
-      R200_STATECHANGE( rmesa, ctx );
-      rmesa->hw.ctx.cmd[CTX_PP_CNTL] &= ~(R200_TEX_0_ENABLE << unit);
-        
-      R200_STATECHANGE( rmesa, vtx );
-      rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_1] &= ~(7 << (unit * 3));
-        
-      if (rmesa->TclFallback & (R200_TCL_FALLBACK_TEXGEN_0<<unit)) {
-        TCL_FALLBACK( ctx, (R200_TCL_FALLBACK_TEXGEN_0<<unit), GL_FALSE);
-      }
-
-      /* Actually want to keep all units less than max active texture
-       * enabled, right?  Fix this for >2 texunits.
-       */
-
-      {
-        GLuint tmp = rmesa->TexGenEnabled;
-
-        rmesa->TexGenEnabled &= ~(R200_TEXGEN_TEXMAT_0_ENABLE<<unit);
-        rmesa->TexGenEnabled &= ~(R200_TEXMAT_0_ENABLE<<unit);
-        rmesa->TexGenNeedNormals[unit] = GL_FALSE;
-        rmesa->TexGenCompSel &= ~(R200_OUTPUT_TEX_0 << unit);
-
-        if (tmp != rmesa->TexGenEnabled) {
-           rmesa->recheck_texgen[unit] = GL_TRUE;
-           rmesa->NewGLState |= _NEW_TEXTURE_MATRIX;
-        }
-      }
-   }
-}
-
 void set_re_cntl_d3d( GLcontext *ctx, int unit, GLboolean use_d3d )
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
@@ -1579,237 +1416,169 @@ void set_re_cntl_d3d( GLcontext *ctx, int unit, GLboolean use_d3d )
    }
 }
 
-static GLboolean enable_tex_2d( GLcontext *ctx, int unit )
+/**
+ * Compute the cached hardware register values for the given texture object.
+ *
+ * \param rmesa Context pointer
+ * \param t the r300 texture object
+ */
+static void setup_hardware_state(r200ContextPtr rmesa, radeonTexObj *t)
 {
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-   struct gl_texture_object *tObj = texUnit->_Current;
-   r200TexObjPtr t = (r200TexObjPtr) tObj->DriverData;
-
-   /* Need to load the 2d images associated with this unit.
-    */
-   if (t->pp_txformat & R200_TXFORMAT_NON_POWER2) {
-      t->pp_txformat &= ~R200_TXFORMAT_NON_POWER2;
-      t->base.dirty_images[0] = ~0;
-   }
-
-   ASSERT(tObj->Target == GL_TEXTURE_2D || tObj->Target == GL_TEXTURE_1D);
-
-   if ( t->base.dirty_images[0] ) {
-      R200_FIREVERTICES( rmesa );
-      r200SetTexImages( rmesa, tObj );
-      r200UploadTexImages( rmesa, (r200TexObjPtr) tObj->DriverData, 0 );
-      if ( !t->base.memBlock && !t->image_override ) 
-        return GL_FALSE;
+   int firstlevel = t->mt ? t->mt->firstLevel : 0;
+   const struct gl_texture_image *firstImage = t->base.Image[0][firstlevel];
+   GLint log2Width, log2Height, log2Depth, texelBytes;
+   
+   if ( t->bo ) {
+       return;
    }
 
-   set_re_cntl_d3d( ctx, unit, GL_FALSE );
+   log2Width  = firstImage->WidthLog2;
+   log2Height = firstImage->HeightLog2;
+   log2Depth  = firstImage->DepthLog2;
+   texelBytes = firstImage->TexFormat->TexelBytes;
 
-   return GL_TRUE;
-}
 
-#if ENABLE_HW_3D_TEXTURE
-static GLboolean enable_tex_3d( GLcontext *ctx, int unit )
-{
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-   struct gl_texture_object *tObj = texUnit->_Current;
-   r200TexObjPtr t = (r200TexObjPtr) tObj->DriverData;
-
-   /* Need to load the 3d images associated with this unit.
-    */
-   if (t->pp_txformat & R200_TXFORMAT_NON_POWER2) {
-      t->pp_txformat &= ~R200_TXFORMAT_NON_POWER2;
-      t->base.dirty_images[0] = ~0;
+   if (!t->image_override) {
+      if (VALID_FORMAT(firstImage->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 |= table[ firstImage->TexFormat->MesaFormat ].format;
+        t->pp_txfilter |= table[ firstImage->TexFormat->MesaFormat ].filter;
+      } else {
+        _mesa_problem(NULL, "unexpected texture format in %s",
+                      __FUNCTION__);
+        return;
+      }
    }
+   
+   t->pp_txfilter &= ~R200_MAX_MIP_LEVEL_MASK;
+   t->pp_txfilter |= (t->mt->lastLevel - t->mt->firstLevel) << R200_MAX_MIP_LEVEL_SHIFT;
+       
+   t->pp_txformat &= ~(R200_TXFORMAT_WIDTH_MASK |
+                      R200_TXFORMAT_HEIGHT_MASK |
+                      R200_TXFORMAT_CUBIC_MAP_ENABLE |
+                      R200_TXFORMAT_F5_WIDTH_MASK |
+                      R200_TXFORMAT_F5_HEIGHT_MASK);
+   t->pp_txformat |= ((log2Width << R200_TXFORMAT_WIDTH_SHIFT) |
+                     (log2Height << R200_TXFORMAT_HEIGHT_SHIFT));
+   
+   t->tile_bits = 0;
+   
+   t->pp_txformat_x &= ~(R200_DEPTH_LOG2_MASK | R200_TEXCOORD_MASK);
+   if (t->base.Target == GL_TEXTURE_3D) {
+      t->pp_txformat_x |= (log2Depth << R200_DEPTH_LOG2_SHIFT);
+      t->pp_txformat_x |= R200_TEXCOORD_VOLUME;
 
-   ASSERT(tObj->Target == GL_TEXTURE_3D);
-
-   /* R100 & R200 do not support mipmaps for 3D textures.
-    */
-   if ( (tObj->MinFilter != GL_NEAREST) && (tObj->MinFilter != GL_LINEAR) ) {
-      return GL_FALSE;
    }
-
-   if ( t->base.dirty_images[0] ) {
-      R200_FIREVERTICES( rmesa );
-      r200SetTexImages( rmesa, tObj );
-      r200UploadTexImages( rmesa, (r200TexObjPtr) tObj->DriverData, 0 );
-      if ( !t->base.memBlock ) 
-        return GL_FALSE;
+   else if (t->base.Target == GL_TEXTURE_CUBE_MAP) {
+      ASSERT(log2Width == log2Height);
+      t->pp_txformat |= ((log2Width << R200_TXFORMAT_F5_WIDTH_SHIFT) |
+                        (log2Height << R200_TXFORMAT_F5_HEIGHT_SHIFT) |
+                        /* don't think we need this bit, if it exists at all - fglrx does not set it */
+                        (R200_TXFORMAT_CUBIC_MAP_ENABLE));
+      t->pp_txformat_x |= R200_TEXCOORD_CUBIC_ENV;
+      t->pp_cubic_faces = ((log2Width << R200_FACE_WIDTH_1_SHIFT) |
+                           (log2Height << R200_FACE_HEIGHT_1_SHIFT) |
+                           (log2Width << R200_FACE_WIDTH_2_SHIFT) |
+                           (log2Height << R200_FACE_HEIGHT_2_SHIFT) |
+                           (log2Width << R200_FACE_WIDTH_3_SHIFT) |
+                           (log2Height << R200_FACE_HEIGHT_3_SHIFT) |
+                           (log2Width << R200_FACE_WIDTH_4_SHIFT) |
+                           (log2Height << R200_FACE_HEIGHT_4_SHIFT));
    }
-
-   set_re_cntl_d3d( ctx, unit, GL_TRUE );
-
-   return GL_TRUE;
-}
-#endif
-
-static GLboolean enable_tex_cube( GLcontext *ctx, int unit )
-{
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-   struct gl_texture_object *tObj = texUnit->_Current;
-   r200TexObjPtr t = (r200TexObjPtr) tObj->DriverData;
-   GLuint face;
-
-   /* Need to load the 2d images associated with this unit.
-    */
-   if (t->pp_txformat & R200_TXFORMAT_NON_POWER2) {
-      t->pp_txformat &= ~R200_TXFORMAT_NON_POWER2;
-      for (face = 0; face < 6; face++)
-         t->base.dirty_images[face] = ~0;
+   else {
+      /* If we don't in fact send enough texture coordinates, q will be 1,
+       * making TEXCOORD_PROJ act like TEXCOORD_NONPROJ (Right?)
+       */
+      t->pp_txformat_x |= R200_TEXCOORD_PROJ;
    }
 
-   ASSERT(tObj->Target == GL_TEXTURE_CUBE_MAP);
+   t->pp_txsize = (((firstImage->Width - 1) << R200_PP_TX_WIDTHMASK_SHIFT)
+                  | ((firstImage->Height - 1) << R200_PP_TX_HEIGHTMASK_SHIFT));
 
-   if ( t->base.dirty_images[0] || t->base.dirty_images[1] ||
-        t->base.dirty_images[2] || t->base.dirty_images[3] ||
-        t->base.dirty_images[4] || t->base.dirty_images[5] ) {
-      /* flush */
-      R200_FIREVERTICES( rmesa );
-      /* layout memory space, once for all faces */
-      r200SetTexImages( rmesa, tObj );
-   }
-
-   /* upload (per face) */
-   for (face = 0; face < 6; face++) {
-      if (t->base.dirty_images[face]) {
-         r200UploadTexImages( rmesa, (r200TexObjPtr) tObj->DriverData, face );
-      }
-   }
-      
-   if ( !t->base.memBlock ) {
-      /* texmem alloc failed, use s/w fallback */
-      return GL_FALSE;
+   if ( !t->image_override ) {
+      if (firstImage->IsCompressed)
+         t->pp_txpitch = (firstImage->Width + 63) & ~(63);
+      else
+         t->pp_txpitch = ((firstImage->Width * texelBytes) + 63) & ~(63);
+      t->pp_txpitch -= 32;
    }
 
-   set_re_cntl_d3d( ctx, unit, GL_TRUE );
-
-   return GL_TRUE;
-}
-
-static GLboolean enable_tex_rect( GLcontext *ctx, int unit )
-{
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-   struct gl_texture_object *tObj = texUnit->_Current;
-   r200TexObjPtr t = (r200TexObjPtr) tObj->DriverData;
-
-   if (!(t->pp_txformat & R200_TXFORMAT_NON_POWER2)) {
+   if (t->base.Target == GL_TEXTURE_RECTANGLE_NV) {
       t->pp_txformat |= R200_TXFORMAT_NON_POWER2;
-      t->base.dirty_images[0] = ~0;
-   }
-
-   ASSERT(tObj->Target == GL_TEXTURE_RECTANGLE_NV);
-
-   if ( t->base.dirty_images[0] ) {
-      R200_FIREVERTICES( rmesa );
-      r200SetTexImages( rmesa, tObj );
-      r200UploadTexImages( rmesa, (r200TexObjPtr) tObj->DriverData, 0 );
-      if ( !t->base.memBlock &&
-           !t->image_override &&
-           !rmesa->prefer_gart_client_texturing ) 
-        return GL_FALSE;
    }
 
-   set_re_cntl_d3d( ctx, unit, GL_FALSE );
-
-   return GL_TRUE;
 }
 
-
-static GLboolean update_tex_common( GLcontext *ctx, int unit )
+static GLboolean r200_validate_texture(GLcontext *ctx, struct gl_texture_object *texObj, int unit)
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-   struct gl_texture_object *tObj = texUnit->_Current;
-   r200TexObjPtr t = (r200TexObjPtr) tObj->DriverData;
-
-   /* Fallback if there's a texture border */
-   if ( tObj->Image[0][tObj->BaseLevel]->Border > 0 )
-       return GL_FALSE;
-
-   /* Update state if this is a different texture object to last
-    * time.
-    */
-   if ( rmesa->state.texture.unit[unit].texobj != t ) {
-      if ( rmesa->state.texture.unit[unit].texobj != NULL ) {
-        /* The old texture is no longer bound to this texture unit.
-         * Mark it as such.
-         */
+   radeonTexObj *t = radeon_tex_obj(texObj);
 
-        rmesa->state.texture.unit[unit].texobj->base.bound &= 
-            ~(1UL << unit);
-      }
-
-      rmesa->state.texture.unit[unit].texobj = t;
-      t->base.bound |= (1UL << unit);
-      t->dirty_state |= 1<<unit;
-      driUpdateTextureLRU( (driTextureObject *) t ); /* XXX: should be locked! */
-   }
-
-
-   /* Newly enabled?
-    */
-   if ( 1|| !(rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (R200_TEX_0_ENABLE<<unit))) {
-      R200_STATECHANGE( rmesa, ctx );
-      rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= R200_TEX_0_ENABLE << unit;
-
-      R200_STATECHANGE( rmesa, vtx );
-      rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_1] &= ~(7 << (unit * 3));
-      rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_1] |= 4 << (unit * 3);
+   if (!radeon_validate_texture_miptree(ctx, texObj))
+      return GL_FALSE;
 
-      rmesa->recheck_texgen[unit] = GL_TRUE;
-   }
+   r200_validate_texgen(ctx, unit);
+   /* Configure the hardware registers (more precisely, the cached version
+    * of the hardware registers). */
+   setup_hardware_state(rmesa, t);
+
+   if (texObj->Target == GL_TEXTURE_RECTANGLE_NV ||
+       texObj->Target == GL_TEXTURE_2D ||
+       texObj->Target == GL_TEXTURE_1D)
+      set_re_cntl_d3d( ctx, unit, GL_FALSE );
+   else
+      set_re_cntl_d3d( ctx, unit, GL_TRUE );
+   R200_STATECHANGE( rmesa, ctx );
+   rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= R200_TEX_0_ENABLE << unit;
+   
+   R200_STATECHANGE( rmesa, vtx );
+   rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_1] &= ~(7 << (unit * 3));
+   rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_1] |= 4 << (unit * 3);
 
-   if (t->dirty_state & (1<<unit)) {
-      import_tex_obj_state( rmesa, unit, t );
-   }
+   rmesa->recheck_texgen[unit] = GL_TRUE;
+   import_tex_obj_state( rmesa, unit, t );
 
    if (rmesa->recheck_texgen[unit]) {
       GLboolean fallback = !r200_validate_texgen( ctx, unit );
       TCL_FALLBACK( ctx, (R200_TCL_FALLBACK_TEXGEN_0<<unit), fallback);
       rmesa->recheck_texgen[unit] = 0;
-      rmesa->NewGLState |= _NEW_TEXTURE_MATRIX;
+      rmesa->radeon.NewGLState |= _NEW_TEXTURE_MATRIX;
    }
 
-   FALLBACK( rmesa, R200_FALLBACK_BORDER_MODE, t->border_fallback );
-   return !t->border_fallback;
-}
+   t->validated = GL_TRUE;
 
+   FALLBACK( rmesa, RADEON_FALLBACK_BORDER_MODE, t->border_fallback );
 
+   return !t->border_fallback;
+}
 
-static GLboolean r200UpdateTextureUnit( GLcontext *ctx, int unit )
+static GLboolean r200UpdateTextureUnit(GLcontext *ctx, int unit)
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
    GLuint unitneeded = rmesa->state.texture.unit[unit].unitneeded;
 
-   if ( unitneeded & (TEXTURE_RECT_BIT) ) {
-      return (enable_tex_rect( ctx, unit ) &&
-             update_tex_common( ctx, unit ));
-   }
-   else if ( unitneeded & (TEXTURE_1D_BIT | TEXTURE_2D_BIT) ) {
-      return (enable_tex_2d( ctx, unit ) &&
-             update_tex_common( ctx, unit ));
-   }
-#if ENABLE_HW_3D_TEXTURE
-   else if ( unitneeded & (TEXTURE_3D_BIT) ) {
-      return (enable_tex_3d( ctx, unit ) &&
-             update_tex_common( ctx, unit ));
-   }
-#endif
-   else if ( unitneeded & (TEXTURE_CUBE_BIT) ) {
-      return (enable_tex_cube( ctx, unit ) &&
-             update_tex_common( ctx, unit ));
-   }
-   else if ( unitneeded ) {
-      return GL_FALSE;
-   }
-   else {
-      disable_tex( ctx, unit );
-      return GL_TRUE;
+   if (!unitneeded) {
+      /* disable the unit */
+     disable_tex_obj_state(rmesa, unit);
+     return GL_TRUE;
    }
+
+   if (!r200_validate_texture(ctx, ctx->Texture.Unit[unit]._Current, unit)) {
+    _mesa_warning(ctx,
+                 "failed to validate texture for unit %d.\n",
+                 unit);
+    rmesa->state.texture.unit[unit].texobj = NULL;
+    return GL_FALSE;
+  }
+
+   rmesa->state.texture.unit[unit].texobj = radeon_tex_obj(ctx->Texture.Unit[unit]._Current);
+  return GL_TRUE;
 }
 
 
@@ -1850,11 +1619,11 @@ void r200UpdateTextureState( GLcontext *ctx )
 
    FALLBACK( rmesa, R200_FALLBACK_TEXTURE, !ok );
 
-   if (rmesa->TclFallback)
+   if (rmesa->radeon.TclFallback)
       r200ChooseVertexState( ctx );
 
 
-   if (rmesa->r200Screen->chip_family == CHIP_FAMILY_R200) {
+   if (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R200) {
 
       /*
        * T0 hang workaround -------------
@@ -1867,7 +1636,7 @@ void r200UpdateTextureState( GLcontext *ctx )
         R200_STATECHANGE(rmesa, tex[1]);
         rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= R200_TEX_1_ENABLE;
         if (!(rmesa->hw.cst.cmd[CST_PP_CNTL_X] & R200_PPX_TEX_1_ENABLE))
-           rmesa->hw.tex[1].cmd[TEX_PP_TXFORMAT] &= ~TEXOBJ_TXFORMAT_MASK;
+          rmesa->hw.tex[1].cmd[TEX_PP_TXFORMAT] &= ~TEXOBJ_TXFORMAT_MASK;
         rmesa->hw.tex[1].cmd[TEX_PP_TXFORMAT] |= R200_TXFORMAT_LOOKUP_DISABLE;
       }
       else if (!ctx->ATIFragmentShader._Enabled) {
index 4ce93b514535c2d0249e8f744f84d5aa5685755a..620f29b5c6e0537be00abf8286a77bb32944d90d 100644 (file)
@@ -1110,9 +1110,9 @@ void r200SetupVertexProg( GLcontext *ctx ) {
    }
    /* could optimize setting up vertex progs away for non-tcl hw */
    fallback = !(vp->native && r200VertexProgUpdateParams(ctx, vp) &&
-      rmesa->r200Screen->drmSupportsVertexProgram);
+      rmesa->radeon.radeonScreen->drmSupportsVertexProgram);
    TCL_FALLBACK(ctx, R200_TCL_FALLBACK_VERTEX_PROGRAM, fallback);
-   if (rmesa->TclFallback) return;
+   if (rmesa->radeon.TclFallback) return;
 
    R200_STATECHANGE( rmesa, vap );
    /* FIXME: fglrx sets R200_VAP_SINGLE_BUF_STATE_ENABLE too. Do we need it?
index 6ca934204f38c6d7f4ec53b19328b145d9f558e2..bdb09624be40104cc6d247ebfdd86369fd0eac07 100644 (file)
@@ -3,6 +3,8 @@
 TOP = ../../../../..
 include $(TOP)/configs/current
 
+CFLAGS += $(RADEON_CFLAGS)
+
 LIBNAME = r300_dri.so
 
 MINIGLX_SOURCES = server/radeon_dri.c
@@ -20,20 +22,26 @@ COMMON_SOURCES = \
        ../common/xmlconfig.c \
        ../common/dri_util.c
 
+RADEON_COMMON_SOURCES = \
+       radeon_texture.c \
+       radeon_common_context.c \
+       radeon_common.c \
+       radeon_dma.c \
+       radeon_lock.c \
+       radeon_bo_legacy.c \
+       radeon_cs_legacy.c \
+       radeon_mipmap_tree.c \
+       radeon_span.c \
+       radeon_fbo.c
+
 DRIVER_SOURCES = \
                 radeon_screen.c \
-                radeon_context.c \
-                radeon_ioctl.c \
-                radeon_lock.c \
-                radeon_span.c \
-                radeon_state.c \
-                r300_mem.c \
                 r300_context.c \
+                r300_draw.c \
                 r300_ioctl.c \
                 r300_cmdbuf.c \
                 r300_state.c \
                 r300_render.c \
-                r300_texmem.c \
                 r300_tex.c \
                 r300_texstate.c \
                 radeon_program.c \
@@ -41,6 +49,7 @@ DRIVER_SOURCES = \
                 radeon_program_pair.c \
                 radeon_nqssadce.c \
                 r300_vertprog.c \
+                r300_fragprog_common.c \
                 r300_fragprog.c \
                 r300_fragprog_swizzle.c \
                 r300_fragprog_emit.c \
@@ -49,12 +58,15 @@ DRIVER_SOURCES = \
                 r300_shader.c \
                 r300_emit.c \
                 r300_swtcl.c \
+                $(RADEON_COMMON_SOURCES) \
                 $(EGL_SOURCES)
 
 C_SOURCES = $(COMMON_SOURCES) $(DRIVER_SOURCES)
 
 DRIVER_DEFINES = -DCOMPILE_R300 -DR200_MERGED=0 \
-       -DRADEON_COMMON=1 -DRADEON_COMMON_FOR_R300
+       -DRADEON_COMMON=1 -DRADEON_COMMON_FOR_R300 \
+#      -DRADEON_BO_TRACK \
+       -Wall
 
 SYMLINKS = \
        server/radeon_dri.c \
@@ -68,7 +80,29 @@ COMMON_SYMLINKS = \
        radeon_chipset.h \
        radeon_screen.c \
        radeon_screen.h \
-       radeon_span.h
+       radeon_span.h \
+       radeon_span.c \
+       radeon_bo_legacy.c \
+       radeon_cs_legacy.c \
+       radeon_bo_legacy.h \
+       radeon_cs_legacy.h \
+       radeon_bocs_wrapper.h \
+       radeon_lock.c \
+       radeon_lock.h \
+       radeon_common.c \
+       radeon_common.h \
+       radeon_common_context.c \
+       radeon_common_context.h \
+       radeon_cmdbuf.h \
+       radeon_dma.c \
+       radeon_dma.h \
+       radeon_mipmap_tree.c \
+       radeon_mipmap_tree.h \
+       radeon_texture.c \
+       radeon_texture.h \
+       radeon_fbo.c
+
+DRI_LIB_DEPS += $(RADEON_LDFLAGS)
 
 ##### TARGETS #####
 
index f4472756f109c2c4256702ddbb2f356af1e6f819..0261a5b1d8ace091057e26854649de7de488a37c 100644 (file)
@@ -44,245 +44,417 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "drm.h"
 #include "radeon_drm.h"
 
-#include "radeon_ioctl.h"
 #include "r300_context.h"
 #include "r300_ioctl.h"
 #include "radeon_reg.h"
 #include "r300_reg.h"
 #include "r300_cmdbuf.h"
 #include "r300_emit.h"
+#include "radeon_bocs_wrapper.h"
+#include "radeon_mipmap_tree.h"
 #include "r300_state.h"
+#include "radeon_reg.h"
 
-// Set this to 1 for extremely verbose debugging of command buffers
-#define DEBUG_CMDBUF           0
-
-/**
- * Send the current command buffer via ioctl to the hardware.
+/** # of dwords reserved for additional instructions that may need to be written
+ * during flushing.
  */
-int r300FlushCmdBufLocked(r300ContextPtr r300, const char *caller)
+#define SPACE_FOR_FLUSHING     4
+
+static unsigned packet0_count(r300ContextPtr r300, uint32_t *pkt)
 {
-       int ret;
-       int i;
-       drm_radeon_cmd_buffer_t cmd;
-       int start;
-
-       if (r300->radeon.lost_context) {
-               start = 0;
-               r300->radeon.lost_context = GL_FALSE;
-       } else
-               start = r300->cmdbuf.count_reemit;
-
-       if (RADEON_DEBUG & DEBUG_IOCTL) {
-               fprintf(stderr, "%s from %s - %i cliprects\n",
-                       __FUNCTION__, caller, r300->radeon.numClipRects);
-
-               if (DEBUG_CMDBUF && RADEON_DEBUG & DEBUG_VERBOSE)
-                       for (i = start; i < r300->cmdbuf.count_used; ++i)
-                               fprintf(stderr, "%d: %08x\n", i,
-                                       r300->cmdbuf.cmd_buf[i]);
-       }
+    if (r300->radeon.radeonScreen->kernel_mm) {
+        return ((((*pkt) >> 16) & 0x3FFF) + 1);
+    } else {
+        drm_r300_cmd_header_t *t = (drm_r300_cmd_header_t*)pkt;
+        return t->packet0.count;
+    }
+}
 
-       cmd.buf = (char *)(r300->cmdbuf.cmd_buf + start);
-       cmd.bufsz = (r300->cmdbuf.count_used - start) * 4;
+#define vpu_count(ptr) (((drm_r300_cmd_header_t*)(ptr))->vpu.count)
+#define r500fp_count(ptr) (((drm_r300_cmd_header_t*)(ptr))->r500fp.count)
 
-       if (r300->radeon.state.scissor.enabled) {
-               cmd.nbox = r300->radeon.state.scissor.numClipRects;
-               cmd.boxes =
-                   (drm_clip_rect_t *) r300->radeon.state.scissor.pClipRects;
-       } else {
-               cmd.nbox = r300->radeon.numClipRects;
-               cmd.boxes = (drm_clip_rect_t *) r300->radeon.pClipRects;
+void emit_vpu(GLcontext *ctx, struct radeon_state_atom * atom)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       BATCH_LOCALS(&r300->radeon);
+       drm_r300_cmd_header_t cmd;
+       uint32_t addr, ndw, i;
+
+       if (!r300->radeon.radeonScreen->kernel_mm) {
+               uint32_t dwords;
+               dwords = (*atom->check) (ctx, atom);
+               BEGIN_BATCH_NO_AUTOSTATE(dwords);
+               OUT_BATCH_TABLE(atom->cmd, dwords);
+               END_BATCH();
+               return;
        }
 
-       ret = drmCommandWrite(r300->radeon.dri.fd,
-                             DRM_RADEON_CMDBUF, &cmd, sizeof(cmd));
-
-       if (RADEON_DEBUG & DEBUG_SYNC) {
-               fprintf(stderr, "Syncing in %s (from %s)\n\n",
-                       __FUNCTION__, caller);
-               radeonWaitForIdleLocked(&r300->radeon);
+       cmd.u = atom->cmd[0];
+       addr = (cmd.vpu.adrhi << 8) | cmd.vpu.adrlo;
+       ndw = cmd.vpu.count * 4;
+       if (ndw) {
+
+               if (r300->vap_flush_needed) {
+                       BEGIN_BATCH_NO_AUTOSTATE(15 + ndw);
+
+                       /* flush processing vertices */
+                       OUT_BATCH_REGVAL(R300_SC_SCREENDOOR, 0);
+                       OUT_BATCH_REGVAL(R300_RB3D_DSTCACHE_CTLSTAT, R300_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_FLUSH_DIRTY_3D);
+                       OUT_BATCH_REGVAL(RADEON_WAIT_UNTIL, RADEON_WAIT_3D_IDLECLEAN);
+                       OUT_BATCH_REGVAL(R300_SC_SCREENDOOR, 0xffffff);
+                       OUT_BATCH_REGVAL(R300_VAP_PVS_STATE_FLUSH_REG, 0);
+                       r300->vap_flush_needed = GL_FALSE;
+               } else {
+                       BEGIN_BATCH_NO_AUTOSTATE(5 + ndw);
+               }
+               OUT_BATCH_REGVAL(R300_VAP_PVS_VECTOR_INDX_REG, addr);
+               OUT_BATCH(CP_PACKET0(R300_VAP_PVS_UPLOAD_DATA, ndw-1) | RADEON_ONE_REG_WR);
+               for (i = 0; i < ndw; i++) {
+                       OUT_BATCH(atom->cmd[i+1]);
+               }
+               OUT_BATCH_REGVAL(R300_VAP_PVS_STATE_FLUSH_REG, 0);
+               END_BATCH();
        }
-
-       r300->dma.nr_released_bufs = 0;
-       r300->cmdbuf.count_used = 0;
-       r300->cmdbuf.count_reemit = 0;
-
-       return ret;
 }
 
-int r300FlushCmdBuf(r300ContextPtr r300, const char *caller)
+void emit_r500fp(GLcontext *ctx, struct radeon_state_atom * atom)
 {
-       int ret;
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       BATCH_LOCALS(&r300->radeon);
+       drm_r300_cmd_header_t cmd;
+       uint32_t addr, ndw, i, sz;
+       int type, clamp, stride;
+
+       if (!r300->radeon.radeonScreen->kernel_mm) {
+               uint32_t dwords;
+               dwords = (*atom->check) (ctx, atom);
+               BEGIN_BATCH_NO_AUTOSTATE(dwords);
+               OUT_BATCH_TABLE(atom->cmd, dwords);
+               END_BATCH();
+               return;
+       }
 
-       LOCK_HARDWARE(&r300->radeon);
+       cmd.u = atom->cmd[0];
+       sz = cmd.r500fp.count;
+       addr = ((cmd.r500fp.adrhi_flags & 1) << 8) | cmd.r500fp.adrlo;
+       type = !!(cmd.r500fp.adrhi_flags & R500FP_CONSTANT_TYPE);
+       clamp = !!(cmd.r500fp.adrhi_flags & R500FP_CONSTANT_CLAMP);
 
-       ret = r300FlushCmdBufLocked(r300, caller);
+       addr |= (type << 16);
+       addr |= (clamp << 17);
 
-       UNLOCK_HARDWARE(&r300->radeon);
+       stride = type ? 4 : 6;
 
-       if (ret) {
-               fprintf(stderr, "drmRadeonCmdBuffer: %d\n", ret);
-               _mesa_exit(ret);
-       }
+       ndw = sz * stride;
+       if (ndw) {
 
-       return ret;
+               BEGIN_BATCH_NO_AUTOSTATE(3 + ndw);
+               OUT_BATCH(CP_PACKET0(R500_GA_US_VECTOR_INDEX, 0));
+               OUT_BATCH(addr);
+               OUT_BATCH(CP_PACKET0(R500_GA_US_VECTOR_DATA, ndw-1) | RADEON_ONE_REG_WR);
+               for (i = 0; i < ndw; i++) {
+                       OUT_BATCH(atom->cmd[i+1]);
+               }
+               END_BATCH();
+       }
 }
 
-static void r300PrintStateAtom(r300ContextPtr r300, struct r300_state_atom *state)
+static void emit_tex_offsets(GLcontext *ctx, struct radeon_state_atom * atom)
 {
-       int i, j, reg;
-       int dwords = (*state->check) (r300, state);
-       drm_r300_cmd_header_t cmd;
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       BATCH_LOCALS(&r300->radeon);
+       int numtmus = packet0_count(r300, r300->hw.tex.offset.cmd);
+       int notexture = 0;
 
-       fprintf(stderr, "  emit %s %d/%d\n", state->name, dwords,
-               state->cmd_size);
-
-       if (RADEON_DEBUG & DEBUG_VERBOSE) {
-               for (i = 0; i < dwords;) {
-                       cmd = *((drm_r300_cmd_header_t *) &state->cmd[i]);
-                       reg = (cmd.packet0.reghi << 8) | cmd.packet0.reglo;
-                       fprintf(stderr, "      %s[%d]: cmdpacket0 (first reg=0x%04x, count=%d)\n",
-                                       state->name, i, reg, cmd.packet0.count);
-                       ++i;
-                       for (j = 0; j < cmd.packet0.count; j++) {
-                               fprintf(stderr, "      %s[%d]: 0x%04x = %08x\n",
-                                       state->name, i, reg, state->cmd[i]);
-                               reg += 4;
-                               ++i;
-                       }
+       if (numtmus) {
+               int i;
+
+               for(i = 0; i < numtmus; ++i) {
+                   radeonTexObj *t = r300->hw.textures[i];
+
+                   if (!t)
+                       notexture = 1;
+               }
+
+               if (r300->radeon.radeonScreen->kernel_mm && notexture) {
+                       return;
+               }
+               for(i = 0; i < numtmus; ++i) {
+                   radeonTexObj *t = r300->hw.textures[i];
+                   if (t && !t->image_override) {
+                BEGIN_BATCH_NO_AUTOSTATE(4);
+                OUT_BATCH_REGSEQ(R300_TX_OFFSET_0 + (i * 4), 1);
+                           OUT_BATCH_RELOC(t->tile_bits, t->mt->bo, 0,
+                                           RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);
+                END_BATCH();
+                   } else if (!t) {
+                /* Texture unit hasn't a texture bound nothings to do */
+                   } else { /* override cases */
+                           if (t->bo) {
+                    BEGIN_BATCH_NO_AUTOSTATE(4);
+                    OUT_BATCH_REGSEQ(R300_TX_OFFSET_0 + (i * 4), 1);
+                                   OUT_BATCH_RELOC(t->tile_bits, t->bo, 0,
+                                                   RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);
+                    END_BATCH();
+                           } else if (!r300->radeon.radeonScreen->kernel_mm) {
+                    BEGIN_BATCH_NO_AUTOSTATE(2);
+                    OUT_BATCH_REGSEQ(R300_TX_OFFSET_0 + (i * 4), 1);
+                                   OUT_BATCH(t->override_offset);
+                    END_BATCH();
+                           } else {
+                    /* Texture unit hasn't a texture bound nothings to do */
+                }
+                   }
                }
        }
 }
 
-/**
- * Emit all atoms with a dirty field equal to dirty.
- *
- * The caller must have ensured that there is enough space in the command
- * buffer.
- */
-static INLINE void r300EmitAtoms(r300ContextPtr r300, GLboolean dirty)
+void r300_emit_scissor(GLcontext *ctx)
 {
-       struct r300_state_atom *atom;
-       uint32_t *dest;
-       int dwords;
-
-       dest = r300->cmdbuf.cmd_buf + r300->cmdbuf.count_used;
-
-       /* Emit WAIT */
-       *dest = cmdwait(R300_WAIT_3D | R300_WAIT_3D_CLEAN);
-       dest++;
-       r300->cmdbuf.count_used++;
-
-       /* Emit cache flush */
-       *dest = cmdpacket0(R300_TX_INVALTAGS, 1);
-       dest++;
-       r300->cmdbuf.count_used++;
-
-       *dest = R300_TX_FLUSH;
-       dest++;
-       r300->cmdbuf.count_used++;
-
-       /* Emit END3D */
-       *dest = cmdpacify();
-       dest++;
-       r300->cmdbuf.count_used++;
-
-       /* Emit actual atoms */
-
-       foreach(atom, &r300->hw.atomlist) {
-               if ((atom->dirty || r300->hw.all_dirty) == dirty) {
-                       dwords = (*atom->check) (r300, atom);
-                       if (dwords) {
-                               if (DEBUG_CMDBUF && RADEON_DEBUG & DEBUG_STATE) {
-                                       r300PrintStateAtom(r300, atom);
-                               }
-                               memcpy(dest, atom->cmd, dwords * 4);
-                               dest += dwords;
-                               r300->cmdbuf.count_used += dwords;
-                               atom->dirty = GL_FALSE;
-                       } else {
-                               if (DEBUG_CMDBUF && RADEON_DEBUG & DEBUG_STATE) {
-                                       fprintf(stderr, "  skip state %s\n",
-                                               atom->name);
-                               }
-                       }
-               }
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       BATCH_LOCALS(&r300->radeon);
+    unsigned x1, y1, x2, y2;
+       struct radeon_renderbuffer *rrb;
+
+    if (!r300->radeon.radeonScreen->driScreen->dri2.enabled) {
+        return;
+    }
+       rrb = radeon_get_colorbuffer(&r300->radeon);
+       if (!rrb || !rrb->bo) {
+               fprintf(stderr, "no rrb\n");
+               return;
        }
+    if (r300->radeon.state.scissor.enabled) {
+        x1 = r300->radeon.state.scissor.rect.x1;
+        y1 = r300->radeon.state.scissor.rect.y1;
+        x2 = r300->radeon.state.scissor.rect.x2 - 1;
+        y2 = r300->radeon.state.scissor.rect.y2 - 1;
+    } else {
+        x1 = 0;
+        y1 = 0;
+        x2 = rrb->width - 1;
+        y2 = rrb->height - 1;
+    }
+    if (r300->radeon.radeonScreen->chip_family < CHIP_FAMILY_RV515) {
+        x1 += R300_SCISSORS_OFFSET;
+        y1 += R300_SCISSORS_OFFSET;
+        x2 += R300_SCISSORS_OFFSET;
+        y2 += R300_SCISSORS_OFFSET;
+    }
+    BEGIN_BATCH_NO_AUTOSTATE(3);
+    OUT_BATCH_REGSEQ(R300_SC_SCISSORS_TL, 2);
+    OUT_BATCH((x1 << R300_SCISSORS_X_SHIFT)|(y1 << R300_SCISSORS_Y_SHIFT));
+    OUT_BATCH((x2 << R300_SCISSORS_X_SHIFT)|(y2 << R300_SCISSORS_Y_SHIFT));
+    END_BATCH();
 }
 
-/**
- * Copy dirty hardware state atoms into the command buffer.
- *
- * We also copy out clean state if we're at the start of a buffer. That makes
- * it easy to recover from lost contexts.
- */
-void r300EmitState(r300ContextPtr r300)
+static void emit_cb_offset(GLcontext *ctx, struct radeon_state_atom * atom)
 {
-       if (RADEON_DEBUG & (DEBUG_STATE | DEBUG_PRIMS))
-               fprintf(stderr, "%s\n", __FUNCTION__);
-
-       if (r300->cmdbuf.count_used && !r300->hw.is_dirty
-           && !r300->hw.all_dirty)
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       BATCH_LOCALS(&r300->radeon);
+       struct radeon_renderbuffer *rrb;
+       uint32_t cbpitch;
+       uint32_t offset = r300->radeon.state.color.draw_offset;
+       uint32_t dw = 6;
+    int i;
+
+       rrb = radeon_get_colorbuffer(&r300->radeon);
+       if (!rrb || !rrb->bo) {
+               fprintf(stderr, "no rrb\n");
                return;
+       }
 
-       /* To avoid going across the entire set of states multiple times, just check
-        * for enough space for the case of emitting all state, and inline the
-        * r300AllocCmdBuf code here without all the checks.
-        */
-       r300EnsureCmdBufSpace(r300, r300->hw.max_state_size, __FUNCTION__);
+       cbpitch = (rrb->pitch / rrb->cpp);
+       if (rrb->cpp == 4)
+               cbpitch |= R300_COLOR_FORMAT_ARGB8888;
+       else
+               cbpitch |= R300_COLOR_FORMAT_RGB565;
+
+       if (rrb->bo->flags & RADEON_BO_FLAGS_MACRO_TILE)
+               cbpitch |= R300_COLOR_TILE_ENABLE;
+
+       if (r300->radeon.radeonScreen->kernel_mm)
+               dw += 2;
+       BEGIN_BATCH_NO_AUTOSTATE(dw);
+       OUT_BATCH_REGSEQ(R300_RB3D_COLOROFFSET0, 1);
+       OUT_BATCH_RELOC(offset, rrb->bo, offset, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+       OUT_BATCH_REGSEQ(R300_RB3D_COLORPITCH0, 1);
+       if (!r300->radeon.radeonScreen->kernel_mm)
+               OUT_BATCH(cbpitch);
+       else
+               OUT_BATCH_RELOC(cbpitch, rrb->bo, cbpitch, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+       END_BATCH();
+    if (r300->radeon.radeonScreen->driScreen->dri2.enabled) {
+        if (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) {
+            BEGIN_BATCH_NO_AUTOSTATE(3);
+            OUT_BATCH_REGSEQ(R300_SC_SCISSORS_TL, 2);
+            OUT_BATCH(0);
+            OUT_BATCH(((rrb->width - 1) << R300_SCISSORS_X_SHIFT) |
+                    ((rrb->height - 1) << R300_SCISSORS_Y_SHIFT));
+            END_BATCH();
+            BEGIN_BATCH_NO_AUTOSTATE(16);
+            for (i = 0; i < 4; i++) {
+                OUT_BATCH_REGSEQ(R300_SC_CLIPRECT_TL_0 + (i * 8), 2);
+                OUT_BATCH((0 << R300_CLIPRECT_X_SHIFT) | (0 << R300_CLIPRECT_Y_SHIFT));
+                OUT_BATCH(((rrb->width - 1) << R300_CLIPRECT_X_SHIFT) | ((rrb->height - 1) << R300_CLIPRECT_Y_SHIFT));
+            }
+            OUT_BATCH_REGSEQ(R300_SC_CLIP_RULE, 1);
+            OUT_BATCH(0xAAAA);
+            OUT_BATCH_REGSEQ(R300_SC_SCREENDOOR, 1);
+            OUT_BATCH(0xffffff);
+            END_BATCH();
+        } else {
+            BEGIN_BATCH_NO_AUTOSTATE(3);
+            OUT_BATCH_REGSEQ(R300_SC_SCISSORS_TL, 2);
+            OUT_BATCH((R300_SCISSORS_OFFSET << R300_SCISSORS_X_SHIFT) |
+                    (R300_SCISSORS_OFFSET << R300_SCISSORS_Y_SHIFT));
+            OUT_BATCH(((rrb->width + R300_SCISSORS_OFFSET - 1) << R300_SCISSORS_X_SHIFT) |
+                    ((rrb->height + R300_SCISSORS_OFFSET - 1) << R300_SCISSORS_Y_SHIFT));
+            END_BATCH();
+            BEGIN_BATCH_NO_AUTOSTATE(16);
+            for (i = 0; i < 4; i++) {
+                OUT_BATCH_REGSEQ(R300_SC_CLIPRECT_TL_0 + (i * 8), 2);
+                OUT_BATCH((R300_SCISSORS_OFFSET << R300_CLIPRECT_X_SHIFT) | (R300_SCISSORS_OFFSET << R300_CLIPRECT_Y_SHIFT));
+                OUT_BATCH(((R300_SCISSORS_OFFSET + rrb->width - 1) << R300_CLIPRECT_X_SHIFT) |
+                          ((R300_SCISSORS_OFFSET + rrb->height - 1) << R300_CLIPRECT_Y_SHIFT));
+            }
+            OUT_BATCH_REGSEQ(R300_SC_CLIP_RULE, 1);
+            OUT_BATCH(0xAAAA);
+            OUT_BATCH_REGSEQ(R300_SC_SCREENDOOR, 1);
+            OUT_BATCH(0xffffff);
+            END_BATCH();
+        }
+    }
+}
 
-       if (!r300->cmdbuf.count_used) {
-               if (RADEON_DEBUG & DEBUG_STATE)
-                       fprintf(stderr, "Begin reemit state\n");
+static void emit_zb_offset(GLcontext *ctx, struct radeon_state_atom * atom)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       BATCH_LOCALS(&r300->radeon);
+       struct radeon_renderbuffer *rrb;
+       uint32_t zbpitch;
 
-               r300EmitAtoms(r300, GL_FALSE);
-               r300->cmdbuf.count_reemit = r300->cmdbuf.count_used;
+       rrb = radeon_get_depthbuffer(&r300->radeon);
+       if (!rrb)
+               return;
+
+       zbpitch = (rrb->pitch / rrb->cpp);
+       if (rrb->bo->flags & RADEON_BO_FLAGS_MACRO_TILE) {
+               zbpitch |= R300_DEPTHMACROTILE_ENABLE;
+       }
+       if (rrb->bo->flags & RADEON_BO_FLAGS_MICRO_TILE){
+               zbpitch |= R300_DEPTHMICROTILE_TILED;
        }
 
-       if (RADEON_DEBUG & DEBUG_STATE)
-               fprintf(stderr, "Begin dirty state\n");
+       BEGIN_BATCH_NO_AUTOSTATE(6);
+       OUT_BATCH_REGSEQ(R300_ZB_DEPTHOFFSET, 1);
+       OUT_BATCH_RELOC(0, rrb->bo, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+       OUT_BATCH_REGVAL(R300_ZB_DEPTHPITCH, zbpitch);
+       END_BATCH();
+}
 
-       r300EmitAtoms(r300, GL_TRUE);
+static void emit_gb_misc(GLcontext *ctx, struct radeon_state_atom * atom)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       BATCH_LOCALS(&r300->radeon);
+    if (!r300->radeon.radeonScreen->driScreen->dri2.enabled) {
+        BEGIN_BATCH_NO_AUTOSTATE(4);
+        OUT_BATCH(atom->cmd[0]);
+        OUT_BATCH(atom->cmd[1]);
+        OUT_BATCH(atom->cmd[2]);
+        OUT_BATCH(atom->cmd[3]);
+        END_BATCH();
+    }
+}
 
-       assert(r300->cmdbuf.count_used < r300->cmdbuf.size);
+static void emit_threshold_misc(GLcontext *ctx, struct radeon_state_atom * atom)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       BATCH_LOCALS(&r300->radeon);
+    if (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) {
+        BEGIN_BATCH_NO_AUTOSTATE(3);
+        OUT_BATCH(atom->cmd[0]);
+        OUT_BATCH(atom->cmd[1]);
+        OUT_BATCH(atom->cmd[2]);
+        END_BATCH();
+    }
+}
 
-       r300->hw.is_dirty = GL_FALSE;
-       r300->hw.all_dirty = GL_FALSE;
+static void emit_shade_misc(GLcontext *ctx, struct radeon_state_atom * atom)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       BATCH_LOCALS(&r300->radeon);
+
+    if (!r300->radeon.radeonScreen->driScreen->dri2.enabled) {
+        BEGIN_BATCH_NO_AUTOSTATE(2);
+        OUT_BATCH(atom->cmd[0]);
+        OUT_BATCH(atom->cmd[1]);
+        END_BATCH();
+    }
 }
 
-#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 void emit_zstencil_format(GLcontext *ctx, struct radeon_state_atom * atom)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       BATCH_LOCALS(&r300->radeon);
+       struct radeon_renderbuffer *rrb;
+       uint32_t format = 0;
+
+       rrb = radeon_get_depthbuffer(&r300->radeon);
+       if (!rrb)
+         format = 0;
+       else {
+         if (rrb->cpp == 2)
+           format = R300_DEPTHFORMAT_16BIT_INT_Z;
+         else if (rrb->cpp == 4)
+           format = R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL;
+       }
+
+       OUT_BATCH(atom->cmd[0]);
+       atom->cmd[1] &= ~0xf;
+       atom->cmd[1] |= format;
+       OUT_BATCH(atom->cmd[1]);
+       OUT_BATCH(atom->cmd[2]);
+       OUT_BATCH(atom->cmd[3]);
+       OUT_BATCH(atom->cmd[4]);
+}
 
-static int check_always(r300ContextPtr r300, struct r300_state_atom *atom)
+static int check_always(GLcontext *ctx, struct radeon_state_atom *atom)
 {
        return atom->cmd_size;
 }
 
-static int check_variable(r300ContextPtr r300, struct r300_state_atom *atom)
+static int check_variable(GLcontext *ctx, struct radeon_state_atom *atom)
 {
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
        int cnt;
-       cnt = packet0_count(atom->cmd);
+       if (atom->cmd[0] == CP_PACKET2) {
+               return 0;
+       }
+       cnt = packet0_count(r300, atom->cmd);
        return cnt ? cnt + 1 : 0;
 }
 
-static int check_vpu(r300ContextPtr r300, struct r300_state_atom *atom)
+int check_vpu(GLcontext *ctx, struct radeon_state_atom *atom)
 {
        int cnt;
+
        cnt = vpu_count(atom->cmd);
        return cnt ? (cnt * 4) + 1 : 0;
 }
 
-static int check_r500fp(r300ContextPtr r300, struct r300_state_atom *atom)
+int check_r500fp(GLcontext *ctx, struct radeon_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 check_r500fp_const(GLcontext *ctx, struct radeon_state_atom *atom)
 {
        int cnt;
+
        cnt = r500fp_count(atom->cmd);
        return cnt ? (cnt * 4) + 1 : 0;
 }
@@ -295,8 +467,8 @@ static int check_r500fp_const(r300ContextPtr r300, struct r300_state_atom *atom)
       r300->hw.ATOM.idx = (IDX);                                       \
       r300->hw.ATOM.check = check_##CHK;                               \
       r300->hw.ATOM.dirty = GL_FALSE;                                  \
-      r300->hw.max_state_size += (SZ);                                 \
-      insert_at_tail(&r300->hw.atomlist, &r300->hw.ATOM);              \
+      r300->radeon.hw.max_state_size += (SZ);                                  \
+      insert_at_tail(&r300->radeon.hw.atomlist, &r300->hw.ATOM);               \
    } while (0)
 /**
  * Allocate memory for the command buffer and initialize the state atom
@@ -304,18 +476,16 @@ static int check_r500fp_const(r300ContextPtr r300, struct r300_state_atom *atom)
  */
 void r300InitCmdBuf(r300ContextPtr r300)
 {
-       int size, mtu;
-       int has_tcl = 1;
+       int mtu;
+       int has_tcl;
        int is_r500 = 0;
-       int i;
 
-       if (!(r300->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL))
-               has_tcl = 0;
+       has_tcl = r300->options.hw_tcl_enabled;
 
        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 */
+       r300->radeon.hw.max_state_size = 2 + 2; /* reserve extra space for WAIT_IDLE and tex cache flush */
 
        mtu = r300->radeon.glCtx->Const.MaxTextureUnits;
        if (RADEON_DEBUG & DEBUG_TEXTURE) {
@@ -323,232 +493,248 @@ void r300InitCmdBuf(r300ContextPtr r300)
        }
 
        /* Setup the atom linked list */
-       make_empty_list(&r300->hw.atomlist);
-       r300->hw.atomlist.name = "atom-list";
+       make_empty_list(&r300->radeon.hw.atomlist);
+       r300->radeon.hw.atomlist.name = "atom-list";
 
        /* 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);
+       r300->hw.vpt.cmd[R300_VPT_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, R300_SE_VPORT_XSCALE, 6);
        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] = cmdpacket0(r300->radeon.radeonScreen, 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);
+       r300->hw.vap_cntl.cmd[R300_VAP_CNTL_CMD] = cmdpacket0(r300->radeon.radeonScreen, 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[0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+       r300->hw.vte.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, R300_SE_VTE_CNTL, 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);
+       r300->hw.vap_vf_max_vtx_indx.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+       r300->hw.vap_cntl_status.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, 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_PROG_STREAM_CNTL_0, 1);
+           cmdpacket0(r300->radeon.radeonScreen, 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_PROG_STREAM_CNTL_EXT_0, 1);
+           cmdpacket0(r300->radeon.radeonScreen, 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_VTX_STATE_CNTL, 2);
+       r300->hw.vic.cmd[R300_VIC_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+       r300->hw.vap_psc_sgn_norm_cntl.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, R300_VAP_PSC_SGN_NORM_CNTL, SGN_NORM_ZERO_CLAMP_MINUS_ONE);
 
        if (has_tcl) {
                ALLOC_STATE(vap_clip_cntl, always, 2, 0);
-               r300->hw.vap_clip_cntl.cmd[0] = cmdpacket0(R300_VAP_CLIP_CNTL, 1);
+               r300->hw.vap_clip_cntl.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+               r300->hw.vap_clip.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+               r300->hw.vap_pvs_vtx_timeout_reg.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, VAP_PVS_VTX_TIMEOUT_REG, 1);
        }
 
        ALLOC_STATE(vof, always, R300_VOF_CMDSIZE, 0);
        r300->hw.vof.cmd[R300_VOF_CMD_0] =
-           cmdpacket0(R300_VAP_OUTPUT_VTX_FMT_0, 2);
+           cmdpacket0(r300->radeon.radeonScreen, R300_VAP_OUTPUT_VTX_FMT_0, 2);
 
        if (has_tcl) {
                ALLOC_STATE(pvs, always, R300_PVS_CMDSIZE, 0);
                r300->hw.pvs.cmd[R300_PVS_CMD_0] =
-                   cmdpacket0(R300_VAP_PVS_CODE_CNTL_0, 3);
+                   cmdpacket0(r300->radeon.radeonScreen, R300_VAP_PVS_CODE_CNTL_0, 3);
        }
 
        ALLOC_STATE(gb_enable, always, 2, 0);
-       r300->hw.gb_enable.cmd[0] = cmdpacket0(R300_GB_ENABLE, 1);
+       r300->hw.gb_enable.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, R300_GB_ENABLE, 1);
        ALLOC_STATE(gb_misc, always, R300_GB_MISC_CMDSIZE, 0);
-       r300->hw.gb_misc.cmd[0] = cmdpacket0(R300_GB_MSPOS0, 5);
+       r300->hw.gb_misc.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, R300_GB_MSPOS0, 3);
+       r300->hw.gb_misc.emit = emit_gb_misc;
+       ALLOC_STATE(gb_misc2, always, R300_GB_MISC2_CMDSIZE, 0);
+    r300->hw.gb_misc2.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, 0x401C, 2);
        ALLOC_STATE(txe, always, R300_TXE_CMDSIZE, 0);
-       r300->hw.txe.cmd[R300_TXE_CMD_0] = cmdpacket0(R300_TX_ENABLE, 1);
+       r300->hw.txe.cmd[R300_TXE_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, R300_TX_ENABLE, 1);
        ALLOC_STATE(ga_point_s0, always, 5, 0);
-       r300->hw.ga_point_s0.cmd[0] = cmdpacket0(R300_GA_POINT_S0, 4);
+       r300->hw.ga_point_s0.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+       r300->hw.ga_triangle_stipple.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, R300_GA_TRIANGLE_STIPPLE, 1);
        ALLOC_STATE(ps, always, R300_PS_CMDSIZE, 0);
-       r300->hw.ps.cmd[0] = cmdpacket0(R300_GA_POINT_SIZE, 1);
+       r300->hw.ps.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+       r300->hw.ga_point_minmax.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, R300_GA_POINT_MINMAX, 3);
        ALLOC_STATE(lcntl, always, 2, 0);
-       r300->hw.lcntl.cmd[0] = cmdpacket0(R300_GA_LINE_CNTL, 1);
+       r300->hw.lcntl.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, 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_GA_ENHANCE, 4);
+       r300->hw.ga_line_stipple.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, R300_GA_LINE_STIPPLE_VALUE, 3);
+       ALLOC_STATE(shade, always, 2, 0);
+       r300->hw.shade.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, R300_GA_ENHANCE, 1);
+       r300->hw.shade.emit = emit_shade_misc;
+       ALLOC_STATE(shade2, always, 4, 0);
+       r300->hw.shade2.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, 0x4278, 3);
        ALLOC_STATE(polygon_mode, always, 4, 0);
-       r300->hw.polygon_mode.cmd[0] = cmdpacket0(R300_GA_POLY_MODE, 3);
+       r300->hw.polygon_mode.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, R300_GA_POLY_MODE, 3);
        ALLOC_STATE(fogp, always, 3, 0);
-       r300->hw.fogp.cmd[0] = cmdpacket0(R300_GA_FOG_SCALE, 2);
+       r300->hw.fogp.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, R300_GA_FOG_SCALE, 2);
        ALLOC_STATE(zbias_cntl, always, 2, 0);
-       r300->hw.zbias_cntl.cmd[0] = cmdpacket0(R300_SU_TEX_WRAP, 1);
+       r300->hw.zbias_cntl.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, R300_SU_TEX_WRAP, 1);
        ALLOC_STATE(zbs, always, R300_ZBS_CMDSIZE, 0);
        r300->hw.zbs.cmd[R300_ZBS_CMD_0] =
-           cmdpacket0(R300_SU_POLY_OFFSET_FRONT_SCALE, 4);
+           cmdpacket0(r300->radeon.radeonScreen, R300_SU_POLY_OFFSET_FRONT_SCALE, 4);
        ALLOC_STATE(occlusion_cntl, always, 2, 0);
-       r300->hw.occlusion_cntl.cmd[0] = cmdpacket0(R300_SU_POLY_OFFSET_ENABLE, 1);
+       r300->hw.occlusion_cntl.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, R300_SU_POLY_OFFSET_ENABLE, 1);
        ALLOC_STATE(cul, always, R300_CUL_CMDSIZE, 0);
-       r300->hw.cul.cmd[R300_CUL_CMD_0] = cmdpacket0(R300_SU_CULL_MODE, 1);
+       r300->hw.cul.cmd[R300_CUL_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+       r300->hw.su_depth_scale.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, R300_SU_DEPTH_SCALE, 2);
        ALLOC_STATE(rc, always, R300_RC_CMDSIZE, 0);
-       r300->hw.rc.cmd[R300_RC_CMD_0] = cmdpacket0(R300_RS_COUNT, 2);
+       r300->hw.rc.cmd[R300_RC_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, 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(ri, variable, R500_RI_CMDSIZE, 0);
+               r300->hw.ri.cmd[R300_RI_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, R500_RS_IP_0, 16);
                ALLOC_STATE(rr, variable, R300_RR_CMDSIZE, 0);
-               r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(R500_RS_INST_0, 1);
+               r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, 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(ri, variable, R300_RI_CMDSIZE, 0);
+               r300->hw.ri.cmd[R300_RI_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+               r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, R300_RS_INST_0, 1);
        }
        ALLOC_STATE(sc_hyperz, always, 3, 0);
-       r300->hw.sc_hyperz.cmd[0] = cmdpacket0(R300_SC_HYPERZ, 2);
+       r300->hw.sc_hyperz.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, R300_SC_HYPERZ, 2);
        ALLOC_STATE(sc_screendoor, always, 2, 0);
-       r300->hw.sc_screendoor.cmd[0] = cmdpacket0(R300_SC_SCREENDOOR, 1);
+       r300->hw.sc_screendoor.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+       r300->hw.us_out_fmt.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, 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_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, 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_CMD_1] = cmdpacket0(r300->radeon.radeonScreen, R500_US_CODE_ADDR, 3);
+               r300->hw.fp.cmd[R500_FP_CMD_2] = cmdpacket0(r300->radeon.radeonScreen, 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);
+               r300->hw.r500fp.cmd[R300_FPI_CMD_0] =
+                       cmdr500fp(r300->radeon.radeonScreen, 0, 0, 0, 0);
+               r300->hw.r500fp.emit = emit_r500fp;
                ALLOC_STATE(r500fp_const, r500fp_const, R500_FPP_CMDSIZE, 0);
-               r300->hw.r500fp_const.cmd[R300_FPI_CMD_0] = cmdr500fp(0, 0, 1, 0);
+               r300->hw.r500fp_const.cmd[R300_FPI_CMD_0] =
+                       cmdr500fp(r300->radeon.radeonScreen, 0, 0, 1, 0);
+               r300->hw.r500fp_const.emit = emit_r500fp;
        } 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);
+               r300->hw.fp.cmd[R300_FP_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, R300_US_CONFIG, 3);
+               r300->hw.fp.cmd[R300_FP_CMD_1] = cmdpacket0(r300->radeon.radeonScreen, 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);
+               r300->hw.fpt.cmd[R300_FPT_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+               r300->hw.fpi[0].cmd[R300_FPI_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+               r300->hw.fpi[1].cmd[R300_FPI_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+               r300->hw.fpi[2].cmd[R300_FPI_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+               r300->hw.fpi[3].cmd[R300_FPI_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+               r300->hw.fpp.cmd[R300_FPP_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, R300_PFS_PARAM_0_X, 0);
        }
        ALLOC_STATE(fogs, always, R300_FOGS_CMDSIZE, 0);
-       r300->hw.fogs.cmd[R300_FOGS_CMD_0] = cmdpacket0(R300_FG_FOG_BLEND, 1);
+       r300->hw.fogs.cmd[R300_FOGS_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, R300_FG_FOG_BLEND, 1);
        ALLOC_STATE(fogc, always, R300_FOGC_CMDSIZE, 0);
-       r300->hw.fogc.cmd[R300_FOGC_CMD_0] = cmdpacket0(R300_FG_FOG_COLOR_R, 3);
+       r300->hw.fogc.cmd[R300_FOGC_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, R300_FG_FOG_COLOR_R, 3);
        ALLOC_STATE(at, always, R300_AT_CMDSIZE, 0);
-       r300->hw.at.cmd[R300_AT_CMD_0] = cmdpacket0(R300_FG_ALPHA_FUNC, 2);
+       r300->hw.at.cmd[R300_AT_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+       r300->hw.fg_depth_src.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, R300_FG_DEPTH_SRC, 1);
        ALLOC_STATE(rb3d_cctl, always, 2, 0);
-       r300->hw.rb3d_cctl.cmd[0] = cmdpacket0(R300_RB3D_CCTL, 1);
+       r300->hw.rb3d_cctl.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+       r300->hw.bld.cmd[R300_BLD_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, R300_RB3D_CBLEND, 2);
        ALLOC_STATE(cmk, always, R300_CMK_CMDSIZE, 0);
-       r300->hw.cmk.cmd[R300_CMK_CMD_0] = cmdpacket0(RB3D_COLOR_CHANNEL_MASK, 1);
+       r300->hw.cmk.cmd[R300_CMK_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+               r300->hw.blend_color.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+               r300->hw.blend_color.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, R300_RB3D_BLEND_COLOR, 1);
        }
        ALLOC_STATE(rop, always, 2, 0);
-       r300->hw.rop.cmd[0] = cmdpacket0(R300_RB3D_ROPCNTL, 1);
+       r300->hw.rop.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+       r300->hw.cb.emit = &emit_cb_offset;
        ALLOC_STATE(rb3d_dither_ctl, always, 10, 0);
-       r300->hw.rb3d_dither_ctl.cmd[0] = cmdpacket0(R300_RB3D_DITHER_CTL, 9);
+       r300->hw.rb3d_dither_ctl.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+       r300->hw.rb3d_aaresolve_ctl.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, 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(r300->radeon.radeonScreen, R500_RB3D_DISCARD_SRC_PIXEL_LTE_THRESHOLD, 2);
+       r300->hw.rb3d_discard_src_pixel_lte_threshold.emit = emit_threshold_misc;
        ALLOC_STATE(zs, always, R300_ZS_CMDSIZE, 0);
        r300->hw.zs.cmd[R300_ZS_CMD_0] =
-           cmdpacket0(R300_ZB_CNTL, 3);
+           cmdpacket0(r300->radeon.radeonScreen, R300_ZB_CNTL, 3);
+
        ALLOC_STATE(zstencil_format, always, 5, 0);
        r300->hw.zstencil_format.cmd[0] =
-           cmdpacket0(R300_ZB_FORMAT, 4);
+           cmdpacket0(r300->radeon.radeonScreen, R300_ZB_FORMAT, 4);
+       r300->hw.zstencil_format.emit = emit_zstencil_format;
+
        ALLOC_STATE(zb, always, R300_ZB_CMDSIZE, 0);
-       r300->hw.zb.cmd[R300_ZB_CMD_0] = cmdpacket0(R300_ZB_DEPTHOFFSET, 2);
+       r300->hw.zb.emit = emit_zb_offset;
        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);
+       r300->hw.zb_depthclearvalue.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, R300_ZB_DEPTHCLEARVALUE, 1);
+       ALLOC_STATE(zb_zmask, always, 3, 0);
+       r300->hw.zb_zmask.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, R300_ZB_ZMASK_OFFSET, 2);
        ALLOC_STATE(zb_hiz_offset, always, 2, 0);
-       r300->hw.zb_hiz_offset.cmd[0] = cmdpacket0(R300_ZB_HIZ_OFFSET, 1);
+       r300->hw.zb_hiz_offset.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, 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);
+       r300->hw.zb_hiz_pitch.cmd[0] = cmdpacket0(r300->radeon.radeonScreen, 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_CODE_START, 0);
+               r300->hw.vpi.cmd[0] =
+                   cmdvpu(r300->radeon.radeonScreen, R300_PVS_CODE_START, 0);
+               r300->hw.vpi.emit = emit_vpu;
 
                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);
+                   r300->hw.vpp.cmd[0] =
+                       cmdvpu(r300->radeon.radeonScreen, R500_PVS_CONST_START, 0);
+                   r300->hw.vpp.emit = emit_vpu;
 
                    ALLOC_STATE(vps, vpu, R300_VPS_CMDSIZE, 0);
-                   r300->hw.vps.cmd[R300_VPS_CMD_0] =
-                       cmdvpu(R500_POINT_VPORT_SCALE_OFFSET, 1);
+                   r300->hw.vps.cmd[0] =
+                       cmdvpu(r300->radeon.radeonScreen, R500_POINT_VPORT_SCALE_OFFSET, 1);
+                   r300->hw.vps.emit = emit_vpu;
 
                        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);
+                         ALLOC_STATE(vpucp[i], vpu, R300_VPUCP_CMDSIZE, 0);
+                         r300->hw.vpucp[i].cmd[0] =
+                                 cmdvpu(r300->radeon.radeonScreen,
+                           R500_PVS_UCP_START + i, 1);
+                               r300->hw.vpucp[i].emit = emit_vpu;
                        }
                } else {
                    ALLOC_STATE(vpp, vpu, R300_VPP_CMDSIZE, 0);
-                   r300->hw.vpp.cmd[R300_VPP_CMD_0] =
-                       cmdvpu(R300_PVS_CONST_START, 0);
+                   r300->hw.vpp.cmd[0] =
+                       cmdvpu(r300->radeon.radeonScreen, R300_PVS_CONST_START, 0);
+                   r300->hw.vpp.emit = emit_vpu;
 
                    ALLOC_STATE(vps, vpu, R300_VPS_CMDSIZE, 0);
-                   r300->hw.vps.cmd[R300_VPS_CMD_0] =
-                       cmdvpu(R300_POINT_VPORT_SCALE_OFFSET, 1);
+                   r300->hw.vps.cmd[0] =
+                       cmdvpu(r300->radeon.radeonScreen, R300_POINT_VPORT_SCALE_OFFSET, 1);
+                   r300->hw.vps.emit = emit_vpu;
 
                        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);
+                               r300->hw.vpucp[i].cmd[0] =
+                                       cmdvpu(r300->radeon.radeonScreen,
+                                              R300_PVS_UCP_START + i, 1);
+                               r300->hw.vpucp[i].emit = emit_vpu;
                        }
                }
        }
@@ -556,130 +742,37 @@ void r300InitCmdBuf(r300ContextPtr r300)
        /* Textures */
        ALLOC_STATE(tex.filter, variable, mtu + 1, 0);
        r300->hw.tex.filter.cmd[R300_TEX_CMD_0] =
-           cmdpacket0(R300_TX_FILTER0_0, 0);
+           cmdpacket0(r300->radeon.radeonScreen, R300_TX_FILTER0_0, 0);
 
        ALLOC_STATE(tex.filter_1, variable, mtu + 1, 0);
        r300->hw.tex.filter_1.cmd[R300_TEX_CMD_0] =
-           cmdpacket0(R300_TX_FILTER1_0, 0);
+           cmdpacket0(r300->radeon.radeonScreen, R300_TX_FILTER1_0, 0);
 
        ALLOC_STATE(tex.size, variable, mtu + 1, 0);
-       r300->hw.tex.size.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_SIZE_0, 0);
+       r300->hw.tex.size.cmd[R300_TEX_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, R300_TX_SIZE_0, 0);
 
        ALLOC_STATE(tex.format, variable, mtu + 1, 0);
        r300->hw.tex.format.cmd[R300_TEX_CMD_0] =
-           cmdpacket0(R300_TX_FORMAT_0, 0);
+           cmdpacket0(r300->radeon.radeonScreen, 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_FORMAT2_0, 0);
+       r300->hw.tex.pitch.cmd[R300_TEX_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, R300_TX_FORMAT2_0, 0);
 
-       ALLOC_STATE(tex.offset, variable, mtu + 1, 0);
+       ALLOC_STATE(tex.offset, variable, 1, 0);
        r300->hw.tex.offset.cmd[R300_TEX_CMD_0] =
-           cmdpacket0(R300_TX_OFFSET_0, 0);
+           cmdpacket0(r300->radeon.radeonScreen, R300_TX_OFFSET_0, 0);
+       r300->hw.tex.offset.emit = &emit_tex_offsets;
 
        ALLOC_STATE(tex.chroma_key, variable, mtu + 1, 0);
        r300->hw.tex.chroma_key.cmd[R300_TEX_CMD_0] =
-           cmdpacket0(R300_TX_CHROMA_KEY_0, 0);
+           cmdpacket0(r300->radeon.radeonScreen, R300_TX_CHROMA_KEY_0, 0);
 
        ALLOC_STATE(tex.border_color, variable, mtu + 1, 0);
        r300->hw.tex.border_color.cmd[R300_TEX_CMD_0] =
-           cmdpacket0(R300_TX_BORDER_COLOR_0, 0);
-
-       r300->hw.is_dirty = GL_TRUE;
-       r300->hw.all_dirty = GL_TRUE;
-
-       /* Initialize command buffer */
-       size =
-           256 * driQueryOptioni(&r300->radeon.optionCache,
-                                 "command_buffer_size");
-       if (size < 2 * r300->hw.max_state_size) {
-               size = 2 * r300->hw.max_state_size + 65535;
-       }
-       if (size > 64 * 256)
-               size = 64 * 256;
-
-       if (RADEON_DEBUG & (DEBUG_IOCTL | DEBUG_DMA)) {
-               fprintf(stderr, "sizeof(drm_r300_cmd_header_t)=%zd\n",
-                       sizeof(drm_r300_cmd_header_t));
-               fprintf(stderr, "sizeof(drm_radeon_cmd_buffer_t)=%zd\n",
-                       sizeof(drm_radeon_cmd_buffer_t));
-               fprintf(stderr,
-                       "Allocating %d bytes command buffer (max state is %d bytes)\n",
-                       size * 4, r300->hw.max_state_size * 4);
-       }
-
-       r300->cmdbuf.size = size;
-       r300->cmdbuf.cmd_buf = (uint32_t *) CALLOC(size * 4);
-       r300->cmdbuf.count_used = 0;
-       r300->cmdbuf.count_reemit = 0;
-}
-
-/**
- * Destroy the command buffer and state atoms.
- */
-void r300DestroyCmdBuf(r300ContextPtr r300)
-{
-       struct r300_state_atom *atom;
-
-       FREE(r300->cmdbuf.cmd_buf);
-
-       foreach(atom, &r300->hw.atomlist) {
-               FREE(atom->cmd);
-       }
-}
-
-void r300EmitBlit(r300ContextPtr rmesa,
-                 GLuint color_fmt,
-                 GLuint src_pitch,
-                 GLuint src_offset,
-                 GLuint dst_pitch,
-                 GLuint dst_offset,
-                 GLint srcx, GLint srcy,
-                 GLint dstx, GLint dsty, GLuint w, GLuint h)
-{
-       drm_r300_cmd_header_t *cmd;
-
-       if (RADEON_DEBUG & DEBUG_IOCTL)
-               fprintf(stderr,
-                       "%s src %x/%x %d,%d dst: %x/%x %d,%d sz: %dx%d\n",
-                       __FUNCTION__, src_pitch, src_offset, srcx, srcy,
-                       dst_pitch, dst_offset, dstx, dsty, w, h);
-
-       assert((src_pitch & 63) == 0);
-       assert((dst_pitch & 63) == 0);
-       assert((src_offset & 1023) == 0);
-       assert((dst_offset & 1023) == 0);
-       assert(w < (1 << 16));
-       assert(h < (1 << 16));
-
-       cmd = (drm_r300_cmd_header_t *) r300AllocCmdBuf(rmesa, 8, __FUNCTION__);
-
-       cmd[0].header.cmd_type = R300_CMD_PACKET3;
-       cmd[0].header.pad0 = R300_CMD_PACKET3_RAW;
-       cmd[1].u = R300_CP_CMD_BITBLT_MULTI | (5 << 16);
-       cmd[2].u = (RADEON_GMC_SRC_PITCH_OFFSET_CNTL |
-                   RADEON_GMC_DST_PITCH_OFFSET_CNTL |
-                   RADEON_GMC_BRUSH_NONE |
-                   (color_fmt << 8) |
-                   RADEON_GMC_SRC_DATATYPE_COLOR |
-                   RADEON_ROP3_S |
-                   RADEON_DP_SRC_SOURCE_MEMORY |
-                   RADEON_GMC_CLR_CMP_CNTL_DIS | RADEON_GMC_WR_MSK_DIS);
-
-       cmd[3].u = ((src_pitch / 64) << 22) | (src_offset >> 10);
-       cmd[4].u = ((dst_pitch / 64) << 22) | (dst_offset >> 10);
-       cmd[5].u = (srcx << 16) | srcy;
-       cmd[6].u = (dstx << 16) | dsty; /* dst */
-       cmd[7].u = (w << 16) | h;
-}
-
-void r300EmitWait(r300ContextPtr rmesa, GLuint flags)
-{
-       drm_r300_cmd_header_t *cmd;
+           cmdpacket0(r300->radeon.radeonScreen, R300_TX_BORDER_COLOR_0, 0);
 
-       assert(!(flags & ~(R300_WAIT_2D | R300_WAIT_3D)));
+       r300->radeon.hw.is_dirty = GL_TRUE;
+       r300->radeon.hw.all_dirty = GL_TRUE;
 
-       cmd = (drm_r300_cmd_header_t *) r300AllocCmdBuf(rmesa, 1, __FUNCTION__);
-       cmd[0].u = 0;
-       cmd[0].wait.cmd_type = R300_CMD_WAIT;
-       cmd[0].wait.flags = flags;
+       rcommonInitCmdBuf(&r300->radeon);
 }
index a8eaa580bd92191f9ec07d86461a9f53a28803b8..53bcc0eeb49d6db0373487d32f2a01c6d82ad0c5 100644 (file)
@@ -38,79 +38,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "r300_context.h"
 
-extern int r300FlushCmdBufLocked(r300ContextPtr r300, const char *caller);
-extern int r300FlushCmdBuf(r300ContextPtr r300, const char *caller);
-
-extern void r300EmitState(r300ContextPtr r300);
-
 extern void r300InitCmdBuf(r300ContextPtr r300);
-extern void r300DestroyCmdBuf(r300ContextPtr r300);
-
-/**
- * Make sure that enough space is available in the command buffer
- * by flushing if necessary.
- *
- * \param dwords The number of dwords we need to be free on the command buffer
- */
-static INLINE void r300EnsureCmdBufSpace(r300ContextPtr r300,
-                                            int dwords, const char *caller)
-{
-       assert(dwords < r300->cmdbuf.size);
-
-       if (r300->cmdbuf.count_used + dwords > r300->cmdbuf.size)
-               r300FlushCmdBuf(r300, caller);
-}
-
-/**
- * Allocate the given number of dwords in the command buffer and return
- * a pointer to the allocated area.
- * When necessary, these functions cause a flush. r300AllocCmdBuf() also
- * causes state reemission after a flush. This is necessary to ensure
- * correct hardware state after an unlock.
- */
-static INLINE uint32_t *r300RawAllocCmdBuf(r300ContextPtr r300,
-                                              int dwords, const char *caller)
-{
-       uint32_t *ptr;
-
-       r300EnsureCmdBufSpace(r300, dwords, caller);
-
-       ptr = &r300->cmdbuf.cmd_buf[r300->cmdbuf.count_used];
-       r300->cmdbuf.count_used += dwords;
-       return ptr;
-}
-
-static INLINE uint32_t *r300AllocCmdBuf(r300ContextPtr r300,
-                                           int dwords, const char *caller)
-{
-       uint32_t *ptr;
-
-       r300EnsureCmdBufSpace(r300, dwords, caller);
-
-       if (!r300->cmdbuf.count_used) {
-               if (RADEON_DEBUG & DEBUG_IOCTL)
-                       fprintf(stderr,
-                               "Reemit state after flush (from %s)\n", caller);
-               r300EmitState(r300);
-       }
-
-       ptr = &r300->cmdbuf.cmd_buf[r300->cmdbuf.count_used];
-       r300->cmdbuf.count_used += dwords;
-       return ptr;
-}
+void r300_emit_scissor(GLcontext *ctx);
 
-extern void r300EmitBlit(r300ContextPtr rmesa,
-                        GLuint color_fmt,
-                        GLuint src_pitch,
-                        GLuint src_offset,
-                        GLuint dst_pitch,
-                        GLuint dst_offset,
-                        GLint srcx, GLint srcy,
-                        GLint dstx, GLint dsty, GLuint w, GLuint h);
+void emit_vpu(GLcontext *ctx, struct radeon_state_atom * atom);
+int check_vpu(GLcontext *ctx, struct radeon_state_atom *atom);
 
-extern void r300EmitWait(r300ContextPtr rmesa, GLuint flags);
-extern void r300EmitLOAD_VBPNTR(r300ContextPtr rmesa, int start);
-extern void r300EmitVertexShader(r300ContextPtr rmesa);
-extern void r300EmitPixelShader(r300ContextPtr rmesa);
+void emit_r500fp(GLcontext *ctx, struct radeon_state_atom * atom);
+int check_r500fp(GLcontext *ctx, struct radeon_state_atom *atom);
+int check_r500fp_const(GLcontext *ctx, struct radeon_state_atom *atom);
 
 #endif                         /* __R300_CMDBUF_H__ */
index 8f0effd83e2726ca2383f8f359ee15941f22462e..76881e49282d7b727a53d16063d89c63d3c6b2fb 100644 (file)
@@ -43,8 +43,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/matrix.h"
 #include "main/extensions.h"
 #include "main/state.h"
-#include "main/texobj.h"
 #include "main/bufferobj.h"
+#include "main/texobj.h"
 
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
@@ -56,42 +56,40 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "drivers/common/driverfuncs.h"
 
-#include "radeon_ioctl.h"
-#include "radeon_span.h"
 #include "r300_context.h"
+#include "radeon_context.h"
+#include "radeon_span.h"
 #include "r300_cmdbuf.h"
 #include "r300_state.h"
 #include "r300_ioctl.h"
 #include "r300_tex.h"
 #include "r300_emit.h"
+#include "r300_render.h"
 #include "r300_swtcl.h"
+#include "radeon_bocs_wrapper.h"
 
-#ifdef USER_BUFFERS
-#include "r300_mem.h"
-#endif
 
 #include "vblank.h"
 #include "utils.h"
 #include "xmlpool.h"           /* for symbolic values of enum-type options */
 
-/* hw_tcl_on derives from future_hw_tcl_on when its safe to change it. */
-int future_hw_tcl_on = 1;
-int hw_tcl_on = 1;
-
 #define need_GL_VERSION_2_0
 #define need_GL_ARB_point_parameters
 #define need_GL_ARB_vertex_program
 #define need_GL_EXT_blend_equation_separate
 #define need_GL_EXT_blend_func_separate
 #define need_GL_EXT_blend_minmax
+#define need_GL_EXT_framebuffer_object
 #define need_GL_EXT_fog_coord
 #define need_GL_EXT_gpu_program_parameters
 #define need_GL_EXT_secondary_color
 #define need_GL_EXT_stencil_two_side
 #define need_GL_ATI_separate_stencil
 #define need_GL_NV_vertex_program
+
 #include "extension_helper.h"
 
+
 const struct dri_extension card_extensions[] = {
   /* *INDENT-OFF* */
   {"GL_ARB_depth_texture",             NULL},
@@ -112,6 +110,7 @@ const struct dri_extension card_extensions[] = {
   {"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_packed_depth_stencil",      NULL},
   {"GL_EXT_fog_coord",                 GL_EXT_fog_coord_functions },
   {"GL_EXT_gpu_program_parameters",     GL_EXT_gpu_program_parameters_functions},
   {"GL_EXT_secondary_color",           GL_EXT_secondary_color_functions},
@@ -125,6 +124,8 @@ const struct dri_extension card_extensions[] = {
   {"GL_EXT_texture_lod_bias",          NULL},
   {"GL_EXT_texture_mirror_clamp",      NULL},
   {"GL_EXT_texture_rectangle",         NULL},
+  {"GL_EXT_texture_sRGB",              NULL},
+  {"GL_EXT_vertex_array_bgra",         NULL},
   {"GL_ATI_separate_stencil",          GL_ATI_separate_stencil_functions},
   {"GL_ATI_texture_env_combine3",      NULL},
   {"GL_ATI_texture_mirror_once",       NULL},
@@ -139,6 +140,11 @@ const struct dri_extension card_extensions[] = {
 };
 
 
+const struct dri_extension mm_extensions[] = {
+  { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions },
+  { NULL, NULL }
+};
+
 /**
  * The GL 2.0 functions are needed to make display lists work with
  * functions added by GL_ATI_separate_stencil.
@@ -147,16 +153,8 @@ const struct dri_extension gl_20_extension[] = {
   {"GL_VERSION_2_0",                   GL_VERSION_2_0_functions },
 };
 
-
-extern struct tnl_pipeline_stage _r300_render_stage;
-extern const struct tnl_pipeline_stage _r300_tcl_stage;
-
 static const struct tnl_pipeline_stage *r300_pipeline[] = {
 
-       /* Try and go straight to t&l
-        */
-       &_r300_tcl_stage,
-
        /* Catch any t&l fallbacks
         */
        &_tnl_vertex_transform_stage,
@@ -165,6 +163,7 @@ static const struct tnl_pipeline_stage *r300_pipeline[] = {
        &_tnl_fog_coordinate_stage,
        &_tnl_texgen_stage,
        &_tnl_texture_transform_stage,
+       &_tnl_point_attenuation_stage,
        &_tnl_vertex_program_stage,
 
        /* Try again to go to tcl?
@@ -184,6 +183,186 @@ static const struct tnl_pipeline_stage *r300_pipeline[] = {
        0,
 };
 
+static void r300_get_lock(radeonContextPtr rmesa)
+{
+       drm_radeon_sarea_t *sarea = rmesa->sarea;
+
+       if (sarea->ctx_owner != rmesa->dri.hwContext) {
+               sarea->ctx_owner = rmesa->dri.hwContext;
+               if (!rmesa->radeonScreen->kernel_mm)
+                       radeon_bo_legacy_texture_age(rmesa->radeonScreen->bom);
+       }
+}
+
+static void r300_vtbl_emit_cs_header(struct radeon_cs *cs, radeonContextPtr rmesa)
+{
+    /* please flush pipe do all pending work */
+    radeon_cs_write_dword(cs, cmdpacket0(rmesa->radeonScreen,
+                                  R300_SC_SCREENDOOR, 1));
+    radeon_cs_write_dword(cs, 0x0);
+    radeon_cs_write_dword(cs, cmdpacket0(rmesa->radeonScreen,
+                                  R300_SC_SCREENDOOR, 1));
+    radeon_cs_write_dword(cs, 0x00FFFFFF);
+    radeon_cs_write_dword(cs, cmdpacket0(rmesa->radeonScreen,
+                                  R300_SC_HYPERZ, 1));
+    radeon_cs_write_dword(cs, 0x0);
+    radeon_cs_write_dword(cs, cmdpacket0(rmesa->radeonScreen,
+                                  R300_US_CONFIG, 1));
+    radeon_cs_write_dword(cs, 0x0);
+    radeon_cs_write_dword(cs, cmdpacket0(rmesa->radeonScreen,
+                                  R300_ZB_CNTL, 1));
+    radeon_cs_write_dword(cs, 0x0);
+    radeon_cs_write_dword(cs, cmdwait(rmesa->radeonScreen, R300_WAIT_3D));
+    radeon_cs_write_dword(cs, cmdpacket0(rmesa->radeonScreen,
+                                  R300_RB3D_DSTCACHE_CTLSTAT, 1));
+    radeon_cs_write_dword(cs, R300_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_FLUSH_DIRTY_3D);
+    radeon_cs_write_dword(cs, cmdpacket0(rmesa->radeonScreen,
+                                  R300_ZB_ZCACHE_CTLSTAT, 1));
+    radeon_cs_write_dword(cs, R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE);
+    radeon_cs_write_dword(cs, cmdwait(rmesa->radeonScreen,
+                               R300_WAIT_3D | R300_WAIT_3D_CLEAN));
+}
+
+static void r300_vtbl_pre_emit_atoms(radeonContextPtr radeon)
+{
+       r300ContextPtr r300 = (r300ContextPtr)radeon;
+       BATCH_LOCALS(radeon);
+
+       r300->vap_flush_needed = GL_TRUE;
+
+       cp_wait(radeon, R300_WAIT_3D | R300_WAIT_3D_CLEAN);
+       BEGIN_BATCH_NO_AUTOSTATE(2);
+       OUT_BATCH_REGVAL(R300_TX_INVALTAGS, R300_TX_FLUSH);
+       END_BATCH();
+       end_3d(radeon);
+}
+
+static void r300_fallback(GLcontext *ctx, GLuint bit, GLboolean mode)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       if (mode)
+               r300->radeon.Fallback |= bit;
+       else
+               r300->radeon.Fallback &= ~bit;
+}
+
+static void r300_init_vtbl(radeonContextPtr radeon)
+{
+       radeon->vtbl.get_lock = r300_get_lock;
+       radeon->vtbl.update_viewport_offset = r300UpdateViewportOffset;
+       radeon->vtbl.emit_cs_header = r300_vtbl_emit_cs_header;
+       radeon->vtbl.swtcl_flush = r300_swtcl_flush;
+       radeon->vtbl.pre_emit_atoms = r300_vtbl_pre_emit_atoms;
+       radeon->vtbl.fallback = r300_fallback;
+}
+
+static void r300InitConstValues(GLcontext *ctx, radeonScreenPtr screen)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+
+       ctx->Const.MaxTextureImageUnits =
+           driQueryOptioni(&r300->radeon.optionCache, "texture_image_units");
+       ctx->Const.MaxTextureCoordUnits =
+           driQueryOptioni(&r300->radeon.optionCache, "texture_coord_units");
+       ctx->Const.MaxTextureUnits = MIN2(ctx->Const.MaxTextureImageUnits,
+                ctx->Const.MaxTextureCoordUnits);
+
+       ctx->Const.MaxTextureMaxAnisotropy = 16.0;
+       ctx->Const.MaxTextureLodBias = 16.0;
+
+       if (screen->chip_family >= CHIP_FAMILY_RV515)
+               ctx->Const.MaxTextureLevels = 13;
+       else
+               ctx->Const.MaxTextureLevels = 12;
+
+       ctx->Const.MinPointSize = 1.0;
+       ctx->Const.MinPointSizeAA = 1.0;
+       ctx->Const.MaxPointSize = R300_POINTSIZE_MAX;
+       ctx->Const.MaxPointSizeAA = R300_POINTSIZE_MAX;
+
+       ctx->Const.MinLineWidth = 1.0;
+       ctx->Const.MinLineWidthAA = 1.0;
+       ctx->Const.MaxLineWidth = R300_LINESIZE_MAX;
+       ctx->Const.MaxLineWidthAA = R300_LINESIZE_MAX;
+
+       ctx->Const.MaxDrawBuffers = 1;
+
+       /* currently bogus data */
+       if (r300->options.hw_tcl_enabled) {
+               ctx->Const.VertexProgram.MaxInstructions = VSF_MAX_FRAGMENT_LENGTH / 4;
+               ctx->Const.VertexProgram.MaxNativeInstructions =
+                 VSF_MAX_FRAGMENT_LENGTH / 4;
+               ctx->Const.VertexProgram.MaxNativeAttribs = 16; /* r420 */
+               ctx->Const.VertexProgram.MaxTemps = 32;
+               ctx->Const.VertexProgram.MaxNativeTemps =
+                 /*VSF_MAX_FRAGMENT_TEMPS */ 32;
+               ctx->Const.VertexProgram.MaxNativeParameters = 256;     /* r420 */
+               ctx->Const.VertexProgram.MaxNativeAddressRegs = 1;
+       }
+
+       if (screen->chip_family >= CHIP_FAMILY_RV515) {
+               ctx->Const.FragmentProgram.MaxNativeTemps = R500_PFS_NUM_TEMP_REGS;
+               ctx->Const.FragmentProgram.MaxNativeAttribs = 11;       /* copy i915... */
+               ctx->Const.FragmentProgram.MaxNativeParameters = R500_PFS_NUM_CONST_REGS;
+               ctx->Const.FragmentProgram.MaxNativeAluInstructions = R500_PFS_MAX_INST;
+               ctx->Const.FragmentProgram.MaxNativeTexInstructions = R500_PFS_MAX_INST;
+               ctx->Const.FragmentProgram.MaxNativeInstructions = R500_PFS_MAX_INST;
+               ctx->Const.FragmentProgram.MaxNativeTexIndirections = R500_PFS_MAX_INST;
+               ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0;
+       } else {
+               ctx->Const.FragmentProgram.MaxNativeTemps = R300_PFS_NUM_TEMP_REGS;
+               ctx->Const.FragmentProgram.MaxNativeAttribs = 11;       /* copy i915... */
+               ctx->Const.FragmentProgram.MaxNativeParameters = R300_PFS_NUM_CONST_REGS;
+               ctx->Const.FragmentProgram.MaxNativeAluInstructions = R300_PFS_MAX_ALU_INST;
+               ctx->Const.FragmentProgram.MaxNativeTexInstructions = R300_PFS_MAX_TEX_INST;
+               ctx->Const.FragmentProgram.MaxNativeInstructions = R300_PFS_MAX_ALU_INST + R300_PFS_MAX_TEX_INST;
+               ctx->Const.FragmentProgram.MaxNativeTexIndirections = R300_PFS_MAX_TEX_INDIRECT;
+               ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0;
+       }
+}
+
+static void r300ParseOptions(r300ContextPtr r300, radeonScreenPtr screen)
+{
+       struct r300_options options = { 0 };
+
+       driParseConfigFiles(&r300->radeon.optionCache, &screen->optionCache,
+                           screen->driScreen->myNum, "r300");
+
+       r300->radeon.initialMaxAnisotropy = driQueryOptionf(&r300->radeon.optionCache, "def_max_anisotropy");
+
+       options.stencil_two_side_disabled = driQueryOptionb(&r300->radeon.optionCache, "disable_stencil_two_side");
+       options.s3tc_force_enabled = driQueryOptionb(&r300->radeon.optionCache, "force_s3tc_enable");
+       options.s3tc_force_disabled = driQueryOptionb(&r300->radeon.optionCache, "disable_s3tc");
+
+       if (!(screen->chip_flags & RADEON_CHIPSET_TCL) || driQueryOptioni(&r300->radeon.optionCache, "tcl_mode") == DRI_CONF_TCL_SW)
+               options.hw_tcl_enabled = 0;
+       else
+               options.hw_tcl_enabled = 1;
+
+       options.conformance_mode = !driQueryOptionb(&r300->radeon.optionCache, "disable_lowimpact_fallback");
+
+       r300->options = options;
+}
+
+static void r300InitGLExtensions(GLcontext *ctx)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+
+       driInitExtensions(ctx, card_extensions, GL_TRUE);
+       if (r300->radeon.radeonScreen->kernel_mm)
+               driInitExtensions(ctx, mm_extensions, GL_FALSE);
+
+       if (r300->options.stencil_two_side_disabled)
+               _mesa_disable_extension(ctx, "GL_EXT_stencil_two_side");
+
+       if (ctx->Mesa_DXTn && !r300->options.s3tc_force_enabled) {
+               _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
+               _mesa_enable_extension(ctx, "GL_S3_s3tc");
+       } else if (r300->options.s3tc_force_disabled) {
+               _mesa_disable_extension(ctx, "GL_EXT_texture_compression_s3tc");
+       }
+}
+
 /* Create the device specific rendering context.
  */
 GLboolean r300CreateContext(const __GLcontextModes * glVisual,
@@ -195,42 +374,25 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
        struct dd_function_table functions;
        r300ContextPtr r300;
        GLcontext *ctx;
-       int tcl_mode, i;
 
        assert(glVisual);
        assert(driContextPriv);
        assert(screen);
 
-       /* Allocate the R300 context */
        r300 = (r300ContextPtr) CALLOC(sizeof(*r300));
        if (!r300)
                return GL_FALSE;
 
-       if (!(screen->chip_flags & RADEON_CHIPSET_TCL))
-               hw_tcl_on = future_hw_tcl_on = 0;
+       r300ParseOptions(r300, screen);
 
-       /* Parse configuration files.
-        * Do this here so that initialMaxAnisotropy is set before we create
-        * the default textures.
-        */
-       driParseConfigFiles(&r300->radeon.optionCache, &screen->optionCache,
-                           screen->driScreen->myNum, "r300");
-       r300->initialMaxAnisotropy = driQueryOptionf(&r300->radeon.optionCache,
-                                                    "def_max_anisotropy");
+       r300_init_vtbl(&r300->radeon);
 
-       /* Init default driver functions then plug in our R300-specific functions
-        * (the texture functions are especially important)
-        */
        _mesa_init_driver_functions(&functions);
        r300InitIoctlFuncs(&functions);
        r300InitStateFuncs(&functions);
        r300InitTextureFuncs(&functions);
        r300InitShaderFuncs(&functions);
 
-#ifdef USER_BUFFERS
-       r300_mem_init(r300);
-#endif
-
        if (!radeonInitContext(&r300->radeon, &functions,
                               glVisual, driContextPriv,
                               sharedContextPrivate)) {
@@ -238,94 +400,15 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
                return GL_FALSE;
        }
 
-       /* Init r300 context data */
-       r300->dma.buf0_address =
-           r300->radeon.radeonScreen->buffers->list[0].address;
-
-       (void)memset(r300->texture_heaps, 0, sizeof(r300->texture_heaps));
-       make_empty_list(&r300->swapped);
-
-       r300->nr_heaps = 1 /* screen->numTexHeaps */ ;
-       assert(r300->nr_heaps < RADEON_NR_TEX_HEAPS);
-       for (i = 0; i < r300->nr_heaps; i++) {
-               /* *INDENT-OFF* */
-               r300->texture_heaps[i] = driCreateTextureHeap(i, r300,
-                                                              screen->
-                                                              texSize[i], 12,
-                                                              RADEON_NR_TEX_REGIONS,
-                                                              (drmTextureRegionPtr)
-                                                              r300->radeon.sarea->
-                                                              tex_list[i],
-                                                              &r300->radeon.sarea->
-                                                              tex_age[i],
-                                                              &r300->swapped,
-                                                              sizeof
-                                                              (r300TexObj),
-                                                              (destroy_texture_object_t
-                                                               *)
-                                                              r300DestroyTexObj);
-               /* *INDENT-ON* */
-       }
-       r300->texture_depth = driQueryOptioni(&r300->radeon.optionCache,
-                                             "texture_depth");
-       if (r300->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
-               r300->texture_depth = (screen->cpp == 4) ?
-                   DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
-
-       /* Set the maximum texture size small enough that we can guarentee that
-        * all texture units can bind a maximal texture and have them both in
-        * texturable memory at once.
-        */
-
        ctx = r300->radeon.glCtx;
 
-       ctx->Const.MaxTextureImageUnits =
-           driQueryOptioni(&r300->radeon.optionCache, "texture_image_units");
-       ctx->Const.MaxTextureCoordUnits =
-           driQueryOptioni(&r300->radeon.optionCache, "texture_coord_units");
-       ctx->Const.MaxTextureUnits =
-           MIN2(ctx->Const.MaxTextureImageUnits,
-                ctx->Const.MaxTextureCoordUnits);
-       ctx->Const.MaxTextureMaxAnisotropy = 16.0;
-       ctx->Const.MaxTextureLodBias = 16.0;
-
-       if (screen->chip_family >= CHIP_FAMILY_RV515)
-           ctx->Const.MaxTextureLevels = 13;
-       else
-           ctx->Const.MaxTextureLevels = 12;
-
-        driCalculateMaxTextureLevels( r300->texture_heaps,
-                                      r300->nr_heaps,
-                                      & ctx->Const,
-                                      4,
-                                      ctx->Const.MaxTextureLevels - 1,
-                                      MIN2(ctx->Const.MaxTextureLevels,
-                                           MAX_3D_TEXTURE_LEVELS) - 1,
-                                      ctx->Const.MaxTextureLevels - 1,
-                                      ctx->Const.MaxTextureLevels - 1,
-                                      ctx->Const.MaxTextureLevels - 1,
-                                      GL_FALSE,
-                                      2 );
-
-       ctx->Const.MinPointSize = 1.0;
-       ctx->Const.MinPointSizeAA = 1.0;
-       ctx->Const.MaxPointSize = R300_POINTSIZE_MAX;
-       ctx->Const.MaxPointSizeAA = R300_POINTSIZE_MAX;
+       r300->fallback = 0;
+       if (r300->options.hw_tcl_enabled)
+               ctx->VertexProgram._MaintainTnlProgram = GL_TRUE;
 
-       ctx->Const.MinLineWidth = 1.0;
-       ctx->Const.MinLineWidthAA = 1.0;
-       ctx->Const.MaxLineWidth = R300_LINESIZE_MAX;
-       ctx->Const.MaxLineWidthAA = R300_LINESIZE_MAX;
-
-#ifdef USER_BUFFERS
-       /* Needs further modifications */
-#if 0
-       ctx->Const.MaxArrayLockSize =
-           ( /*512 */ RADEON_BUFFER_SIZE * 16 * 1024) / (4 * 4);
-#endif
-#endif
+       ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
 
-       ctx->Const.MaxDrawBuffers = 1;
+       r300InitConstValues(ctx, screen);
 
        /* Initialize the software rasterizer and helper modules.
         */
@@ -334,16 +417,12 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
        _tnl_CreateContext(ctx);
        _swsetup_CreateContext(ctx);
        _swsetup_Wakeup(ctx);
-       _ae_create_context(ctx);
 
        /* Install the customized pipeline:
         */
        _tnl_destroy_pipeline(ctx);
        _tnl_install_pipeline(ctx, r300_pipeline);
-
-       /* Try and keep materials and vertices separate:
-        */
-/*     _tnl_isolate_materials(ctx, GL_TRUE); */
+       TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline;
 
        /* Configure swrast and TNL to match hardware characteristics:
         */
@@ -352,226 +431,25 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
        _tnl_allow_pixel_fog(ctx, GL_FALSE);
        _tnl_allow_vertex_fog(ctx, GL_TRUE);
 
-       /* currently bogus data */
-       if (screen->chip_flags & RADEON_CHIPSET_TCL) {
-               ctx->Const.VertexProgram.MaxInstructions = VSF_MAX_FRAGMENT_LENGTH / 4;
-               ctx->Const.VertexProgram.MaxNativeInstructions =
-                 VSF_MAX_FRAGMENT_LENGTH / 4;
-               ctx->Const.VertexProgram.MaxNativeAttribs = 16; /* r420 */
-               ctx->Const.VertexProgram.MaxTemps = 32;
-               ctx->Const.VertexProgram.MaxNativeTemps =
-                 /*VSF_MAX_FRAGMENT_TEMPS */ 32;
-               ctx->Const.VertexProgram.MaxNativeParameters = 256;     /* r420 */
-               ctx->Const.VertexProgram.MaxNativeAddressRegs = 1;
-       }
-
-       ctx->Const.FragmentProgram.MaxNativeTemps = PFS_NUM_TEMP_REGS;
-       ctx->Const.FragmentProgram.MaxNativeAttribs = 11;       /* copy i915... */
-       ctx->Const.FragmentProgram.MaxNativeParameters = PFS_NUM_CONST_REGS;
-       ctx->Const.FragmentProgram.MaxNativeAluInstructions = PFS_MAX_ALU_INST;
-       ctx->Const.FragmentProgram.MaxNativeTexInstructions = PFS_MAX_TEX_INST;
-       ctx->Const.FragmentProgram.MaxNativeInstructions =
-           PFS_MAX_ALU_INST + PFS_MAX_TEX_INST;
-       ctx->Const.FragmentProgram.MaxNativeTexIndirections =
-           PFS_MAX_TEX_INDIRECT;
-       ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0;    /* and these are?? */
-       ctx->VertexProgram._MaintainTnlProgram = GL_TRUE;
-       ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
-
-       driInitExtensions(ctx, card_extensions, GL_TRUE);
-
-       if (driQueryOptionb
-           (&r300->radeon.optionCache, "disable_stencil_two_side"))
-               _mesa_disable_extension(ctx, "GL_EXT_stencil_two_side");
-
-       if (r300->radeon.glCtx->Mesa_DXTn
-           && !driQueryOptionb(&r300->radeon.optionCache, "disable_s3tc")) {
-               _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
-               _mesa_enable_extension(ctx, "GL_S3_s3tc");
-       } else
-           if (driQueryOptionb(&r300->radeon.optionCache, "force_s3tc_enable"))
-       {
-               _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
+       if (r300->options.hw_tcl_enabled) {
+               r300InitDraw(ctx);
+       } else {
+               r300InitSwtcl(ctx);
        }
 
-       r300->disable_lowimpact_fallback =
-           driQueryOptionb(&r300->radeon.optionCache,
-                           "disable_lowimpact_fallback");
-
-       radeonInitSpanFuncs(ctx);
+       radeon_fbo_init(&r300->radeon);
+       radeonInitSpanFuncs( ctx );
        r300InitCmdBuf(r300);
        r300InitState(r300);
-       if (!(screen->chip_flags & RADEON_CHIPSET_TCL))
-               r300InitSwtcl(ctx);
+       r300InitShaderFunctions(r300);
 
-       TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline;
-
-       tcl_mode = driQueryOptioni(&r300->radeon.optionCache, "tcl_mode");
-       if (driQueryOptionb(&r300->radeon.optionCache, "no_rast")) {
-               fprintf(stderr, "disabling 3D acceleration\n");
-#if R200_MERGED
-               FALLBACK(&r300->radeon, RADEON_FALLBACK_DISABLE, 1);
-#endif
-       }
-       if (tcl_mode == DRI_CONF_TCL_SW ||
-           !(r300->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL)) {
-               if (r300->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL) {
-                       r300->radeon.radeonScreen->chip_flags &=
-                           ~RADEON_CHIPSET_TCL;
-                       fprintf(stderr, "Disabling HW TCL support\n");
-               }
-               TCL_FALLBACK(r300->radeon.glCtx,
-                            RADEON_TCL_FALLBACK_TCL_DISABLE, 1);
+       if (screen->chip_family == CHIP_FAMILY_RS600 || screen->chip_family == CHIP_FAMILY_RS690 ||
+               screen->chip_family == CHIP_FAMILY_RS740) {
+               r300->radeon.texture_row_align = 64;
        }
 
-       return GL_TRUE;
-}
-
-static void r300FreeGartAllocations(r300ContextPtr r300)
-{
-       int i, ret, tries = 0, done_age, in_use = 0;
-       drm_radeon_mem_free_t memfree;
+       r300InitGLExtensions(ctx);
 
-       memfree.region = RADEON_MEM_REGION_GART;
-
-#ifdef USER_BUFFERS
-       for (i = r300->rmm->u_last; i > 0; i--) {
-               if (r300->rmm->u_list[i].ptr == NULL) {
-                       continue;
-               }
-
-               /* check whether this buffer is still in use */
-               if (r300->rmm->u_list[i].pending) {
-                       in_use++;
-               }
-       }
-       /* Cannot flush/lock if no context exists. */
-       if (in_use)
-               r300FlushCmdBuf(r300, __FUNCTION__);
-
-       done_age = radeonGetAge((radeonContextPtr) r300);
-
-       for (i = r300->rmm->u_last; i > 0; i--) {
-               if (r300->rmm->u_list[i].ptr == NULL) {
-                       continue;
-               }
-
-               /* check whether this buffer is still in use */
-               if (!r300->rmm->u_list[i].pending) {
-                       continue;
-               }
-
-               assert(r300->rmm->u_list[i].h_pending == 0);
-
-               tries = 0;
-               while (r300->rmm->u_list[i].age > done_age && tries++ < 1000) {
-                       usleep(10);
-                       done_age = radeonGetAge((radeonContextPtr) r300);
-               }
-               if (tries >= 1000) {
-                       WARN_ONCE("Failed to idle region!");
-               }
-
-               memfree.region_offset = (char *)r300->rmm->u_list[i].ptr -
-                   (char *)r300->radeon.radeonScreen->gartTextures.map;
-
-               ret = drmCommandWrite(r300->radeon.radeonScreen->driScreen->fd,
-                                     DRM_RADEON_FREE, &memfree,
-                                     sizeof(memfree));
-               if (ret) {
-                       fprintf(stderr, "Failed to free at %p\nret = %s\n",
-                               r300->rmm->u_list[i].ptr, strerror(-ret));
-               } else {
-                       if (i == r300->rmm->u_last)
-                               r300->rmm->u_last--;
-
-                       r300->rmm->u_list[i].pending = 0;
-                       r300->rmm->u_list[i].ptr = NULL;
-               }
-       }
-       r300->rmm->u_head = i;
-#endif                         /* USER_BUFFERS */
+       return GL_TRUE;
 }
 
-/* Destroy the device specific context.
- */
-void r300DestroyContext(__DRIcontextPrivate * driContextPriv)
-{
-       GET_CURRENT_CONTEXT(ctx);
-       r300ContextPtr r300 = (r300ContextPtr) driContextPriv->driverPrivate;
-       radeonContextPtr radeon = (radeonContextPtr) r300;
-       radeonContextPtr current = ctx ? RADEON_CONTEXT(ctx) : NULL;
-       int i;
-
-       if (RADEON_DEBUG & DEBUG_DRI) {
-               fprintf(stderr, "Destroying context !\n");
-       }
-
-       /* check if we're deleting the currently bound context */
-       if (&r300->radeon == current) {
-               radeonFlush(r300->radeon.glCtx);
-               _mesa_make_current(NULL, NULL, NULL);
-       }
-
-       /* Free r300 context resources */
-       assert(r300);           /* should never be null */
-
-       if (r300) {
-               GLboolean release_texture_heaps;
-
-               release_texture_heaps =
-                   (r300->radeon.glCtx->Shared->RefCount == 1);
-               _swsetup_DestroyContext(r300->radeon.glCtx);
-               _tnl_DestroyContext(r300->radeon.glCtx);
-               _vbo_DestroyContext(r300->radeon.glCtx);
-               _swrast_DestroyContext(r300->radeon.glCtx);
-
-               if (r300->dma.current.buf) {
-                       r300ReleaseDmaRegion(r300, &r300->dma.current,
-                                            __FUNCTION__);
-#ifndef USER_BUFFERS
-                       r300FlushCmdBuf(r300, __FUNCTION__);
-#endif
-               }
-               r300FreeGartAllocations(r300);
-               r300DestroyCmdBuf(r300);
-
-               if (radeon->state.scissor.pClipRects) {
-                       FREE(radeon->state.scissor.pClipRects);
-                       radeon->state.scissor.pClipRects = NULL;
-               }
-
-               if (release_texture_heaps) {
-                       /* This share group is about to go away, free our private
-                        * texture object data.
-                        */
-                       int i;
-
-                       for (i = 0; i < r300->nr_heaps; i++) {
-                               driDestroyTextureHeap(r300->texture_heaps[i]);
-                               r300->texture_heaps[i] = NULL;
-                       }
-
-                       assert(is_empty_list(&r300->swapped));
-               }
-
-                /* Drop texture object references from current hardware state */
-               for (i = 0; i < 8; i++) {
-                       _mesa_reference_texobj(&r300->state.texture.unit[i].texobj, NULL);
-               }
-
-               radeonCleanupContext(&r300->radeon);
-
-#ifdef USER_BUFFERS
-               /* the memory manager might be accessed when Mesa frees the shared
-                * state, so don't destroy it earlier
-                */
-               r300_mem_destroy(r300);
-#endif
-
-               /* free the option cache */
-               driDestroyOptionCache(&r300->radeon.optionCache);
-
-               FREE(r300);
-       }
-}
index 96a3205f1a3be5d38aed182ac905aa2813220042..026c33c67cb209203d691e128982f55826409924 100644 (file)
@@ -37,26 +37,20 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #ifndef __R300_CONTEXT_H__
 #define __R300_CONTEXT_H__
 
-#include "tnl/t_vertex.h"
 #include "drm.h"
 #include "radeon_drm.h"
 #include "dri_util.h"
-#include "texmem.h"
+#include "radeon_common.h"
 
-#include "main/macros.h"
 #include "main/mtypes.h"
-#include "main/colormac.h"
-
-#define USER_BUFFERS
+#include "shader/prog_instruction.h"
 
 struct r300_context;
 typedef struct r300_context r300ContextRec;
 typedef struct r300_context *r300ContextPtr;
 
-#include "radeon_lock.h"
-#include "main/mm.h"
 
-/* From http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Variadic-Macros.html .
+/* From http://gcc. gnu.org/onlinedocs/gcc-3.2.3/gcc/Variadic-Macros.html .
    I suppose we could inline this and use macro to fetch out __LINE__ and stuff in case we run into trouble
    with other compilers ... GLUE!
 */
@@ -73,180 +67,14 @@ typedef struct r300_context *r300ContextPtr;
        }
 
 #include "r300_vertprog.h"
-#include "r500_fragprog.h"
-
-/**
- * This function takes a float and packs it into a uint32_t
- */
-static INLINE uint32_t r300PackFloat32(float fl)
-{
-       union {
-               float fl;
-               uint32_t u;
-       } u;
-
-       u.fl = fl;
-       return u.u;
-}
-
-/* This is probably wrong for some values, I need to test this
- * some more.  Range checking would be a good idea also..
- *
- * But it works for most things.  I'll fix it later if someone
- * else with a better clue doesn't
- */
-static INLINE uint32_t r300PackFloat24(float f)
-{
-       float mantissa;
-       int exponent;
-       uint32_t float24 = 0;
-
-       if (f == 0.0)
-               return 0;
-
-       mantissa = frexpf(f, &exponent);
-
-       /* Handle -ve */
-       if (mantissa < 0) {
-               float24 |= (1 << 23);
-               mantissa = mantissa * -1.0;
-       }
-       /* Handle exponent, bias of 63 */
-       exponent += 62;
-       float24 |= (exponent << 16);
-       /* Kill 7 LSB of mantissa */
-       float24 |= (r300PackFloat32(mantissa) & 0x7FFFFF) >> 7;
-
-       return float24;
-}
-
-/************ DMA BUFFERS **************/
-
-/* Need refcounting on dma buffers:
- */
-struct r300_dma_buffer {
-       int refcount;           /**< the number of retained regions in buf */
-       drmBufPtr buf;
-       int id;
-};
-#undef GET_START
-#ifdef USER_BUFFERS
-#define GET_START(rvb) (r300GartOffsetFromVirtual(rmesa, (rvb)->address+(rvb)->start))
-#else
-#define GET_START(rvb) (rmesa->radeon.radeonScreen->gart_buffer_offset +               \
-                       (rvb)->address - rmesa->dma.buf0_address +      \
-                       (rvb)->start)
-#endif
-/* A retained region, eg vertices for indexed vertices.
- */
-struct r300_dma_region {
-       struct r300_dma_buffer *buf;
-       char *address;          /* == buf->address */
-       int start, end, ptr;    /* offsets from start of buf */
-
-       int aos_offset;         /* address in GART memory */
-       int aos_stride;         /* distance between elements, in dwords */
-       int aos_size;           /* number of components (1-4) */
-};
-
-struct r300_dma {
-       /* Active dma region.  Allocations for vertices and retained
-        * regions come from here.  Also used for emitting random vertices,
-        * these may be flushed by calling flush_current();
-        */
-       struct r300_dma_region current;
 
-       void (*flush) (r300ContextPtr);
-
-       char *buf0_address;     /* start of buf[0], for index calcs */
-
-       /* Number of "in-flight" DMA buffers, i.e. the number of buffers
-        * for which a DISCARD command is currently queued in the command buffer.
-        */
-       GLuint nr_released_bufs;
-};
-
-       /* Texture related */
-
-typedef struct r300_tex_obj r300TexObj, *r300TexObjPtr;
-
-/* Maximum number of mipmap levels supported by any supported GPU
- */
-#define R300_MAX_TEXTURE_LEVELS 13
-
-/* Texture object in locally shared texture space.
- */
-struct r300_tex_obj {
-       driTextureObject base;
-
-       GLuint bufAddr;         /* Offset to start of locally
-                                  shared texture block */
-
-       drm_radeon_tex_image_t image[6][R300_MAX_TEXTURE_LEVELS];
-       /* Six, for the cube faces */
-
-       GLboolean image_override;       /* Image overridden by GLX_EXT_tfp */
-
-       GLuint pitch;           /* this isn't sent to hardware just used in calculations */
-       /* hardware register values */
-       /* Note that R200 has 8 registers per texture and R300 only 7 */
-       GLuint filter;
-       GLuint filter_1;
-       GLuint pitch_reg;
-       GLuint size;            /* npot only */
-       GLuint format;
-       GLuint offset;          /* Image location in the card's address space.
-                                  All cube faces follow. */
-       GLuint unknown4;
-       GLuint unknown5;
-       /* end hardware registers */
-
-       /* registers computed by r200 code - keep them here to
-          compare against what is actually written.
-
-          to be removed later.. */
-       GLuint pp_border_color;
-       GLuint pp_cubic_faces;  /* cube face 1,2,3,4 log2 sizes */
-       GLuint format_x;
-
-       GLboolean border_fallback;
-
-       GLuint tile_bits;       /* hw texture tile bits used on this texture */
-};
-
-struct r300_texture_env_state {
-       struct gl_texture_object *texobj;
-       GLenum format;
-       GLenum envMode;
-};
 
 /* The blit width for texture uploads
  */
 #define R300_BLIT_WIDTH_BYTES 1024
 #define R300_MAX_TEXTURE_UNITS 8
 
-struct r300_texture_state {
-       struct r300_texture_env_state unit[R300_MAX_TEXTURE_UNITS];
-       int tc_count;           /* number of incoming texture coordinates from VAP */
-};
 
-/**
- * A block of hardware state.
- *
- * When check returns non-zero, the returned number of dwords must be
- * copied verbatim into the command buffer in order to update a state atom
- * when it is dirty.
- */
-struct r300_state_atom {
-       struct r300_state_atom *next, *prev;
-       const char *name;       /* for debug */
-       int cmd_size;           /* maximum size in dwords */
-       GLuint idx;             /* index in an array (e.g. textures) */
-       uint32_t *cmd;
-       GLboolean dirty;
-
-       int (*check) (r300ContextPtr, struct r300_state_atom * atom);
-};
 
 #define R300_VPT_CMD_0         0
 #define R300_VPT_XSCALE                1
@@ -288,9 +116,11 @@ struct r300_state_atom {
 #define R300_GB_MISC_MSPOS_0           1
 #define R300_GB_MISC_MSPOS_1           2
 #define R300_GB_MISC_TILE_CONFIG       3
-#define R300_GB_MISC_SELECT            4
-#define R300_GB_MISC_AA_CONFIG         5
-#define R300_GB_MISC_CMDSIZE           6
+#define R300_GB_MISC_CMDSIZE           4
+#define R300_GB_MISC2_CMD_0                0
+#define R300_GB_MISC2_SELECT           1
+#define R300_GB_MISC2_AA_CONFIG                2
+#define R300_GB_MISC2_CMDSIZE          3
 
 #define R300_TXE_CMD_0         0
 #define R300_TXE_ENABLE                1
@@ -463,124 +293,100 @@ struct r300_state_atom {
  * Cache for hardware register state.
  */
 struct r300_hw_state {
-       struct r300_state_atom atomlist;
-
-       GLboolean is_dirty;
-       GLboolean all_dirty;
-       int max_state_size;     /* in dwords */
-
-       struct r300_state_atom vpt;     /* viewport (1D98) */
-       struct r300_state_atom 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 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 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 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 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 ga_point_minmax; /* (4230) */
-       struct r300_state_atom lcntl;   /* line control */
-       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 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 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 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 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 fg_depth_src;    /* (4BD8) */
-       struct r300_state_atom fpp;     /* 0x4C00 and following */
-       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 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 zb_depthclearvalue;      /* (4F28) */
-       struct r300_state_atom unk4F30; /* (4F30) */
-       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 */
+       struct radeon_state_atom vpt;   /* viewport (1D98) */
+       struct radeon_state_atom vap_cntl;
+       struct radeon_state_atom vap_index_offset; /* 0x208c r5xx only */
+       struct radeon_state_atom vof;   /* VAP output format register 0x2090 */
+       struct radeon_state_atom vte;   /* (20B0) */
+       struct radeon_state_atom vap_vf_max_vtx_indx;   /* Maximum Vertex Indx Clamp (2134) */
+       struct radeon_state_atom vap_cntl_status;
+       struct radeon_state_atom vir[2];        /* vap input route (2150/21E0) */
+       struct radeon_state_atom vic;   /* vap input control (2180) */
+       struct radeon_state_atom vap_psc_sgn_norm_cntl; /* Programmable Stream Control Signed Normalize Control (21DC) */
+       struct radeon_state_atom vap_clip_cntl;
+       struct radeon_state_atom vap_clip;
+       struct radeon_state_atom vap_pvs_vtx_timeout_reg;       /* Vertex timeout register (2288) */
+       struct radeon_state_atom pvs;   /* pvs_cntl (22D0) */
+       struct radeon_state_atom gb_enable;     /* (4008) */
+       struct radeon_state_atom gb_misc;       /* Multisampling position shifts ? (4010) */
+       struct radeon_state_atom gb_misc2;      /* Multisampling position shifts ? (4010) */
+       struct radeon_state_atom ga_point_s0;   /* S Texture Coordinate of Vertex 0 for Point texture stuffing (LLC) (4200) */
+       struct radeon_state_atom ga_triangle_stipple;   /* (4214) */
+       struct radeon_state_atom ps;    /* pointsize (421C) */
+       struct radeon_state_atom ga_point_minmax;       /* (4230) */
+       struct radeon_state_atom lcntl; /* line control */
+       struct radeon_state_atom ga_line_stipple;       /* (4260) */
+       struct radeon_state_atom shade;
+       struct radeon_state_atom shade2;
+       struct radeon_state_atom polygon_mode;
+       struct radeon_state_atom fogp;  /* fog parameters (4294) */
+       struct radeon_state_atom ga_soft_reset; /* (429C) */
+       struct radeon_state_atom zbias_cntl;
+       struct radeon_state_atom zbs;   /* zbias (42A4) */
+       struct radeon_state_atom occlusion_cntl;
+       struct radeon_state_atom cul;   /* cull cntl (42B8) */
+       struct radeon_state_atom su_depth_scale;        /* (42C0) */
+       struct radeon_state_atom rc;    /* rs control (4300) */
+       struct radeon_state_atom ri;    /* rs interpolators (4310) */
+       struct radeon_state_atom rr;    /* rs route (4330) */
+       struct radeon_state_atom sc_hyperz;     /* (43A4) */
+       struct radeon_state_atom sc_screendoor; /* (43E8) */
+       struct radeon_state_atom fp;    /* fragment program cntl + nodes (4600) */
+       struct radeon_state_atom fpt;   /* texi - (4620) */
+       struct radeon_state_atom us_out_fmt;    /* (46A4) */
+       struct radeon_state_atom r500fp;        /* r500 fp instructions */
+       struct radeon_state_atom r500fp_const;  /* r500 fp constants */
+       struct radeon_state_atom fpi[4];        /* fp instructions (46C0/47C0/48C0/49C0) */
+       struct radeon_state_atom fogs;  /* fog state (4BC0) */
+       struct radeon_state_atom fogc;  /* fog color (4BC8) */
+       struct radeon_state_atom at;    /* alpha test (4BD4) */
+       struct radeon_state_atom fg_depth_src;  /* (4BD8) */
+       struct radeon_state_atom fpp;   /* 0x4C00 and following */
+       struct radeon_state_atom rb3d_cctl;     /* (4E00) */
+       struct radeon_state_atom bld;   /* blending (4E04) */
+       struct radeon_state_atom cmk;   /* colormask (4E0C) */
+       struct radeon_state_atom blend_color;   /* constant blend color */
+       struct radeon_state_atom rop;   /* ropcntl */
+       struct radeon_state_atom cb;    /* colorbuffer (4E28) */
+       struct radeon_state_atom rb3d_dither_ctl;       /* (4E50) */
+       struct radeon_state_atom rb3d_aaresolve_ctl;    /* (4E88) */
+       struct radeon_state_atom rb3d_discard_src_pixel_lte_threshold;  /* (4E88) I saw it only written on RV350 hardware..  */
+       struct radeon_state_atom zs;    /* zstencil control (4F00) */
+       struct radeon_state_atom zstencil_format;
+       struct radeon_state_atom zb;    /* z buffer (4F20) */
+       struct radeon_state_atom zb_depthclearvalue;    /* (4F28) */
+       struct radeon_state_atom zb_zmask;      /* (4F30) */
+       struct radeon_state_atom zb_hiz_offset; /* (4F44) */
+       struct radeon_state_atom zb_hiz_pitch;  /* (4F54) */
+
+       struct radeon_state_atom vpi;   /* vp instructions */
+       struct radeon_state_atom vpp;   /* vp parameters */
+       struct radeon_state_atom vps;   /* vertex point size (?) */
+       struct radeon_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
           really awkward - we are much better off
           updating the whole thing at once */
        struct {
-               struct r300_state_atom filter;
-               struct r300_state_atom filter_1;
-               struct r300_state_atom size;
-               struct r300_state_atom format;
-               struct r300_state_atom pitch;
-               struct r300_state_atom offset;
-               struct r300_state_atom chroma_key;
-               struct r300_state_atom border_color;
+               struct radeon_state_atom filter;
+               struct radeon_state_atom filter_1;
+               struct radeon_state_atom size;
+               struct radeon_state_atom format;
+               struct radeon_state_atom pitch;
+               struct radeon_state_atom offset;
+               struct radeon_state_atom chroma_key;
+               struct radeon_state_atom border_color;
        } tex;
-       struct r300_state_atom txe;     /* tex enable (4104) */
-};
+       struct radeon_state_atom txe;   /* tex enable (4104) */
 
-/**
- * This structure holds the command buffer while it is being constructed.
- *
- * The first batch of commands in the buffer is always the state that needs
- * to be re-emitted when the context is lost. This batch can be skipped
- * otherwise.
- */
-struct r300_cmdbuf {
-       int size;               /* DWORDs allocated for buffer */
-       uint32_t *cmd_buf;
-       int count_used;         /* DWORDs filled so far */
-       int count_reemit;       /* size of re-emission batch */
+       radeonTexObj *textures[R300_MAX_TEXTURE_UNITS];
 };
 
 /**
  * State cache
  */
 
-struct r300_depthbuffer_state {
-       GLfloat scale;
-};
-
-struct r300_stencilbuffer_state {
-       GLboolean hw_stencil;
-};
-
 /* Vertex shader state */
 
 /* Perhaps more if we store programs in vmem? */
@@ -593,73 +399,55 @@ struct r300_stencilbuffer_state {
 #define STATE_R300_WINDOW_DIMENSION (STATE_INTERNAL_DRIVER+0)
 #define STATE_R300_TEXRECT_FACTOR (STATE_INTERNAL_DRIVER+1)
 
-struct r300_vertex_shader_fragment {
-       int length;
-       union {
-               GLuint d[VSF_MAX_FRAGMENT_LENGTH];
-               float f[VSF_MAX_FRAGMENT_LENGTH];
-               GLuint i[VSF_MAX_FRAGMENT_LENGTH];
-       } body;
-};
-
-struct r300_vertex_shader_state {
-       struct r300_vertex_shader_fragment program;
-};
-
-extern int hw_tcl_on;
-
 #define COLOR_IS_RGBA
 #define TAG(x) r300##x
 #include "tnl_dd/t_dd_vertex.h"
 #undef TAG
 
-//#define CURRENT_VERTEX_SHADER(ctx) (ctx->VertexProgram._Current)
-#define CURRENT_VERTEX_SHADER(ctx) (R300_CONTEXT(ctx)->selected_vp)
-
-/* Should but doesnt work */
-//#define CURRENT_VERTEX_SHADER(ctx) (R300_CONTEXT(ctx)->curr_vp)
-
-/* r300_vertex_shader_state and r300_vertex_program should probably be merged together someday.
- * Keeping them them seperate for now should ensure fixed pipeline keeps functioning properly.
- */
-
-struct r300_vertex_program_key {
-       GLuint InputsRead;
-       GLuint OutputsWritten;
-       GLuint OutputsAdded;
-};
-
 struct r300_vertex_program {
        struct r300_vertex_program *next;
-       struct r300_vertex_program_key key;
-       int translated;
 
-       struct r300_vertex_shader_fragment program;
+       struct r300_vertex_program_key {
+               GLuint InputsRead;
+               GLuint OutputsWritten;
+               GLuint OutputsAdded;
+       } key;
+       
+       struct r300_vertex_shader_hw_code {
+               int length;
+               union {
+                       GLuint d[VSF_MAX_FRAGMENT_LENGTH];
+                       float f[VSF_MAX_FRAGMENT_LENGTH];
+               } body;
+       } hw_code;
+
+       GLboolean translated;
+       GLboolean error;
 
        int pos_end;
        int num_temporaries;    /* Number of temp vars used by program */
        int wpos_idx;
        int inputs[VERT_ATTRIB_MAX];
        int outputs[VERT_RESULT_MAX];
-       int native;
-       int ref_count;
-       int use_ref_count;
 };
 
 struct r300_vertex_program_cont {
        struct gl_vertex_program mesa_program;  /* Must be first */
-       struct r300_vertex_shader_fragment params;
        struct r300_vertex_program *progs;
 };
 
-#define PFS_MAX_ALU_INST       64
-#define PFS_MAX_TEX_INST       64
-#define PFS_MAX_TEX_INDIRECT 4
-#define PFS_NUM_TEMP_REGS      32
-#define PFS_NUM_CONST_REGS     16
+#define R300_PFS_MAX_ALU_INST  64
+#define R300_PFS_MAX_TEX_INST  32
+#define R300_PFS_MAX_TEX_INDIRECT 4
+#define R300_PFS_NUM_TEMP_REGS 32
+#define R300_PFS_NUM_CONST_REGS        32
 
-struct r300_pfs_compile_state;
+#define R500_PFS_MAX_INST 512
+#define R500_PFS_NUM_TEMP_REGS 128
+#define R500_PFS_NUM_CONST_REGS 256
 
+struct r300_pfs_compile_state;
+struct r500_pfs_compile_state;
 
 /**
  * Stores state that influences the compilation of a fragment program.
@@ -702,7 +490,7 @@ struct r300_fragment_program_node {
 struct r300_fragment_program_code {
        struct {
                int length; /**< total # of texture instructions used */
-               GLuint inst[PFS_MAX_TEX_INST];
+               GLuint inst[R300_PFS_MAX_TEX_INST];
        } tex;
 
        struct {
@@ -712,7 +500,7 @@ struct r300_fragment_program_code {
                        GLuint inst1;
                        GLuint inst2;
                        GLuint inst3;
-               } inst[PFS_MAX_ALU_INST];
+               } inst[R300_PFS_MAX_ALU_INST];
        } alu;
 
        struct r300_fragment_program_node node[4];
@@ -723,53 +511,12 @@ struct r300_fragment_program_code {
         * Remember which program register a given hardware constant
         * belongs to.
         */
-       struct prog_src_register constant[PFS_NUM_CONST_REGS];
+       struct prog_src_register constant[R300_PFS_NUM_CONST_REGS];
        int const_nr;
 
        int max_temp_idx;
 };
 
-/**
- * Store everything about a fragment program that is needed
- * to render with that program.
- */
-struct r300_fragment_program {
-       struct gl_fragment_program mesa_program;
-
-       GLboolean translated;
-       GLboolean error;
-
-       struct r300_fragment_program_external_state state;
-       struct r300_fragment_program_code code;
-
-       GLboolean WritesDepth;
-       GLuint optimization;
-};
-
-struct r500_pfs_compile_state;
-
-struct r500_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];
-};
 
 struct r500_fragment_program_code {
        struct {
@@ -779,7 +526,7 @@ struct r500_fragment_program_code {
                GLuint inst3;
                GLuint inst4;
                GLuint inst5;
-       } inst[512];
+       } inst[R500_PFS_MAX_INST];
 
        int inst_offset;
        int inst_end;
@@ -788,94 +535,46 @@ struct r500_fragment_program_code {
         * Remember which program register a given hardware constant
         * belongs to.
         */
-       struct prog_src_register constant[PFS_NUM_CONST_REGS];
+       struct prog_src_register constant[R500_PFS_NUM_CONST_REGS];
        int const_nr;
 
        int max_temp_idx;
 };
 
-struct r500_fragment_program {
-       struct gl_fragment_program mesa_program;
+/**
+* Store everything about a fragment program that is needed
+* to render with that program.
+*/
+struct r300_fragment_program {
+       struct gl_fragment_program Base;
 
-       GLcontext *ctx;
        GLboolean translated;
        GLboolean error;
 
-       struct r500_fragment_program_external_state state;
-       struct r500_fragment_program_code code;
+       struct r300_fragment_program_external_state state;
+       union rX00_fragment_program_code {
+               struct r300_fragment_program_code r300;
+               struct r500_fragment_program_code r500;
+       } code;
 
        GLboolean writes_depth;
-
        GLuint optimization;
 };
 
-#define R300_MAX_AOS_ARRAYS            16
-
-#define REG_COORDS     0
-#define REG_COLOR0     1
-#define REG_TEX0       2
-
-struct r300_state {
-       struct r300_depthbuffer_state depth;
-       struct r300_texture_state texture;
-       int sw_tcl_inputs[VERT_ATTRIB_MAX];
-       struct r300_vertex_shader_state vertex_shader;
-       struct r300_dma_region aos[R300_MAX_AOS_ARRAYS];
-       int aos_count;
-
-       GLuint *Elts;
-       struct r300_dma_region elt_dma;
-
-       struct r300_dma_region swtcl_dma;
-       DECLARE_RENDERINPUTS(render_inputs_bitset);     /* actual render inputs that R300 was configured for.
-                                                          They are the same as tnl->render_inputs for fixed pipeline */
-
-       struct r300_stencilbuffer_state stencil;
-
+struct r300_fragment_program_compiler {
+       r300ContextPtr r300;
+       struct r300_fragment_program *fp;
+       union rX00_fragment_program_code *code;
+       struct gl_program *program;
 };
 
-#define R300_FALLBACK_NONE 0
-#define R300_FALLBACK_TCL 1
-#define R300_FALLBACK_RAST 2
+#define R300_MAX_AOS_ARRAYS            16
+
 
 /* r300_swtcl.c
  */
 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.
-    */
-   GLuint vertex_size;
-
-   /**
-    * Attributes instructing the Mesa TCL pipeline where / how to put vertex
-    * data in the hardware buffer.
-    */
-   struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
-
-   /**
-    * Number of elements of \c ::vertex_attrs that are actually used.
-    */
-   GLuint vertex_attr_count;
-
-   /**
-    * Cached pointer to the buffer where Mesa will store vertex data.
-    */
-   GLubyte *verts;
-
-   /* Fallback rasterization functions
-    */
-  //   r200_point_func draw_point;
-  //   r200_line_func draw_line;
-  //   r200_tri_func draw_tri;
-
-   GLuint hw_primitive;
-   GLenum render_primitive;
-   GLuint numverts;
-
-   /**
+  /*
     * Offset of the 4UB color data within a hardware (swtcl) vertex.
     */
    GLuint coloroffset;
@@ -884,15 +583,44 @@ struct r300_swtcl_info {
     * Offset of the 3UB specular color data within a hardware (swtcl) vertex.
     */
    GLuint specoffset;
+};
 
-   /**
-    * Should Mesa project vertex data or will the hardware do it?
-    */
-   GLboolean needproj;
+struct r300_vtable {
+       void (* SetupRSUnit)(GLcontext *ctx);
+       void (* SetupFragmentShaderTextures)(GLcontext *ctx, int *tmu_mappings);
+       GLboolean (* BuildFragmentProgramHwCode)(struct r300_fragment_program_compiler *compiler);
+       void (* FragmentProgramDump)(union rX00_fragment_program_code *code);
+       void (* SetupPixelShader)(GLcontext *ctx);
+};
 
-   struct r300_dma_region indexed_verts;
+struct r300_vertex_buffer {
+       struct vertex_attribute {
+               /* generic */
+               GLubyte element;
+               GLvoid *data;
+               GLboolean free_needed;
+               GLuint stride;
+               GLuint dwords;
+               GLubyte size; /* number of components */
+
+               /* hw specific */
+               uint32_t data_type:4;
+               uint32_t dst_loc:5;
+               uint32_t _signed:1;
+               uint32_t normalize:1;
+               uint32_t swizzle:12;
+               uint32_t write_mask:4;
+       } attribs[VERT_ATTRIB_MAX];
+
+       GLubyte num_attribs;
 };
 
+struct r300_index_buffer {
+       GLvoid *ptr;
+       GLboolean is_32bit;
+       GLboolean free_needed;
+       GLuint count;
+};
 
 /**
  * \brief R300 context structure.
@@ -900,46 +628,33 @@ struct r300_swtcl_info {
 struct r300_context {
        struct radeon_context radeon;   /* parent class, must be first */
 
+       struct r300_vtable vtbl;
+
        struct r300_hw_state hw;
-       struct r300_cmdbuf cmdbuf;
-       struct r300_state state;
-       struct gl_vertex_program *curr_vp;
+
        struct r300_vertex_program *selected_vp;
 
        /* Vertex buffers
         */
-       struct r300_dma dma;
-       GLboolean save_on_next_unlock;
-       GLuint NewGLState;
-
-       /* Texture object bookkeeping
-        */
-       unsigned nr_heaps;
-       driTexHeap *texture_heaps[RADEON_NR_TEX_HEAPS];
-       driTextureObject swapped;
-       int texture_depth;
-       float initialMaxAnisotropy;
-
-       /* Clientdata textures;
-        */
-       GLuint prefer_gart_client_texturing;
-
-#ifdef USER_BUFFERS
-       struct r300_memory_manager *rmm;
-#endif
-
        GLvector4f dummy_attrib[_TNL_ATTRIB_MAX];
        GLvector4f *temp_attrib[_TNL_ATTRIB_MAX];
 
-       GLboolean disable_lowimpact_fallback;
-
-       DECLARE_RENDERINPUTS(tnl_index_bitset); /* index of bits for last tnl_install_attrs */
+       struct r300_options {
+               uint32_t conformance_mode:1;
+               uint32_t hw_tcl_enabled:1;
+               uint32_t s3tc_force_enabled:1;
+               uint32_t s3tc_force_disabled:1;
+               uint32_t stencil_two_side_disabled:1;
+       } options;
+       
        struct r300_swtcl_info swtcl;
-};
+       struct r300_vertex_buffer vbuf;
+       struct r300_index_buffer ind_buf;
+       GLboolean vap_flush_needed;
+
+       uint32_t fallback;
 
-struct r300_buffer_object {
-       struct gl_buffer_object mesa_obj;
-       int id;
+       DECLARE_RENDERINPUTS(render_inputs_bitset);
 };
 
 #define R300_CONTEXT(ctx)              ((r300ContextPtr)(ctx->DriverCtx))
@@ -955,9 +670,11 @@ extern int r300VertexProgUpdateParams(GLcontext * ctx,
                                      struct r300_vertex_program_cont *vp,
                                      float *dst);
 
-#define RADEON_D_CAPTURE 0
-#define RADEON_D_PLAYBACK 1
-#define RADEON_D_PLAYBACK_RAW 2
-#define RADEON_D_T 3
+extern void r300InitShaderFunctions(r300ContextPtr r300);
+
+extern void r300InitDraw(GLcontext *ctx);
+
+#define r300PackFloat32 radeonPackFloat32
+#define r300PackFloat24 radeonPackFloat24
 
 #endif                         /* __R300_CONTEXT_H__ */
diff --git a/src/mesa/drivers/dri/r300/r300_draw.c b/src/mesa/drivers/dri/r300/r300_draw.c
new file mode 100644 (file)
index 0000000..cc5650f
--- /dev/null
@@ -0,0 +1,475 @@
+/**************************************************************************
+ *
+ * Copyright 2009 Maciej Cencora
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHOR(S) AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <stdlib.h>
+
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/state.h"
+#include "main/api_validate.h"
+#include "main/enums.h"
+
+#include "r300_reg.h"
+#include "r300_context.h"
+#include "r300_emit.h"
+#include "r300_render.h"
+#include "r300_state.h"
+#include "r300_tex.h"
+
+#include "tnl/tnl.h"
+#include "tnl/t_vp_build.h"
+#include "vbo/vbo_context.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+
+static void r300FixupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer *mesa_ind_buf, struct gl_buffer_object **bo, GLuint *nr_bo)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       struct r300_index_buffer *ind_buf = &r300->ind_buf;
+       GLvoid *src_ptr;
+
+       if (!mesa_ind_buf) {
+               ind_buf->ptr = NULL;
+               return;
+       }
+
+       ind_buf->count = mesa_ind_buf->count;
+       if (mesa_ind_buf->obj->Name && !mesa_ind_buf->obj->Pointer) {
+               bo[*nr_bo] = mesa_ind_buf->obj;
+               (*nr_bo)++;
+               ctx->Driver.MapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER, GL_READ_ONLY_ARB, mesa_ind_buf->obj);
+               assert(mesa_ind_buf->obj->Pointer != NULL);
+       }
+       src_ptr = ADD_POINTERS(mesa_ind_buf->obj->Pointer, mesa_ind_buf->ptr);
+
+       if (mesa_ind_buf->type == GL_UNSIGNED_BYTE) {
+               GLubyte *in = (GLubyte *)src_ptr;
+               GLuint *out = _mesa_malloc(sizeof(GLushort) * ((mesa_ind_buf->count + 1) & ~1));
+               int i;
+
+               ind_buf->ptr = out;
+
+               for (i = 0; i + 1 < mesa_ind_buf->count; i += 2) {
+                       *out++ = in[i] | in[i + 1] << 16;
+               }
+
+               if (i < mesa_ind_buf->count) {
+                       *out++ = in[i];
+               }
+
+               ind_buf->free_needed = GL_TRUE;
+               ind_buf->is_32bit = GL_FALSE;
+       } else if (mesa_ind_buf->type == GL_UNSIGNED_SHORT) {
+#if MESA_BIG_ENDIAN
+               GLushort *in = (GLushort *)src_ptr;
+               GLuint *out = _mesa_malloc(sizeof(GLushort) *
+                                          ((mesa_ind_buf->count + 1) & ~1));
+               int i;
+
+               ind_buf->ptr = out;
+
+               for (i = 0; i + 1 < mesa_ind_buf->count; i += 2) {
+                       *out++ = in[i] | in[i + 1] << 16;
+               }
+
+               if (i < mesa_ind_buf->count) {
+                       *out++ = in[i];
+               }
+
+               ind_buf->free_needed = GL_TRUE;
+#else
+               ind_buf->ptr = src_ptr;
+               ind_buf->free_needed = GL_FALSE;
+#endif
+               ind_buf->is_32bit = GL_FALSE;
+       } else {
+               ind_buf->ptr = src_ptr;
+               ind_buf->free_needed = GL_FALSE;
+               ind_buf->is_32bit = GL_TRUE;
+       }
+}
+
+static int getTypeSize(GLenum type)
+{
+       switch (type) {
+               case GL_DOUBLE:
+                       return sizeof(GLdouble);
+               case GL_FLOAT:
+                       return sizeof(GLfloat);
+               case GL_INT:
+                       return sizeof(GLint);
+               case GL_UNSIGNED_INT:
+                       return sizeof(GLuint);
+               case GL_SHORT:
+                       return sizeof(GLshort);
+               case GL_UNSIGNED_SHORT:
+                       return sizeof(GLushort);
+               case GL_BYTE:
+                       return sizeof(GLbyte);
+               case GL_UNSIGNED_BYTE:
+                       return sizeof(GLubyte);
+               default:
+                       assert(0);
+                       return 0;
+       }
+}
+
+#define CONVERT( TYPE, MACRO ) do {            \
+       GLuint i, j, sz;                                \
+       sz = input->Size;                               \
+       if (input->Normalized) {                        \
+               for (i = 0; i < count; i++) {           \
+                       const TYPE *in = (TYPE *)src_ptr;               \
+                       for (j = 0; j < sz; j++) {              \
+                               *dst_ptr++ = MACRO(*in);                \
+                               in++;                           \
+                       }                                       \
+                       src_ptr += stride;                      \
+               }                                               \
+       } else {                                        \
+               for (i = 0; i < count; i++) {           \
+                       const TYPE *in = (TYPE *)src_ptr;               \
+                       for (j = 0; j < sz; j++) {              \
+                               *dst_ptr++ = (GLfloat)(*in);            \
+                               in++;                           \
+                       }                                       \
+                       src_ptr += stride;                      \
+               }                                               \
+       }                                               \
+} while (0)
+
+static void r300TranslateAttrib(GLcontext *ctx, GLuint attr, int count, const struct gl_client_array *input, struct gl_buffer_object **bo, GLuint *nr_bo)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       struct r300_vertex_buffer *vbuf = &r300->vbuf;
+       struct vertex_attribute r300_attr;
+       const void *src_ptr;
+       GLenum type;
+       GLuint stride;
+
+       if (input->BufferObj->Name) {
+               if (!input->BufferObj->Pointer) {
+                       bo[*nr_bo] = input->BufferObj;
+                       (*nr_bo)++;
+                       ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER, GL_READ_ONLY_ARB, input->BufferObj);
+                       assert(input->BufferObj->Pointer != NULL);
+               }
+
+               src_ptr = ADD_POINTERS(input->BufferObj->Pointer, input->Ptr);
+       } else
+               src_ptr = input->Ptr;
+
+       stride = (input->StrideB == 0) ? getTypeSize(input->Type) * input->Size : input->StrideB;
+
+       if (input->Type == GL_DOUBLE || input->Type == GL_UNSIGNED_INT || input->Type == GL_INT ||
+#if MESA_BIG_ENDIAN
+           getTypeSize(input->Type) != 4 ||
+#endif
+           stride < 4) {
+               if (RADEON_DEBUG & DEBUG_FALLBACKS) {
+                       fprintf(stderr, "%s: Converting vertex attributes, attribute data format %x,", __FUNCTION__, input->Type);
+                       fprintf(stderr, "stride %d, components %d\n", stride, input->Size);
+               }
+
+               GLfloat *dst_ptr, *tmp;
+               tmp = dst_ptr = _mesa_malloc(sizeof(GLfloat) * input->Size * count);
+
+               switch (input->Type) {
+                       case GL_DOUBLE:
+                               CONVERT(GLdouble, (GLfloat));
+                               break;
+                       case GL_UNSIGNED_INT:
+                               CONVERT(GLuint, UINT_TO_FLOAT);
+                               break;
+                       case GL_INT:
+                               CONVERT(GLint, INT_TO_FLOAT);
+                               break;
+                       case GL_UNSIGNED_SHORT:
+                               CONVERT(GLushort, USHORT_TO_FLOAT);
+                               break;
+                       case GL_SHORT:
+                               CONVERT(GLshort, SHORT_TO_FLOAT);
+                               break;
+                       case GL_UNSIGNED_BYTE:
+                               assert(input->Format != GL_BGRA);
+                               CONVERT(GLubyte, UBYTE_TO_FLOAT);
+                               break;
+                       case GL_BYTE:
+                               CONVERT(GLbyte, BYTE_TO_FLOAT);
+                               break;
+                       default:
+                               assert(0);
+                               break;
+               }
+
+               type = GL_FLOAT;
+               r300_attr.free_needed = GL_TRUE;
+               r300_attr.data = tmp;
+               r300_attr.stride = sizeof(GLfloat) * input->Size;
+               r300_attr.dwords = input->Size;
+       } else {
+               type = input->Type;
+               r300_attr.free_needed = GL_FALSE;
+               r300_attr.data = (GLvoid *)src_ptr;
+               r300_attr.stride = stride;
+               r300_attr.dwords = (getTypeSize(type) * input->Size  + 3)/ 4;
+       }
+
+       r300_attr.size = input->Size;
+       r300_attr.element = attr;
+       r300_attr.dst_loc = vbuf->num_attribs;
+
+       switch (type) {
+               case GL_FLOAT:
+                       switch (input->Size) {
+                               case 1: r300_attr.data_type = R300_DATA_TYPE_FLOAT_1; break;
+                               case 2: r300_attr.data_type = R300_DATA_TYPE_FLOAT_2; break;
+                               case 3: r300_attr.data_type = R300_DATA_TYPE_FLOAT_3; break;
+                               case 4: r300_attr.data_type = R300_DATA_TYPE_FLOAT_4; break;
+                       }
+                       r300_attr._signed = 0;
+                       r300_attr.normalize = 0;
+                       break;
+               case GL_SHORT:
+                       r300_attr._signed = 1;
+                       r300_attr.normalize = input->Normalized;
+                       switch (input->Size) {
+                               case 1:
+                               case 2:
+                                       r300_attr.data_type = R300_DATA_TYPE_SHORT_2;
+                                       break;
+                               case 3:
+                               case 4:
+                                       r300_attr.data_type = R300_DATA_TYPE_SHORT_4;
+                                       break;
+                       }
+                       break;
+               case GL_BYTE:
+                       r300_attr._signed = 1;
+                       r300_attr.normalize = input->Normalized;
+                       r300_attr.data_type = R300_DATA_TYPE_BYTE;
+                       break;
+               case GL_UNSIGNED_SHORT:
+                       r300_attr._signed = 0;
+                       r300_attr.normalize = input->Normalized;
+                       switch (input->Size) {
+                               case 1:
+                               case 2:
+                                       r300_attr.data_type = R300_DATA_TYPE_SHORT_2;
+                                       break;
+                               case 3:
+                               case 4:
+                                       r300_attr.data_type = R300_DATA_TYPE_SHORT_4;
+                                       break;
+                       }
+                       break;
+               case GL_UNSIGNED_BYTE:
+                       r300_attr._signed = 0;
+                       r300_attr.normalize = input->Normalized;
+                       if (input->Format == GL_BGRA)
+                               r300_attr.data_type = R300_DATA_TYPE_D3DCOLOR;
+                       else
+                               r300_attr.data_type = R300_DATA_TYPE_BYTE;
+                       break;
+
+               default:
+               case GL_DOUBLE:
+               case GL_INT:
+               case GL_UNSIGNED_INT:
+                       assert(0);
+                       break;
+       }
+
+       switch (input->Size) {
+               case 4:
+                       r300_attr.swizzle = SWIZZLE_XYZW;
+                       break;
+               case 3:
+                       r300_attr.swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ONE);
+                       break;
+               case 2:
+                       r300_attr.swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_ZERO, SWIZZLE_ONE);
+                       break;
+               case 1:
+                       r300_attr.swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE);
+                       break;
+       }
+
+       r300_attr.write_mask = MASK_XYZW;
+
+       vbuf->attribs[vbuf->num_attribs] = r300_attr;
+       ++vbuf->num_attribs;
+}
+
+static void r300SetVertexFormat(GLcontext *ctx, const struct gl_client_array *arrays[], int count, struct gl_buffer_object **bo, GLuint *nr_bo)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       struct r300_vertex_buffer *vbuf = &r300->vbuf;
+
+       {
+               int i, tmp;
+
+               tmp = r300->selected_vp->key.InputsRead;
+               i = 0;
+               vbuf->num_attribs = 0;
+               while (tmp) {
+                       /* find first enabled bit */
+                       while (!(tmp & 1)) {
+                               tmp >>= 1;
+                               ++i;
+                       }
+
+                       r300TranslateAttrib(ctx, i, count, arrays[i], bo, nr_bo);
+
+                       tmp >>= 1;
+                       ++i;
+               }
+       }
+
+       r300SwitchFallback(ctx, R300_FALLBACK_AOS_LIMIT, vbuf->num_attribs > R300_MAX_AOS_ARRAYS);
+       if (r300->fallback)
+               return;
+
+       {
+               int i;
+
+               for (i = 0; i < vbuf->num_attribs; i++) {
+                       rcommon_emit_vector(ctx, &r300->radeon.tcl.aos[i],
+                                               vbuf->attribs[i].data, vbuf->attribs[i].dwords,
+                                               vbuf->attribs[i].stride, count);
+               }
+
+               r300->radeon.tcl.aos_count = vbuf->num_attribs;
+       }
+}
+
+static void r300FreeData(GLcontext *ctx, struct gl_buffer_object **bo, GLuint nr_bo)
+{
+       {
+               struct r300_vertex_buffer *vbuf = &R300_CONTEXT(ctx)->vbuf;
+               int i;
+
+               for (i = 0; i < vbuf->num_attribs; i++) {
+                       if (vbuf->attribs[i].free_needed)
+                               _mesa_free(vbuf->attribs[i].data);
+               }
+       }
+
+       {
+               struct r300_index_buffer *ind_buf = &R300_CONTEXT(ctx)->ind_buf;
+               if (ind_buf->free_needed)
+                       _mesa_free(ind_buf->ptr);
+       }
+
+       {
+               int i;
+
+               for (i = 0; i < nr_bo; ++i) {
+                       ctx->Driver.UnmapBuffer(ctx, 0, bo[i]);
+               }
+       }
+}
+
+static GLboolean r300TryDrawPrims(GLcontext *ctx,
+                                        const struct gl_client_array *arrays[],
+                                        const struct _mesa_prim *prim,
+                                        GLuint nr_prims,
+                                        const struct _mesa_index_buffer *ib,
+                                        GLuint min_index,
+                                        GLuint max_index )
+{
+       struct r300_context *r300 = R300_CONTEXT(ctx);
+       struct gl_buffer_object *bo[VERT_ATTRIB_MAX+1];
+       GLuint i, nr_bo = 0;
+
+       if (ctx->NewState)
+               _mesa_update_state( ctx );
+
+       if (r300->options.hw_tcl_enabled)
+               _tnl_UpdateFixedFunctionProgram(ctx);
+
+       r300UpdateShaders(r300);
+
+       r300SwitchFallback(ctx, R300_FALLBACK_INVALID_BUFFERS, !r300ValidateBuffers(ctx));
+
+       r300FixupIndexBuffer(ctx, ib, bo, &nr_bo);
+
+       r300SetVertexFormat(ctx, arrays, max_index + 1, bo, &nr_bo);
+
+       if (r300->fallback)
+               return GL_FALSE;
+
+       r300SetupVAP(ctx, r300->selected_vp->key.InputsRead, r300->selected_vp->key.OutputsWritten);
+
+       r300UpdateShaderStates(r300);
+
+       r300EmitCacheFlush(r300);
+       radeonEmitState(&r300->radeon);
+
+       for (i = 0; i < nr_prims; ++i) {
+               r300RunRenderPrimitive(ctx, prim[i].start, prim[i].start + prim[i].count, prim[i].mode);
+       }
+
+       r300EmitCacheFlush(r300);
+
+       radeonReleaseArrays(ctx, ~0);
+
+       r300FreeData(ctx, bo, nr_bo);
+
+       return GL_TRUE;
+}
+
+/* TODO: rebase if number of indices in any of primitives is > 8192 for 32bit indices or 16384 for 16bit indices */
+
+static void r300DrawPrims(GLcontext *ctx,
+                        const struct gl_client_array *arrays[],
+                        const struct _mesa_prim *prim,
+                        GLuint nr_prims,
+                        const struct _mesa_index_buffer *ib,
+                        GLuint min_index,
+                        GLuint max_index)
+{
+       GLboolean retval;
+
+       if (min_index) {
+               vbo_rebase_prims( ctx, arrays, prim, nr_prims, ib, min_index, max_index, r300DrawPrims );
+               return;
+       }
+
+       /* Make an attempt at drawing */
+       retval = r300TryDrawPrims(ctx, arrays, prim, nr_prims, ib, min_index, max_index);
+
+       /* If failed run tnl pipeline - it should take care of fallbacks */
+       if (!retval)
+               _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index);
+}
+
+void r300InitDraw(GLcontext *ctx)
+{
+       struct vbo_context *vbo = vbo_context(ctx);
+
+       vbo->draw_prims = r300DrawPrims;
+}
index 28c3157427c01b44612c04f80f6a8f16bb50c6f7..c3817721dc47566d25d09d375e3ae2e76978b109 100644 (file)
@@ -31,6 +31,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  * \file
  *
  * \author Keith Whitwell <keith@tungstengraphics.com>
+ * \author Maciej Cencora <m.cencora@gmail.com>
  */
 
 #include "main/glheader.h"
@@ -46,222 +47,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "tnl/t_context.h"
 
 #include "r300_context.h"
-#include "radeon_ioctl.h"
 #include "r300_state.h"
 #include "r300_emit.h"
 #include "r300_ioctl.h"
-
-#ifdef USER_BUFFERS
-#include "r300_mem.h"
-#endif
-
-#if SWIZZLE_X != R300_INPUT_ROUTE_SELECT_X || \
-    SWIZZLE_Y != R300_INPUT_ROUTE_SELECT_Y || \
-    SWIZZLE_Z != R300_INPUT_ROUTE_SELECT_Z || \
-    SWIZZLE_W != R300_INPUT_ROUTE_SELECT_W || \
-    SWIZZLE_ZERO != R300_INPUT_ROUTE_SELECT_ZERO || \
-    SWIZZLE_ONE != R300_INPUT_ROUTE_SELECT_ONE
-#error Cannot change these!
-#endif
-
-#define DEBUG_ALL DEBUG_VERTS
-
-#if defined(USE_X86_ASM)
-#define COPY_DWORDS( dst, src, nr )                                    \
-do {                                                                   \
-       int __tmp;                                                      \
-       __asm__ __volatile__( "rep ; movsl"                             \
-                             : "=%c" (__tmp), "=D" (dst), "=S" (__tmp) \
-                             : "0" (nr),                               \
-                               "D" ((long)dst),                        \
-                               "S" ((long)src) );                      \
-} while (0)
-#else
-#define COPY_DWORDS( dst, src, nr )            \
-do {                                           \
-   int j;                                      \
-   for ( j = 0 ; j < nr ; j++ )                        \
-      dst[j] = ((int *)src)[j];                        \
-   dst += nr;                                  \
-} while (0)
-#endif
-
-static void r300EmitVec4(GLcontext * ctx, struct r300_dma_region *rvb,
-                        GLvoid * data, int stride, int count)
-{
-       int i;
-       int *out = (int *)(rvb->address + rvb->start);
-
-       if (RADEON_DEBUG & DEBUG_VERTS)
-               fprintf(stderr, "%s count %d stride %d out %p data %p\n",
-                       __FUNCTION__, count, stride, (void *)out, (void *)data);
-
-       if (stride == 4)
-               COPY_DWORDS(out, data, count);
-       else
-               for (i = 0; i < count; i++) {
-                       out[0] = *(int *)data;
-                       out++;
-                       data += stride;
-               }
-}
-
-static void r300EmitVec8(GLcontext * ctx, struct r300_dma_region *rvb,
-                        GLvoid * data, int stride, int count)
-{
-       int i;
-       int *out = (int *)(rvb->address + rvb->start);
-
-       if (RADEON_DEBUG & DEBUG_VERTS)
-               fprintf(stderr, "%s count %d stride %d out %p data %p\n",
-                       __FUNCTION__, count, stride, (void *)out, (void *)data);
-
-       if (stride == 8)
-               COPY_DWORDS(out, data, count * 2);
-       else
-               for (i = 0; i < count; i++) {
-                       out[0] = *(int *)data;
-                       out[1] = *(int *)(data + 4);
-                       out += 2;
-                       data += stride;
-               }
-}
-
-static void r300EmitVec12(GLcontext * ctx, struct r300_dma_region *rvb,
-                         GLvoid * data, int stride, int count)
-{
-       int i;
-       int *out = (int *)(rvb->address + rvb->start);
-
-       if (RADEON_DEBUG & DEBUG_VERTS)
-               fprintf(stderr, "%s count %d stride %d out %p data %p\n",
-                       __FUNCTION__, count, stride, (void *)out, (void *)data);
-
-       if (stride == 12)
-               COPY_DWORDS(out, data, count * 3);
-       else
-               for (i = 0; i < count; i++) {
-                       out[0] = *(int *)data;
-                       out[1] = *(int *)(data + 4);
-                       out[2] = *(int *)(data + 8);
-                       out += 3;
-                       data += stride;
-               }
-}
-
-static void r300EmitVec16(GLcontext * ctx, struct r300_dma_region *rvb,
-                         GLvoid * data, int stride, int count)
-{
-       int i;
-       int *out = (int *)(rvb->address + rvb->start);
-
-       if (RADEON_DEBUG & DEBUG_VERTS)
-               fprintf(stderr, "%s count %d stride %d out %p data %p\n",
-                       __FUNCTION__, count, stride, (void *)out, (void *)data);
-
-       if (stride == 16)
-               COPY_DWORDS(out, data, count * 4);
-       else
-               for (i = 0; i < count; i++) {
-                       out[0] = *(int *)data;
-                       out[1] = *(int *)(data + 4);
-                       out[2] = *(int *)(data + 8);
-                       out[3] = *(int *)(data + 12);
-                       out += 4;
-                       data += stride;
-               }
-}
-
-static void r300EmitVec(GLcontext * ctx, struct r300_dma_region *rvb,
-                       GLvoid * data, int size, int stride, int count)
-{
-       r300ContextPtr rmesa = R300_CONTEXT(ctx);
-
-       if (stride == 0) {
-               r300AllocDmaRegion(rmesa, rvb, size * 4, 4);
-               count = 1;
-               rvb->aos_offset = GET_START(rvb);
-               rvb->aos_stride = 0;
-       } else {
-               r300AllocDmaRegion(rmesa, rvb, size * count * 4, 4);
-               rvb->aos_offset = GET_START(rvb);
-               rvb->aos_stride = size;
-       }
-
-       switch (size) {
-       case 1:
-               r300EmitVec4(ctx, rvb, data, stride, count);
-               break;
-       case 2:
-               r300EmitVec8(ctx, rvb, data, stride, count);
-               break;
-       case 3:
-               r300EmitVec12(ctx, rvb, data, stride, count);
-               break;
-       case 4:
-               r300EmitVec16(ctx, rvb, data, stride, count);
-               break;
-       default:
-               assert(0);
-               break;
-       }
-}
-
-#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 < 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;
-       }
-
-       return (nr + 1) >> 1;
-}
-
-static GLuint r300VAPInputRoute1Swizzle(int swizzle[4])
-{
-       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, dw;
-
-       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;
-}
+#include "r300_render.h"
+#include "r300_swtcl.h"
 
 GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead)
 {
@@ -272,7 +62,6 @@ GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead)
 
 GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead)
 {
-       r300ContextPtr rmesa = R300_CONTEXT(ctx);
        GLuint i, vic_1 = 0;
 
        if (InputsRead & (1 << VERT_ATTRIB_POS))
@@ -284,281 +73,112 @@ GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead)
        if (InputsRead & (1 << VERT_ATTRIB_COLOR0))
                vic_1 |= R300_INPUT_CNTL_COLOR;
 
-       rmesa->state.texture.tc_count = 0;
        for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
                if (InputsRead & (1 << (VERT_ATTRIB_TEX0 + i))) {
-                       rmesa->state.texture.tc_count++;
                        vic_1 |= R300_INPUT_CNTL_TC0 << i;
                }
 
        return vic_1;
 }
 
-GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten)
+GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint vp_writes, GLuint fp_reads)
 {
        GLuint ret = 0;
 
-       if (OutputsWritten & (1 << VERT_RESULT_HPOS))
+       if (vp_writes & (1 << VERT_RESULT_HPOS))
                ret |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
 
-       if (OutputsWritten & (1 << VERT_RESULT_COL0))
+       if (vp_writes & (1 << VERT_RESULT_COL0) && fp_reads & FRAG_BIT_COL0)
                ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT;
 
-       if (OutputsWritten & (1 << VERT_RESULT_COL1))
+       if (vp_writes & (1 << VERT_RESULT_COL1) && fp_reads & FRAG_BIT_COL1)
                ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT;
 
-       if (OutputsWritten & (1 << VERT_RESULT_BFC0)
-           || OutputsWritten & (1 << VERT_RESULT_BFC1))
-               ret |=
-                   R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT |
-                   R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT |
-                   R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT;
+       /* Two sided lighting works only if all 4 colors are written */
+       if (vp_writes & (1 << VERT_RESULT_BFC0) || vp_writes & (1 << VERT_RESULT_BFC1))
+               ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT | R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT |
+                          R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT | R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT;
 
-       if (OutputsWritten & (1 << VERT_RESULT_PSIZ))
+       if (vp_writes & (1 << VERT_RESULT_PSIZ))
                ret |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT;
 
        return ret;
 }
 
-GLuint r300VAPOutputCntl1(GLcontext * ctx, GLuint OutputsWritten)
+GLuint r300VAPOutputCntl1(GLcontext * ctx, GLuint vp_writes, GLuint fp_reads)
 {
        GLuint i, ret = 0, first_free_texcoord = 0;
 
        for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
-               if (OutputsWritten & (1 << (VERT_RESULT_TEX0 + i))) {
-                       ret |= (4 << (3 * i));
+               if (vp_writes & (1 << (VERT_RESULT_TEX0 + i)) && fp_reads & FRAG_BIT_TEX(i)) {
+                       ret |= (4 << (3 * first_free_texcoord));
                        ++first_free_texcoord;
                }
        }
 
-       if (OutputsWritten & (1 << VERT_RESULT_FOGC)) {
-               if (first_free_texcoord > 8) {
-                       fprintf(stderr, "\tout of free texcoords to write fog coord\n");
-                       _mesa_exit(-1);
-               }
-               ret |= 4 << (3 * first_free_texcoord);
-       }
-
-       return ret;
-}
-
-/* Emit vertex data to GART memory
- * Route inputs to the vertex processor
- * This function should never return R300_FALLBACK_TCL when using software tcl.
- */
-int r300EmitArrays(GLcontext * ctx)
-{
-       r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       TNLcontext *tnl = TNL_CONTEXT(ctx);
-       struct vertex_buffer *vb = &tnl->vb;
-       GLuint nr;
-       GLuint count = vb->Count;
-       GLuint i;
-       GLuint InputsRead = 0, OutputsWritten = 0;
-       int *inputs = NULL;
-       int vir_inputs[VERT_ATTRIB_MAX];
-       GLint tab[VERT_ATTRIB_MAX];
-       int swizzle[VERT_ATTRIB_MAX][4];
-       struct r300_vertex_program *prog =
-           (struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx);
-
-       if (hw_tcl_on) {
-               inputs = prog->inputs;
-               InputsRead = prog->key.InputsRead;
-               OutputsWritten = prog->key.OutputsWritten;
-       } else {
-               inputs = rmesa->state.sw_tcl_inputs;
-
-               DECLARE_RENDERINPUTS(render_inputs_bitset);
-               RENDERINPUTS_COPY(render_inputs_bitset, tnl->render_inputs_bitset);
-
-               vb->AttribPtr[VERT_ATTRIB_POS] = vb->ClipPtr;
-
-               assert(RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_POS));
-               assert(RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_NORMAL) == 0);
-               //assert(RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_COLOR0));
-
-               if (RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_POS)) {
-                       InputsRead |= 1 << VERT_ATTRIB_POS;
-                       OutputsWritten |= 1 << VERT_RESULT_HPOS;
-               }
-
-               if (RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_COLOR0)) {
-                       InputsRead |= 1 << VERT_ATTRIB_COLOR0;
-                       OutputsWritten |= 1 << VERT_RESULT_COL0;
-               }
-
-               if (RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_COLOR1)) {
-                       InputsRead |= 1 << VERT_ATTRIB_COLOR1;
-                       OutputsWritten |= 1 << VERT_RESULT_COL1;
-               }
-
-               for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
-                       if (RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_TEX(i))) {
-                               InputsRead |= 1 << (VERT_ATTRIB_TEX0 + i);
-                               OutputsWritten |= 1 << (VERT_RESULT_TEX0 + i);
-                       }
-               }
-
-               for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++) {
-                       if (InputsRead & (1 << i)) {
-                               inputs[i] = nr++;
-                       } else {
-                               inputs[i] = -1;
-                       }
-               }
-
-               /* Fixed, apply to vir0 only */
-               memcpy(vir_inputs, inputs, VERT_ATTRIB_MAX * sizeof(int));
-               inputs = vir_inputs;
-               if (InputsRead & VERT_ATTRIB_POS)
-                       inputs[VERT_ATTRIB_POS] = 0;
-               if (InputsRead & (1 << VERT_ATTRIB_COLOR0))
-                       inputs[VERT_ATTRIB_COLOR0] = 2;
-               if (InputsRead & (1 << VERT_ATTRIB_COLOR1))
-                       inputs[VERT_ATTRIB_COLOR1] = 3;
-               for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++)
-                       if (InputsRead & (1 << i))
-                               inputs[i] = 6 + (i - VERT_ATTRIB_TEX0);
-
-               RENDERINPUTS_COPY(rmesa->state.render_inputs_bitset, render_inputs_bitset);
+       if (fp_reads & FRAG_BIT_WPOS) {
+               ret |= (4 << (3 * first_free_texcoord));
+               ++first_free_texcoord;
        }
 
-       assert(InputsRead);
-       assert(OutputsWritten);
-
-       for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++) {
-               if (InputsRead & (1 << i)) {
-                       tab[nr++] = i;
-               }
+       if (vp_writes & (1 << VERT_RESULT_FOGC) && fp_reads & FRAG_BIT_FOGC) {
+               ret |= 4 << (3 * first_free_texcoord);
        }
 
-       if (nr > R300_MAX_AOS_ARRAYS) {
-               return R300_FALLBACK_TCL;
+       if (first_free_texcoord > 8) {
+               fprintf(stderr, "\tout of free texcoords\n");
+               _mesa_exit(-1);
        }
 
-       for (i = 0; i < nr; i++) {
-               int ci, fix, found = 0;
-
-               swizzle[i][0] = SWIZZLE_ZERO;
-               swizzle[i][1] = SWIZZLE_ZERO;
-               swizzle[i][2] = SWIZZLE_ZERO;
-               swizzle[i][3] = SWIZZLE_ONE;
+       return ret;
+}
 
-               for (ci = 0; ci < vb->AttribPtr[tab[i]]->size; ci++) {
-                       swizzle[i][ci] = ci;
-               }
+GLboolean r300EmitArrays(GLcontext * ctx)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       struct r300_vertex_buffer *vbuf = &r300->vbuf;
+       GLuint InputsRead, OutputsWritten;
 
-               if (r300IsGartMemory(rmesa, vb->AttribPtr[tab[i]]->data, 4)) {
-                       if (vb->AttribPtr[tab[i]]->stride % 4) {
-                               return R300_FALLBACK_TCL;
-                       }
-                       rmesa->state.aos[i].address = (void *)(vb->AttribPtr[tab[i]]->data);
-                       rmesa->state.aos[i].start = 0;
-                       rmesa->state.aos[i].aos_offset = r300GartOffsetFromVirtual(rmesa, vb->AttribPtr[tab[i]]->data);
-                       rmesa->state.aos[i].aos_stride = vb->AttribPtr[tab[i]]->stride / 4;
-                       rmesa->state.aos[i].aos_size = vb->AttribPtr[tab[i]]->size;
-               } else {
-                       r300EmitVec(ctx, &rmesa->state.aos[i],
-                                   vb->AttribPtr[tab[i]]->data,
-                                   vb->AttribPtr[tab[i]]->size,
-                                   vb->AttribPtr[tab[i]]->stride, count);
-               }
+       r300ChooseSwtclVertexFormat(ctx, &InputsRead, &OutputsWritten);
 
-               rmesa->state.aos[i].aos_size = vb->AttribPtr[tab[i]]->size;
+       r300SwitchFallback(ctx, R300_FALLBACK_AOS_LIMIT, vbuf->num_attribs > R300_MAX_AOS_ARRAYS);
+       if (r300->fallback & R300_RASTER_FALLBACK_MASK)
+               return GL_FALSE;
 
-               for (fix = 0; fix <= 4 - vb->AttribPtr[tab[i]]->size; fix++) {
-                       if ((rmesa->state.aos[i].aos_offset - _mesa_sizeof_type(GL_FLOAT) * fix) % 4) {
-                               continue;
-                       }
-                       found = 1;
-                       break;
-               }
+       {
+               struct vertex_buffer *mesa_vb = &TNL_CONTEXT(ctx)->vb;
+               GLuint attr, i;
 
-               if (found) {
-                       if (fix > 0) {
-                               WARN_ONCE("Feeling lucky?\n");
-                       }
-                       rmesa->state.aos[i].aos_offset -= _mesa_sizeof_type(GL_FLOAT) * fix;
-                       for (ci = 0; ci < vb->AttribPtr[tab[i]]->size; ci++) {
-                               swizzle[i][ci] += fix;
-                       }
-               } else {
-                       WARN_ONCE
-                           ("Cannot handle offset %x with stride %d, comp %d\n",
-                            rmesa->state.aos[i].aos_offset,
-                            rmesa->state.aos[i].aos_stride,
-                            vb->AttribPtr[tab[i]]->size);
-                       return R300_FALLBACK_TCL;
+               for (i = 0; i < vbuf->num_attribs; i++) {
+                       attr = vbuf->attribs[i].element;
+                       rcommon_emit_vector(ctx, &r300->radeon.tcl.aos[i], mesa_vb->AttribPtr[attr]->data,
+                                       mesa_vb->AttribPtr[attr]->size, mesa_vb->AttribPtr[attr]->stride, mesa_vb->Count);
                }
-       }
 
-       /* Setup INPUT_ROUTE. */
-       R300_STATECHANGE(rmesa, vir[0]);
-       ((drm_r300_cmd_header_t *) rmesa->hw.vir[0].cmd)->packet0.count =
-           r300VAPInputRoute0(&rmesa->hw.vir[0].cmd[R300_VIR_CNTL_0],
-                              vb->AttribPtr, inputs, tab, nr);
-       R300_STATECHANGE(rmesa, vir[1]);
-       ((drm_r300_cmd_header_t *) rmesa->hw.vir[1].cmd)->packet0.count =
-           r300VAPInputRoute1(&rmesa->hw.vir[1].cmd[R300_VIR_CNTL_0], swizzle,
-                              nr);
-
-       /* Setup INPUT_CNTL. */
-       R300_STATECHANGE(rmesa, vic);
-       rmesa->hw.vic.cmd[R300_VIC_CNTL_0] = r300VAPInputCntl0(ctx, InputsRead);
-       rmesa->hw.vic.cmd[R300_VIC_CNTL_1] = r300VAPInputCntl1(ctx, InputsRead);
-
-       /* Setup OUTPUT_VTX_FMT. */
-       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->state.aos_count = nr;
-
-       return R300_FALLBACK_NONE;
-}
+               r300->radeon.tcl.aos_count = vbuf->num_attribs;
 
-#ifdef USER_BUFFERS
-void r300UseArrays(GLcontext * ctx)
-{
-       r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       int i;
-
-       if (rmesa->state.elt_dma.buf)
-               r300_mem_use(rmesa, rmesa->state.elt_dma.buf->id);
-
-       for (i = 0; i < rmesa->state.aos_count; i++) {
-               if (rmesa->state.aos[i].buf)
-                       r300_mem_use(rmesa, rmesa->state.aos[i].buf->id);
+               /* Fill index buffer info */
+               r300->ind_buf.ptr = mesa_vb->Elts;
+               r300->ind_buf.is_32bit = GL_TRUE;
+               r300->ind_buf.free_needed = GL_FALSE;
        }
-}
-#endif
 
-void r300ReleaseArrays(GLcontext * ctx)
-{
-       r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       int i;
+       r300SetupVAP(ctx, InputsRead, OutputsWritten);
 
-       r300ReleaseDmaRegion(rmesa, &rmesa->state.elt_dma, __FUNCTION__);
-       for (i = 0; i < rmesa->state.aos_count; i++) {
-               r300ReleaseDmaRegion(rmesa, &rmesa->state.aos[i], __FUNCTION__);
-       }
+       return GL_TRUE;
 }
 
 void r300EmitCacheFlush(r300ContextPtr rmesa)
 {
-       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_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);
+       BATCH_LOCALS(&rmesa->radeon);
+
+       BEGIN_BATCH_NO_AUTOSTATE(4);
+       OUT_BATCH_REGVAL(R300_RB3D_DSTCACHE_CTLSTAT,
+               R300_RB3D_DSTCACHE_CTLSTAT_DC_FREE_FREE_3D_TAGS |
+               R300_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_FLUSH_DIRTY_3D);
+       OUT_BATCH_REGVAL(R300_ZB_ZCACHE_CTLSTAT,
+               R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE |
+               R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE);
+       END_BATCH();
+       COMMIT_BATCH();
 }
index 89d738339f8cab3d01904f94f0bfb88d2161359b..2fb8b82d3a1f41befeea688d15c3517a7710b4c7 100644 (file)
 #include "r300_cmdbuf.h"
 #include "radeon_reg.h"
 
-/* TODO: move these defines (and the ones from DRM) into r300_reg.h and sync up
- * with DRM */
-#define CP_PACKET0(reg, n)     (RADEON_CP_PACKET0 | ((n)<<16) | ((reg)>>2))
-#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(struct radeon_screen *rscrn,
+                                  int reg, int count)
 {
-       drm_r300_cmd_header_t cmd;
-
-       cmd.packet0.cmd_type = R300_CMD_PACKET0;
-       cmd.packet0.count = count;
-       cmd.packet0.reghi = ((unsigned int)reg & 0xFF00) >> 8;
-       cmd.packet0.reglo = ((unsigned int)reg & 0x00FF);
-
-       return cmd.u;
+    if (!rscrn->kernel_mm) {
+           drm_r300_cmd_header_t cmd;
+
+       cmd.u = 0;
+       cmd.packet0.cmd_type = R300_CMD_PACKET0;
+           cmd.packet0.count = count;
+       cmd.packet0.reghi = ((unsigned int)reg & 0xFF00) >> 8;
+           cmd.packet0.reglo = ((unsigned int)reg & 0x00FF);
+
+       return cmd.u;
+    }
+    if (count) {
+        return CP_PACKET0(reg, count - 1);
+    }
+    return CP_PACKET2;
 }
 
-static INLINE uint32_t cmdvpu(int addr, int count)
+static INLINE uint32_t cmdvpu(struct radeon_screen *rscrn, int addr, int count)
 {
        drm_r300_cmd_header_t cmd;
 
+       cmd.u = 0;
        cmd.vpu.cmd_type = R300_CMD_VPU;
        cmd.vpu.count = count;
        cmd.vpu.adrhi = ((unsigned int)addr & 0xFF00) >> 8;
@@ -74,10 +77,12 @@ static INLINE uint32_t cmdvpu(int addr, int count)
        return cmd.u;
 }
 
-static INLINE uint32_t cmdr500fp(int addr, int count, int type, int clamp)
+static INLINE uint32_t cmdr500fp(struct radeon_screen *rscrn,
+                                 int addr, int count, int type, int clamp)
 {
        drm_r300_cmd_header_t cmd;
 
+       cmd.u = 0;
        cmd.r500fp.cmd_type = R300_CMD_R500FP;
        cmd.r500fp.count = count;
        cmd.r500fp.adrhi_flags = ((unsigned int)addr & 0x100) >> 8;
@@ -88,181 +93,139 @@ static INLINE uint32_t cmdr500fp(int addr, int count, int type, int clamp)
        return cmd.u;
 }
 
-static INLINE uint32_t cmdpacket3(int packet)
+static INLINE uint32_t cmdpacket3(struct radeon_screen *rscrn, int packet)
 {
        drm_r300_cmd_header_t cmd;
 
+       cmd.u = 0;
        cmd.packet3.cmd_type = R300_CMD_PACKET3;
        cmd.packet3.packet = packet;
 
        return cmd.u;
 }
 
-static INLINE uint32_t cmdcpdelay(unsigned short count)
+static INLINE uint32_t cmdcpdelay(struct radeon_screen *rscrn,  
+                                  unsigned short count)
 {
        drm_r300_cmd_header_t cmd;
 
+       cmd.u = 0;
+
        cmd.delay.cmd_type = R300_CMD_CP_DELAY;
        cmd.delay.count = count;
 
        return cmd.u;
 }
 
-static INLINE uint32_t cmdwait(unsigned char flags)
+static INLINE uint32_t cmdwait(struct radeon_screen *rscrn,
+                               unsigned char flags)
 {
        drm_r300_cmd_header_t cmd;
 
+       cmd.u = 0;
        cmd.wait.cmd_type = R300_CMD_WAIT;
        cmd.wait.flags = flags;
 
        return cmd.u;
 }
 
-static INLINE uint32_t cmdpacify(void)
+static INLINE uint32_t cmdpacify(struct radeon_screen *rscrn)
 {
        drm_r300_cmd_header_t cmd;
 
+       cmd.u = 0;
        cmd.header.cmd_type = R300_CMD_END3D;
 
        return cmd.u;
 }
 
 /**
- * Prepare to write a register value to register at address reg.
- * If num_extra > 0 then the following extra values are written
- * to registers with address +4, +8 and so on..
- */
-#define reg_start(reg, num_extra)                                      \
-       do {                                                            \
-               int _n;                                                 \
-               _n=(num_extra);                                         \
-               cmd = (drm_radeon_cmd_header_t*)                        \
-                       r300AllocCmdBuf(rmesa,                          \
-                                       (_n+2),                         \
-                                       __FUNCTION__);                  \
-               cmd_reserved=_n+2;                                      \
-               cmd_written=1;                                          \
-               cmd[0].i=cmdpacket0((reg), _n+1);                       \
-       } while (0);
-
-/**
- * Emit GLuint freestyle
+ * Write the header of a packet3 to the command buffer.
+ * Outputs 2 dwords and expects (num_extra+1) additional dwords afterwards.
  */
-#define e32(dword)                                                     \
-       do {                                                            \
-               if(cmd_written<cmd_reserved) {                          \
-                       cmd[cmd_written].i=(dword);                     \
-                       cmd_written++;                                  \
-               } else {                                                \
-                       fprintf(stderr,                                 \
-                               "e32 but no previous packet "           \
-                               "declaration.\n"                        \
-                               "Aborting! in %s::%s at line %d, "      \
-                               "cmd_written=%d cmd_reserved=%d\n",     \
-                               __FILE__, __FUNCTION__, __LINE__,       \
-                               cmd_written, cmd_reserved);             \
-                       _mesa_exit(-1);                                 \
-               }                                                       \
+#define OUT_BATCH_PACKET3(packet, num_extra) do {\
+    if (!b_l_rmesa->radeonScreen->kernel_mm) {         \
+       OUT_BATCH(cmdpacket3(b_l_rmesa->radeonScreen,\
+                  R300_CMD_PACKET3_RAW)); \
+    } else b_l_rmesa->cmdbuf.cs->section_cdw++;\
+       OUT_BATCH(CP_PACKET3((packet), (num_extra))); \
        } while(0)
 
-#define        efloat(f) e32(r300PackFloat32(f))
-
-#define vsf_start_fragment(dest, length)                               \
-       do {                                                            \
-               int _n;                                                 \
-               _n = (length);                                          \
-               cmd = (drm_radeon_cmd_header_t*)                        \
-                       r300AllocCmdBuf(rmesa,                          \
-                                       (_n+1),                         \
-                                       __FUNCTION__);                  \
-               cmd_reserved = _n+2;                                    \
-               cmd_written =1;                                         \
-               cmd[0].i = cmdvpu((dest), _n/4);                        \
-       } 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;                                                 \
-               GLuint _p;                                              \
-               _n = (count);                                           \
-               _p = (packet);                                          \
-               cmd = (drm_radeon_cmd_header_t*)                        \
-                       r300AllocCmdBuf(rmesa,                          \
-                                       (_n+3),                         \
-                                       __FUNCTION__);                  \
-               cmd_reserved = _n+3;                                    \
-               cmd_written = 2;                                        \
-               if(_n > 0x3fff) {                                       \
-                       fprintf(stderr,"Too big packet3 %08x: cannot "  \
-                               "store %d dwords\n",                    \
-                               _p, _n);                                \
-                       _mesa_exit(-1);                                 \
-               }                                                       \
-               cmd[0].i = cmdpacket3(R300_CMD_PACKET3_RAW);            \
-               cmd[1].i = _p | ((_n & 0x3fff)<<16);                    \
-       }
-
 /**
  * Must be sent to switch to 2d commands
  */
-void static INLINE end_3d(r300ContextPtr rmesa)
+void static INLINE end_3d(radeonContextPtr radeon)
 {
-       drm_radeon_cmd_header_t *cmd = NULL;
+       BATCH_LOCALS(radeon);
 
-       cmd =
-           (drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, 1, __FUNCTION__);
-       cmd[0].header.cmd_type = R300_CMD_END3D;
+       if (!radeon->radeonScreen->kernel_mm) {
+               BEGIN_BATCH_NO_AUTOSTATE(1);
+               OUT_BATCH(cmdpacify(radeon->radeonScreen));
+               END_BATCH();
+       }
 }
 
 void static INLINE cp_delay(r300ContextPtr rmesa, unsigned short count)
 {
-       drm_radeon_cmd_header_t *cmd = NULL;
+       BATCH_LOCALS(&rmesa->radeon);
 
-       cmd =
-           (drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, 1, __FUNCTION__);
-       cmd[0].i = cmdcpdelay(count);
+       if (!rmesa->radeon.radeonScreen->kernel_mm) {
+               BEGIN_BATCH_NO_AUTOSTATE(1);
+               OUT_BATCH(cmdcpdelay(rmesa->radeon.radeonScreen, count));
+               END_BATCH();
+       }
 }
 
-void static INLINE cp_wait(r300ContextPtr rmesa, unsigned char flags)
+void static INLINE cp_wait(radeonContextPtr radeon, unsigned char flags)
 {
-       drm_radeon_cmd_header_t *cmd = NULL;
-
-       cmd =
-           (drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, 1, __FUNCTION__);
-       cmd[0].i = cmdwait(flags);
+       BATCH_LOCALS(radeon);
+       uint32_t wait_until;
+
+       if (!radeon->radeonScreen->kernel_mm) {
+               BEGIN_BATCH_NO_AUTOSTATE(1);
+               OUT_BATCH(cmdwait(radeon->radeonScreen, flags));
+               END_BATCH();
+       } else {
+               switch(flags) {
+               case R300_WAIT_2D:
+                       wait_until = (1 << 14);
+                       break;
+               case R300_WAIT_3D:
+                       wait_until = (1 << 15);
+                       break;
+               case R300_NEW_WAIT_2D_3D:
+                       wait_until = (1 << 14) | (1 << 15);
+                       break;
+               case R300_NEW_WAIT_2D_2D_CLEAN:
+                       wait_until = (1 << 14) | (1 << 16) | (1 << 18);
+                       break;
+               case R300_NEW_WAIT_3D_3D_CLEAN:
+                       wait_until = (1 << 15) | (1 << 17) | (1 << 18);
+                       break;
+               case R300_NEW_WAIT_2D_2D_CLEAN_3D_3D_CLEAN:
+                       wait_until  = (1 << 14) | (1 << 16) | (1 << 18);
+                       wait_until |= (1 << 15) | (1 << 17) | (1 << 18);
+                       break;
+               default:
+                       return;
+               }
+               BEGIN_BATCH_NO_AUTOSTATE(2);
+               OUT_BATCH(CP_PACKET0(RADEON_WAIT_UNTIL, 0));
+               OUT_BATCH(wait_until);
+               END_BATCH();
+       }
 }
 
-extern int r300EmitArrays(GLcontext * ctx);
-
-#ifdef USER_BUFFERS
-void r300UseArrays(GLcontext * ctx);
-#endif
+extern GLboolean r300EmitArrays(GLcontext * ctx);
 
-extern void r300ReleaseArrays(GLcontext * ctx);
 extern int r300PrimitiveType(r300ContextPtr rmesa, int prim);
 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);
-extern GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten);
-extern GLuint r300VAPOutputCntl1(GLcontext * ctx, GLuint OutputsWritten);
+extern GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint vp_writes, GLuint fp_reads);
+extern GLuint r300VAPOutputCntl1(GLcontext * ctx, GLuint vp_writes, GLuint fp_reads);
 
 #endif
index 873cde44144394c361ee09f31478dd1f70277b4a..55c1cfe63179fbd921b6b300d5f314607558d909 100644 (file)
  *
  */
 
-/**
- * \file
- *
- * 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>
- */
+#include "r300_fragprog.h"
 
-#include "main/glheader.h"
-#include "main/macros.h"
-#include "main/enums.h"
-#include "shader/prog_instruction.h"
 #include "shader/prog_parameter.h"
-#include "shader/prog_print.h"
 
 #include "r300_context.h"
-#include "r300_fragprog.h"
 #include "r300_fragprog_swizzle.h"
-#include "r300_state.h"
-
-#include "radeon_nqssadce.h"
-#include "radeon_program_alu.h"
-
 
 static void reset_srcreg(struct prog_src_register* reg)
 {
@@ -81,7 +61,7 @@ static struct prog_src_register shadow_ambient(struct gl_program *program, int t
  * \todo If/when r5xx uses the radeon_program architecture, this can probably
  * be reused.
  */
-static GLboolean transform_TEX(
+GLboolean r300_transform_TEX(
        struct radeon_transform_context *t,
        struct prog_instruction* orig_inst, void* data)
 {
@@ -160,6 +140,8 @@ static GLboolean transform_TEX(
                        inst.DstReg.Index = tempreg;
                        inst.DstReg.WriteMask = WRITEMASK_XYZW;
                        destredirect = GL_TRUE;
+               } else if (inst.SaturateMode) {
+                       destredirect = GL_TRUE;
                }
        }
 
@@ -175,7 +157,7 @@ static GLboolean transform_TEX(
                inst.SrcReg[0].File = PROGRAM_TEMPORARY;
                inst.SrcReg[0].Index = tmpreg;
        }
-       
+
        tgt = radeonAppendInstructions(t->Program, 1);
        _mesa_copy_instructions(tgt, &inst, 1);
 
@@ -239,6 +221,7 @@ static GLboolean transform_TEX(
 
                tgt->Opcode = OPCODE_MOV;
                tgt->DstReg = orig_inst->DstReg;
+               tgt->SaturateMode = inst.SaturateMode;
                tgt->SrcReg[0].File = PROGRAM_TEMPORARY;
                tgt->SrcReg[0].Index = inst.DstReg.Index;
        }
@@ -246,241 +229,10 @@ static GLboolean transform_TEX(
        return GL_TRUE;
 }
 
-
-static void update_params(r300ContextPtr r300, 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(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 r300_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_COLOR].Sourced = WRITEMASK_XYZW;
-       s->Outputs[FRAG_RESULT_DEPTH].Sourced = WRITEMASK_W;
-}
-
-
-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 r300_fragment_program *fp,
-       struct r300_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);
-               }
-       }
-}
-
-
-void r300TranslateFragmentShader(r300ContextPtr r300,
-                                struct r300_fragment_program *fp)
-{
-       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);
-               }
-
-               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);
-               }
-
-               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);
-               }
-
-               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(r300, fp);
-}
-
 /* just some random things... */
-void r300FragmentProgramDump(
-       struct r300_fragment_program *fp,
-       struct r300_fragment_program_code *code)
+void r300FragmentProgramDump(union rX00_fragment_program_code *c)
 {
+       struct r300_fragment_program_code *code = &c->r300;
        int n, i, j;
        static int pc = 0;
 
index 94fb554fb374ec94e1bd6e3bf132501e8229b305..5ce6f33cee705197f43d716f8f39b65801304048 100644 (file)
@@ -33,9 +33,6 @@
 #ifndef __R300_FRAGPROG_H_
 #define __R300_FRAGPROG_H_
 
-#include "main/glheader.h"
-#include "main/macros.h"
-#include "main/enums.h"
 #include "shader/program.h"
 #include "shader/prog_instruction.h"
 
 
 #endif
 
-struct r300_fragment_program;
+extern GLboolean r300BuildFragmentProgramHwCode(struct r300_fragment_program_compiler *compiler);
 
-extern void r300TranslateFragmentShader(r300ContextPtr r300,
-                                       struct r300_fragment_program *fp);
+extern void r300FragmentProgramDump(union rX00_fragment_program_code *c);
 
-
-/**
- * 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);
+extern GLboolean r300_transform_TEX(struct radeon_transform_context *t, struct prog_instruction* orig_inst, void* data);
 
 #endif
diff --git a/src/mesa/drivers/dri/r300/r300_fragprog_common.c b/src/mesa/drivers/dri/r300/r300_fragprog_common.c
new file mode 100644 (file)
index 0000000..abc8757
--- /dev/null
@@ -0,0 +1,291 @@
+/*
+ * Copyright (C) 2009 Maciej Cencora <m.cencora@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.
+ *
+ */
+
+/**
+ * \file
+ *
+ * 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>
+ */
+
+#include "r300_fragprog_common.h"
+
+#include "shader/program.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_print.h"
+
+#include "r300_state.h"
+#include "r300_fragprog.h"
+#include "r300_fragprog_swizzle.h"
+#include "r500_fragprog.h"
+
+#include "radeon_program.h"
+#include "radeon_program_alu.h"
+
+static void update_params(GLcontext *ctx, struct gl_fragment_program *fp)
+{
+       /* Ask Mesa nicely to fill in ParameterValues for us */
+       if (fp->Base.Parameters)
+               _mesa_load_state_parameters(ctx, fp->Base.Parameters);
+}
+
+static void nqssadce_init(struct nqssadce_state* s)
+{
+       s->Outputs[FRAG_RESULT_COLOR].Sourced = WRITEMASK_XYZW;
+       s->Outputs[FRAG_RESULT_DEPTH].Sourced = WRITEMASK_W;
+}
+
+/**
+ * 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.
+ *
+ */
+static void insert_WPOS_trailer(struct r300_fragment_program_compiler *compiler)
+{
+       GLuint InputsRead = compiler->fp->Base.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 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 r300_fragment_program *fp,
+       struct r300_fragment_program_external_state *state)
+{
+       int unit;
+
+       _mesa_bzero(state, sizeof(*state));
+
+       for(unit = 0; unit < 16; ++unit) {
+               if (fp->Base.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);
+               }
+       }
+}
+
+void r300TranslateFragmentShader(GLcontext *ctx, struct gl_fragment_program *fp)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       struct r300_fragment_program *r300_fp = (struct r300_fragment_program *)fp;
+       struct r300_fragment_program_external_state state;
+
+       build_state(r300, r300_fp, &state);
+       if (_mesa_memcmp(&r300_fp->state, &state, sizeof(state))) {
+               /* TODO: cache compiled programs */
+               r300_fp->translated = GL_FALSE;
+               _mesa_memcpy(&r300_fp->state, &state, sizeof(state));
+       }
+
+       if (!r300_fp->translated) {
+               struct r300_fragment_program_compiler compiler;
+
+               compiler.r300 = r300;
+               compiler.fp = r300_fp;
+               compiler.code = &r300_fp->code;
+               compiler.program = _mesa_clone_program(ctx, &fp->Base);
+
+               if (RADEON_DEBUG & DEBUG_PIXEL) {
+                       fflush(stdout);
+                       _mesa_printf("Fragment Program: Initial program:\n");
+                       _mesa_print_program(compiler.program);
+                       fflush(stdout);
+               }
+
+               insert_WPOS_trailer(&compiler);
+
+               if (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) {
+                       struct radeon_program_transformation transformations[] = {
+                               { &r500_transform_TEX, &compiler },
+                               { &radeonTransformALU, 0 },
+                               { &radeonTransformDeriv, 0 },
+                               { &radeonTransformTrigScale, 0 }
+                       };
+                       radeonLocalTransform(ctx, compiler.program, 4, transformations);
+               } else {
+                       struct radeon_program_transformation transformations[] = {
+                               { &r300_transform_TEX, &compiler },
+                               { &radeonTransformALU, 0 },
+                               { &radeonTransformTrigSimple, 0 }
+                       };
+                       radeonLocalTransform(ctx, compiler.program, 3, transformations);
+               }
+
+               if (RADEON_DEBUG & DEBUG_PIXEL) {
+                       _mesa_printf("Fragment Program: After native rewrite:\n");
+                       _mesa_print_program(compiler.program);
+                       fflush(stdout);
+               }
+
+               if (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) {
+                       struct radeon_nqssadce_descr nqssadce = {
+                               .Init = &nqssadce_init,
+                               .IsNativeSwizzle = &r500FPIsNativeSwizzle,
+                               .BuildSwizzle = &r500FPBuildSwizzle,
+                               .RewriteDepthOut = GL_TRUE
+                       };
+                       radeonNqssaDce(ctx, compiler.program, &nqssadce);
+               } else {
+                       struct radeon_nqssadce_descr nqssadce = {
+                               .Init = &nqssadce_init,
+                               .IsNativeSwizzle = &r300FPIsNativeSwizzle,
+                               .BuildSwizzle = &r300FPBuildSwizzle,
+                               .RewriteDepthOut = GL_TRUE
+                       };
+                       radeonNqssaDce(ctx, compiler.program, &nqssadce);
+               }
+
+               if (RADEON_DEBUG & DEBUG_PIXEL) {
+                       _mesa_printf("Compiler: after NqSSA-DCE:\n");
+                       _mesa_print_program(compiler.program);
+                       fflush(stdout);
+               }
+
+               if (!r300->vtbl.BuildFragmentProgramHwCode(&compiler))
+                       r300_fp->error = GL_TRUE;
+
+               /* Subtle: Rescue any parameters that have been added during transformations */
+               _mesa_free_parameter_list(fp->Base.Parameters);
+               fp->Base.Parameters = compiler.program->Parameters;
+               compiler.program->Parameters = 0;
+
+               _mesa_reference_program(ctx, &compiler.program, NULL);
+
+               r300_fp->translated = GL_TRUE;
+
+               r300UpdateStateParameters(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
+
+               if (r300_fp->error || (RADEON_DEBUG & DEBUG_PIXEL))
+                       r300->vtbl.FragmentProgramDump(&r300_fp->code);
+       }
+
+       update_params(ctx, fp);
+}
diff --git a/src/mesa/drivers/dri/r300/r300_fragprog_common.h b/src/mesa/drivers/dri/r300/r300_fragprog_common.h
new file mode 100644 (file)
index 0000000..85ea86f
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2009 Maciej Cencora <m.cencora@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.
+ *
+ */
+
+#ifndef __R300_FRAGPROG_COMMON_H_
+#define __R300_FRAGPROG_COMMON_H_
+
+#include "main/mtypes.h"
+
+extern void r300TranslateFragmentShader(GLcontext *ctx, struct gl_fragment_program *fp);
+
+#endif
index 9f0b7e3534978d683b97b5877b7713aa34403674..b75656e7ee1bb0a36b15f047db98f8c200566c77 100644 (file)
@@ -47,7 +47,7 @@
 
 #define PROG_CODE \
        struct r300_fragment_program_compiler *c = (struct r300_fragment_program_compiler*)data; \
-       struct r300_fragment_program_code *code = c->code
+       struct r300_fragment_program_code *code = &c->code->r300
 
 #define error(fmt, args...) do {                       \
                fprintf(stderr, "%s::%s(): " fmt "\n",  \
@@ -66,7 +66,7 @@ static GLboolean emit_const(void* data, GLuint file, GLuint index, GLuint *hwind
        }
 
        if (*hwindex >= code->const_nr) {
-               if (*hwindex >= PFS_NUM_CONST_REGS) {
+               if (*hwindex >= R300_PFS_NUM_CONST_REGS) {
                        error("Out of hw constants!\n");
                        return GL_FALSE;
                }
@@ -138,7 +138,7 @@ static GLboolean emit_alu(void* data, struct radeon_pair_instruction* inst)
 {
        PROG_CODE;
 
-       if (code->alu.length >= PFS_MAX_ALU_INST) {
+       if (code->alu.length >= R300_PFS_MAX_ALU_INST) {
                error("Too many ALU instructions");
                return GL_FALSE;
        }
@@ -201,7 +201,7 @@ static GLboolean emit_alu(void* data, struct radeon_pair_instruction* inst)
        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;
+               c->fp->writes_depth = GL_TRUE;
        }
 
        return GL_TRUE;
@@ -213,7 +213,7 @@ static GLboolean emit_alu(void* data, struct radeon_pair_instruction* inst)
  */
 static GLboolean finish_node(struct r300_fragment_program_compiler *c)
 {
-       struct r300_fragment_program_code *code = c->code;
+       struct r300_fragment_program_code *code = &c->code->r300;
        struct r300_fragment_program_node *node = &code->node[code->cur_node];
 
        if (node->alu_end < 0) {
@@ -275,7 +275,7 @@ static GLboolean emit_tex(void* data, struct prog_instruction* inst)
 {
        PROG_CODE;
 
-       if (code->tex.length >= PFS_MAX_TEX_INST) {
+       if (code->tex.length >= R300_PFS_MAX_TEX_INST) {
                error("Too many TEX instructions");
                return GL_FALSE;
        }
@@ -318,16 +318,16 @@ static const struct radeon_pair_handler pair_handler = {
        .EmitPaired = &emit_alu,
        .EmitTex = &emit_tex,
        .BeginTexBlock = &begin_tex,
-       .MaxHwTemps = PFS_NUM_TEMP_REGS
+       .MaxHwTemps = R300_PFS_NUM_TEMP_REGS
 };
 
 /**
  * Final compilation step: Turn the intermediate radeon_program into
  * machine-readable instructions.
  */
-GLboolean r300FragmentProgramEmit(struct r300_fragment_program_compiler *compiler)
+GLboolean r300BuildFragmentProgramHwCode(struct r300_fragment_program_compiler *compiler)
 {
-       struct r300_fragment_program_code *code = compiler->code;
+       struct r300_fragment_program_code *code = &compiler->code->r300;
 
        _mesa_bzero(code, sizeof(struct r300_fragment_program_code));
        code->node[0].alu_end = -1;
index ee85e229f0b222bbeaac31a3050badeb1efbe80e..104079b4dbe9789c47c01b2519705f9fcb89c636 100644 (file)
@@ -46,8 +46,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/context.h"
 #include "swrast/swrast.h"
 
+#include "radeon_common.h"
+#include "radeon_lock.h"
 #include "r300_context.h"
-#include "radeon_ioctl.h"
 #include "r300_ioctl.h"
 #include "r300_cmdbuf.h"
 #include "r300_state.h"
@@ -55,71 +56,90 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "radeon_reg.h"
 #include "r300_emit.h"
 #include "r300_fragprog.h"
+#include "r300_context.h"
 
 #include "vblank.h"
 
+#define R200_3D_DRAW_IMMD_2      0xC0003500
+
 #define CLEARBUFFER_COLOR      0x1
 #define CLEARBUFFER_DEPTH      0x2
 #define CLEARBUFFER_STENCIL    0x4
 
-static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
+static void r300EmitClearState(GLcontext * ctx);
+
+static void r300UserClear(GLcontext *ctx, GLuint mask)
 {
+       radeon_clear_tris(ctx, mask);
+}
+
+static void r300ClearBuffer(r300ContextPtr r300, int flags,
+                           struct radeon_renderbuffer *rrb,
+                           struct radeon_renderbuffer *rrbd)
+{
+       BATCH_LOCALS(&r300->radeon);
        GLcontext *ctx = r300->radeon.glCtx;
-       __DRIdrawablePrivate *dPriv = r300->radeon.dri.drawable;
-       GLuint cboffset, cbpitch;
-       drm_r300_cmd_header_t *cmd2;
-       int cmd_reserved = 0;
-       int cmd_written = 0;
-       drm_radeon_cmd_header_t *cmd = NULL;
+       __DRIdrawablePrivate *dPriv = radeon_get_drawable(&r300->radeon);
+       GLuint cbpitch = 0;
        r300ContextPtr rmesa = r300;
 
        if (RADEON_DEBUG & DEBUG_IOCTL)
-               fprintf(stderr, "%s: %s buffer (%i,%i %ix%i)\n",
-                       __FUNCTION__, buffer ? "back" : "front",
-                       dPriv->x, dPriv->y, dPriv->w, dPriv->h);
-
-       if (buffer) {
-               cboffset = r300->radeon.radeonScreen->backOffset;
-               cbpitch = r300->radeon.radeonScreen->backPitch;
-       } else {
-               cboffset = r300->radeon.radeonScreen->frontOffset;
-               cbpitch = r300->radeon.radeonScreen->frontPitch;
+               fprintf(stderr, "%s: buffer %p (%i,%i %ix%i)\n",
+                       __FUNCTION__, rrb, dPriv->x, dPriv->y,
+                       dPriv->w, dPriv->h);
+
+       if (rrb) {
+               cbpitch = (rrb->pitch / rrb->cpp);
+               if (rrb->cpp == 4)
+                       cbpitch |= R300_COLOR_FORMAT_ARGB8888;
+               else
+                       cbpitch |= R300_COLOR_FORMAT_RGB565;
+
+               if (rrb->bo->flags & RADEON_BO_FLAGS_MACRO_TILE){
+                       cbpitch |= R300_COLOR_TILE_ENABLE;
+        }
        }
 
-       cboffset += r300->radeon.radeonScreen->fbLocation;
-
-       cp_wait(r300, R300_WAIT_3D | R300_WAIT_3D_CLEAN);
-       end_3d(rmesa);
-
-       R300_STATECHANGE(r300, cb);
-       reg_start(R300_RB3D_COLOROFFSET0, 0);
-       e32(cboffset);
-
-       if (r300->radeon.radeonScreen->cpp == 4)
-               cbpitch |= R300_COLOR_FORMAT_ARGB8888;
-       else
-               cbpitch |= R300_COLOR_FORMAT_RGB565;
-
-       if (r300->radeon.sarea->tiling_enabled)
-               cbpitch |= R300_COLOR_TILE_ENABLE;
-
-       reg_start(R300_RB3D_COLORPITCH0, 0);
-       e32(cbpitch);
-
-       R300_STATECHANGE(r300, cmk);
-       reg_start(RB3D_COLOR_CHANNEL_MASK, 0);
+       /* TODO in bufmgr */
+       cp_wait(&r300->radeon, R300_WAIT_3D | R300_WAIT_3D_CLEAN);
+       end_3d(&rmesa->radeon);
 
        if (flags & CLEARBUFFER_COLOR) {
-               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));
+               assert(rrb != 0);
+               BEGIN_BATCH_NO_AUTOSTATE(6);
+               OUT_BATCH_REGSEQ(R300_RB3D_COLOROFFSET0, 1);
+               OUT_BATCH_RELOC(0, rrb->bo, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+               OUT_BATCH_REGVAL(R300_RB3D_COLORPITCH0, cbpitch);
+               END_BATCH();
+       }
+#if 1
+       if (flags & (CLEARBUFFER_DEPTH | CLEARBUFFER_STENCIL)) {
+               assert(rrbd != 0);
+               cbpitch = (rrbd->pitch / rrbd->cpp);
+               if (rrbd->bo->flags & RADEON_BO_FLAGS_MACRO_TILE){
+                       cbpitch |= R300_DEPTHMACROTILE_ENABLE;
+        }
+               if (rrbd->bo->flags & RADEON_BO_FLAGS_MICRO_TILE){
+            cbpitch |= R300_DEPTHMICROTILE_TILED;
+        }
+               BEGIN_BATCH_NO_AUTOSTATE(6);
+               OUT_BATCH_REGSEQ(R300_ZB_DEPTHOFFSET, 1);
+               OUT_BATCH_RELOC(0, rrbd->bo, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+               OUT_BATCH_REGVAL(R300_ZB_DEPTHPITCH, cbpitch);
+               END_BATCH();
+       }
+#endif
+       BEGIN_BATCH_NO_AUTOSTATE(6);
+       OUT_BATCH_REGSEQ(RB3D_COLOR_CHANNEL_MASK, 1);
+       if (flags & CLEARBUFFER_COLOR) {
+               OUT_BATCH((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);
+               OUT_BATCH(0);
        }
 
-       R300_STATECHANGE(r300, zs);
-       reg_start(R300_ZB_CNTL, 2);
 
        {
                uint32_t t1, t2;
@@ -146,73 +166,92 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
                             R300_S_FRONT_ZFAIL_OP_SHIFT);
                }
 
-               e32(t1);
-               e32(t2);
-               e32(((ctx->Stencil.WriteMask[0] & R300_STENCILREF_MASK) << R300_STENCILWRITEMASK_SHIFT) |
-                   (ctx->Stencil.Clear & R300_STENCILREF_MASK));
+               OUT_BATCH_REGSEQ(R300_ZB_CNTL, 3);
+               OUT_BATCH(t1);
+               OUT_BATCH(t2);
+               OUT_BATCH(((ctx->Stencil.WriteMask[0] & R300_STENCILREF_MASK) <<
+                   R300_STENCILWRITEMASK_SHIFT) |
+                         (ctx->Stencil.Clear & R300_STENCILREF_MASK));
+               END_BATCH();
        }
 
-       cmd2 = (drm_r300_cmd_header_t *) r300AllocCmdBuf(r300, 9, __FUNCTION__);
-       cmd2[0].packet3.cmd_type = R300_CMD_PACKET3;
-       cmd2[0].packet3.packet = R300_CMD_PACKET3_CLEAR;
-       cmd2[1].u = r300PackFloat32(dPriv->w / 2.0);
-       cmd2[2].u = r300PackFloat32(dPriv->h / 2.0);
-       cmd2[3].u = r300PackFloat32(ctx->Depth.Clear);
-       cmd2[4].u = r300PackFloat32(1.0);
-       cmd2[5].u = r300PackFloat32(ctx->Color.ClearColor[0]);
-       cmd2[6].u = r300PackFloat32(ctx->Color.ClearColor[1]);
-       cmd2[7].u = r300PackFloat32(ctx->Color.ClearColor[2]);
-       cmd2[8].u = r300PackFloat32(ctx->Color.ClearColor[3]);
+       if (!rmesa->radeon.radeonScreen->kernel_mm) {
+               BEGIN_BATCH_NO_AUTOSTATE(9);
+               OUT_BATCH(cmdpacket3(r300->radeon.radeonScreen, R300_CMD_PACKET3_CLEAR));
+               OUT_BATCH_FLOAT32(dPriv->w / 2.0);
+               OUT_BATCH_FLOAT32(dPriv->h / 2.0);
+               OUT_BATCH_FLOAT32(ctx->Depth.Clear);
+               OUT_BATCH_FLOAT32(1.0);
+               OUT_BATCH_FLOAT32(ctx->Color.ClearColor[0]);
+               OUT_BATCH_FLOAT32(ctx->Color.ClearColor[1]);
+               OUT_BATCH_FLOAT32(ctx->Color.ClearColor[2]);
+               OUT_BATCH_FLOAT32(ctx->Color.ClearColor[3]);
+               END_BATCH();
+       } else {
+               OUT_BATCH(CP_PACKET3(R200_3D_DRAW_IMMD_2, 8));
+               OUT_BATCH(R300_PRIM_TYPE_POINT | R300_PRIM_WALK_RING |
+                         (1 << R300_PRIM_NUM_VERTICES_SHIFT));
+               OUT_BATCH_FLOAT32(dPriv->w / 2.0);
+               OUT_BATCH_FLOAT32(dPriv->h / 2.0);
+               OUT_BATCH_FLOAT32(ctx->Depth.Clear);
+               OUT_BATCH_FLOAT32(1.0);
+               OUT_BATCH_FLOAT32(ctx->Color.ClearColor[0]);
+               OUT_BATCH_FLOAT32(ctx->Color.ClearColor[1]);
+               OUT_BATCH_FLOAT32(ctx->Color.ClearColor[2]);
+               OUT_BATCH_FLOAT32(ctx->Color.ClearColor[3]);
+       }
 
        r300EmitCacheFlush(rmesa);
-       cp_wait(rmesa, R300_WAIT_3D | R300_WAIT_3D_CLEAN);
+       cp_wait(&r300->radeon, R300_WAIT_3D | R300_WAIT_3D_CLEAN);
+
+       R300_STATECHANGE(r300, cb);
+       R300_STATECHANGE(r300, cmk);
+       R300_STATECHANGE(r300, zs);
 }
 
 static void r300EmitClearState(GLcontext * ctx)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
-       r300ContextPtr rmesa = r300;
-       __DRIdrawablePrivate *dPriv = r300->radeon.dri.drawable;
+       BATCH_LOCALS(&r300->radeon);
+       __DRIdrawablePrivate *dPriv = radeon_get_drawable(&r300->radeon);
        int i;
-       int cmd_reserved = 0;
-       int cmd_written = 0;
-       drm_radeon_cmd_header_t *cmd = NULL;
-       int has_tcl = 1;
+       int has_tcl;
        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;
+       has_tcl = r300->options.hw_tcl_enabled;
 
+       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.
+       /* State atom dirty tracking is a little subtle here.
+        *
+        * On the one hand, we need to make sure base state is emitted
+        * here if we start with an empty batch buffer, otherwise clear
+        * works incorrectly with multiple processes. Therefore, the first
+        * BEGIN_BATCH cannot be a BEGIN_BATCH_NO_AUTOSTATE.
         *
-        * I believe it would be a good idea to extend the functions in
-        * r300_emit.c so that they can be used to setup the default values for
-        * these registers, as well as the actual values used for rendering.
+        * On the other hand, implicit state emission clears the state atom
+        * dirty bits, so we have to call R300_STATECHANGE later than the
+        * first BEGIN_BATCH.
+        *
+        * The final trickiness is that, because we change state, we need
+        * to ensure that any stored swtcl primitives are flushed properly
+        * before we start changing state. See the R300_NEWPRIM in r300Clear
+        * for this.
         */
-       R300_STATECHANGE(r300, vir[0]);
-       reg_start(R300_VAP_PROG_STREAM_CNTL_0, 0);
+       BEGIN_BATCH(31);
+       OUT_BATCH_REGSEQ(R300_VAP_PROG_STREAM_CNTL_0, 1);
        if (!has_tcl)
-           e32(((((0 << R300_DST_VEC_LOC_SHIFT) | R300_DATA_TYPE_FLOAT_4) << R300_DATA_TYPE_0_SHIFT) |
+               OUT_BATCH(((((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(((((0 << R300_DST_VEC_LOC_SHIFT) | R300_DATA_TYPE_FLOAT_4) << R300_DATA_TYPE_0_SHIFT) |
+               OUT_BATCH(((((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_FG_FOG_BLEND, 0);
-       e32(0x0);
-
-       R300_STATECHANGE(r300, vir[1]);
-       reg_start(R300_VAP_PROG_STREAM_CNTL_EXT_0, 0);
-       e32(((((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) |
+       OUT_BATCH_REGVAL(R300_FG_FOG_BLEND, 0);
+       OUT_BATCH_REGVAL(R300_VAP_PROG_STREAM_CNTL_EXT_0,
+          ((((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) |
@@ -226,619 +265,402 @@ static void r300EmitClearState(GLcontext * ctx)
              << R300_SWIZZLE1_SHIFT)));
 
        /* R300_VAP_INPUT_CNTL_0, R300_VAP_INPUT_CNTL_1 */
-       R300_STATECHANGE(r300, vic);
-       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);
+       OUT_BATCH_REGSEQ(R300_VAP_VTX_STATE_CNTL, 2);
+       OUT_BATCH((R300_SEL_USER_COLOR_0 << R300_COLOR_0_ASSEMBLY_SHIFT));
+       OUT_BATCH(R300_INPUT_CNTL_POS | R300_INPUT_CNTL_COLOR | R300_INPUT_CNTL_TC0);
 
-       R300_STATECHANGE(r300, vte);
        /* comes from fglrx startup of clear */
-       reg_start(R300_SE_VTE_CNTL, 1);
-       e32(R300_VTX_W0_FMT | R300_VPORT_X_SCALE_ENA |
-           R300_VPORT_X_OFFSET_ENA | R300_VPORT_Y_SCALE_ENA |
-           R300_VPORT_Y_OFFSET_ENA | R300_VPORT_Z_SCALE_ENA |
-           R300_VPORT_Z_OFFSET_ENA);
-       e32(0x8);
+       OUT_BATCH_REGSEQ(R300_SE_VTE_CNTL, 2);
+       OUT_BATCH(R300_VTX_W0_FMT | R300_VPORT_X_SCALE_ENA |
+                 R300_VPORT_X_OFFSET_ENA | R300_VPORT_Y_SCALE_ENA |
+                 R300_VPORT_Y_OFFSET_ENA | R300_VPORT_Z_SCALE_ENA |
+                 R300_VPORT_Z_OFFSET_ENA);
+       OUT_BATCH(0x8);
 
-       reg_start(R300_VAP_PSC_SGN_NORM_CNTL, 0);
-       e32(0xaaaaaaaa);
+       OUT_BATCH_REGVAL(R300_VAP_PSC_SGN_NORM_CNTL, 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_0_PRESENT);
-       e32(0x0);               /* no textures */
+       OUT_BATCH_REGSEQ(R300_VAP_OUTPUT_VTX_FMT_0, 2);
+       OUT_BATCH(R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT |
+                 R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT);
+       OUT_BATCH(0); /* no textures */
 
-       R300_STATECHANGE(r300, txe);
-       reg_start(R300_TX_ENABLE, 0);
-       e32(0x0);
+       OUT_BATCH_REGVAL(R300_TX_ENABLE, 0);
 
-       R300_STATECHANGE(r300, vpt);
-       reg_start(R300_SE_VPORT_XSCALE, 5);
-       efloat(1.0);
-       efloat(dPriv->x);
-       efloat(1.0);
-       efloat(dPriv->y);
-       efloat(1.0);
-       efloat(0.0);
+       OUT_BATCH_REGSEQ(R300_SE_VPORT_XSCALE, 6);
+       OUT_BATCH_FLOAT32(1.0);
+       OUT_BATCH_FLOAT32(dPriv->x);
+       OUT_BATCH_FLOAT32(1.0);
+       OUT_BATCH_FLOAT32(dPriv->y);
+       OUT_BATCH_FLOAT32(1.0);
+       OUT_BATCH_FLOAT32(0.0);
 
-       R300_STATECHANGE(r300, at);
-       reg_start(R300_FG_ALPHA_FUNC, 0);
-       e32(0x0);
+       OUT_BATCH_REGVAL(R300_FG_ALPHA_FUNC, 0);
+
+       OUT_BATCH_REGSEQ(R300_RB3D_CBLEND, 2);
+       OUT_BATCH(0x0);
+       OUT_BATCH(0x0);
+       END_BATCH();
 
+       R300_STATECHANGE(r300, vir[0]);
+       R300_STATECHANGE(r300, fogs);
+       R300_STATECHANGE(r300, vir[1]);
+       R300_STATECHANGE(r300, vic);
+       R300_STATECHANGE(r300, vte);
+       R300_STATECHANGE(r300, vof);
+       R300_STATECHANGE(r300, txe);
+       R300_STATECHANGE(r300, vpt);
+       R300_STATECHANGE(r300, at);
        R300_STATECHANGE(r300, bld);
-       reg_start(R300_RB3D_CBLEND, 1);
-       e32(0x0);
-       e32(0x0);
+       R300_STATECHANGE(r300, ps);
 
        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, vap_clip_cntl);
+
+               BEGIN_BATCH_NO_AUTOSTATE(2);
+               OUT_BATCH_REGVAL(R300_VAP_CLIP_CNTL, R300_PS_UCP_MODE_CLIP_AS_TRIFAN | R300_CLIP_DISABLE);
+               END_BATCH();
         }
 
-       R300_STATECHANGE(r300, ps);
-       reg_start(R300_GA_POINT_SIZE, 0);
-       e32(((dPriv->w * 6) << R300_POINTSIZE_X_SHIFT) |
-           ((dPriv->h * 6) << R300_POINTSIZE_Y_SHIFT));
+       BEGIN_BATCH_NO_AUTOSTATE(2);
+       OUT_BATCH_REGVAL(R300_GA_POINT_SIZE,
+               ((dPriv->w * 6) << R300_POINTSIZE_X_SHIFT) |
+               ((dPriv->h * 6) << R300_POINTSIZE_Y_SHIFT));
+       END_BATCH();
 
        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);
+
+               BEGIN_BATCH(14);
+               OUT_BATCH_REGSEQ(R300_RS_IP_0, 8);
+               for (i = 0; i < 8; ++i)
+                       OUT_BATCH(R300_RS_SEL_T(1) | R300_RS_SEL_R(2) | R300_RS_SEL_Q(3));
+
+               OUT_BATCH_REGSEQ(R300_RS_COUNT, 2);
+               OUT_BATCH((1 << R300_IC_COUNT_SHIFT) | R300_HIRES_EN);
+               OUT_BATCH(0x0);
+
+               OUT_BATCH_REGVAL(R300_RS_INST_0, R300_RS_INST_COL_CN_WRITE);
+               END_BATCH();
        } else {
                R300_STATECHANGE(r300, ri);
-               reg_start(R500_RS_IP_0, 7);
+               R300_STATECHANGE(r300, rc);
+               R300_STATECHANGE(r300, rr);
+
+               BEGIN_BATCH(14);
+               OUT_BATCH_REGSEQ(R500_RS_IP_0, 8);
                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));
+                       OUT_BATCH((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);
+               OUT_BATCH_REGSEQ(R300_RS_COUNT, 2);
+               OUT_BATCH((1 << R300_IC_COUNT_SHIFT) | R300_HIRES_EN);
+               OUT_BATCH(0x0);
 
+               OUT_BATCH_REGVAL(R500_RS_INST_0, R500_RS_INST_COL_CN_WRITE);
+               END_BATCH();
        }
 
        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, fpi[0]);
                R300_STATECHANGE(r300, fpi[1]);
                R300_STATECHANGE(r300, fpi[2]);
                R300_STATECHANGE(r300, fpi[3]);
 
-               reg_start(R300_US_ALU_RGB_INST_0, 0);
-               e32(FP_INSTRC(MAD, FP_ARGC(SRC0C_XYZ), FP_ARGC(ONE), FP_ARGC(ZERO)));
-
-               reg_start(R300_US_ALU_RGB_ADDR_0, 0);
-               e32(FP_SELC(0, NO, XYZ, FP_TMP(0), 0, 0));
-
-               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_US_ALU_ALPHA_ADDR_0, 0);
-               e32(FP_SELA(0, NO, W, FP_TMP(0), 0, 0));
+               BEGIN_BATCH(17);
+               OUT_BATCH_REGSEQ(R300_US_CONFIG, 3);
+               OUT_BATCH(0x0);
+               OUT_BATCH(0x0);
+               OUT_BATCH(0x0);
+               OUT_BATCH_REGSEQ(R300_US_CODE_ADDR_0, 4);
+               OUT_BATCH(0x0);
+               OUT_BATCH(0x0);
+               OUT_BATCH(0x0);
+               OUT_BATCH(R300_RGBA_OUT);
+
+               OUT_BATCH_REGVAL(R300_US_ALU_RGB_INST_0,
+                       FP_INSTRC(MAD, FP_ARGC(SRC0C_XYZ), FP_ARGC(ONE), FP_ARGC(ZERO)));
+               OUT_BATCH_REGVAL(R300_US_ALU_RGB_ADDR_0,
+                       FP_SELC(0, NO, XYZ, FP_TMP(0), 0, 0));
+               OUT_BATCH_REGVAL(R300_US_ALU_ALPHA_INST_0,
+                       FP_INSTRA(MAD, FP_ARGA(SRC0A), FP_ARGA(ONE), FP_ARGA(ZERO)));
+               OUT_BATCH_REGVAL(R300_US_ALU_ALPHA_ADDR_0,
+                       FP_SELA(0, NO, W, FP_TMP(0), 0, 0));
+               END_BATCH();
        } 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));
+               struct radeon_state_atom r500fp;
+               uint32_t _cmd[10];
 
+               R300_STATECHANGE(r300, fp);
                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);
+
+               BEGIN_BATCH(7);
+               OUT_BATCH_REGSEQ(R500_US_CONFIG, 2);
+               OUT_BATCH(R500_ZERO_TIMES_ANYTHING_EQUALS_ZERO);
+               OUT_BATCH(0x0);
+               OUT_BATCH_REGSEQ(R500_US_CODE_ADDR, 3);
+               OUT_BATCH(R500_US_CODE_START_ADDR(0) | R500_US_CODE_END_ADDR(1));
+               OUT_BATCH(R500_US_CODE_RANGE_ADDR(0) | R500_US_CODE_RANGE_SIZE(1));
+               OUT_BATCH(R500_US_CODE_OFFSET_ADDR(0));
+               END_BATCH();
+
+               r500fp.check = check_r500fp;
+               r500fp.cmd = _cmd;
+               r500fp.cmd[0] = cmdr500fp(r300->radeon.radeonScreen, 0, 1, 0, 0);
+               r500fp.cmd[1] = 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;
+               r500fp.cmd[2] = R500_RGB_ADDR0(0) |
+                       R500_RGB_ADDR1(0) |
+                       R500_RGB_ADDR1_CONST |
+                       R500_RGB_ADDR2(0) |
+                       R500_RGB_ADDR2_CONST;
+               r500fp.cmd[3] = R500_ALPHA_ADDR0(0) |
+                       R500_ALPHA_ADDR1(0) |
+                       R500_ALPHA_ADDR1_CONST |
+                       R500_ALPHA_ADDR2(0) |
+                       R500_ALPHA_ADDR2_CONST;
+               r500fp.cmd[4] = 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;
+               r500fp.cmd[5] = R500_ALPHA_OP_CMP |
+                       R500_ALPHA_SWIZ_A_A |
+                       R500_ALPHA_SWIZ_B_A;
+               r500fp.cmd[6] = 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;
+
+               r500fp.cmd[7] = 0;
+               emit_r500fp(ctx, &r500fp);
        }
 
-       reg_start(R300_VAP_PVS_STATE_FLUSH_REG, 0);
-       e32(0x00000000);
+       BEGIN_BATCH(2);
+       OUT_BATCH_REGVAL(R300_VAP_PVS_STATE_FLUSH_REG, 0);
+       END_BATCH();
+
        if (has_tcl) {
-           vap_cntl = ((10 << R300_PVS_NUM_SLOTS_SHIFT) |
+               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) |
+               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);
+               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);
+               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);
+               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);
+               vap_cntl |= (8 << R300_PVS_NUM_FPUS_SHIFT);
        else
-           vap_cntl |= (4 << R300_PVS_NUM_FPUS_SHIFT);
+               vap_cntl |= (4 << R300_PVS_NUM_FPUS_SHIFT);
+
+       R300_STATECHANGE(r300, vap_cntl);
 
-       R300_STATECHANGE(rmesa, vap_cntl);
-       reg_start(R300_VAP_CNTL, 0);
-       e32(vap_cntl);
+       BEGIN_BATCH(2);
+       OUT_BATCH_REGVAL(R300_VAP_CNTL, vap_cntl);
+       END_BATCH();
 
        if (has_tcl) {
+        struct radeon_state_atom vpu;
+        uint32_t _cmd[10];
                R300_STATECHANGE(r300, pvs);
-               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(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(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);
+               BEGIN_BATCH(4);
+               OUT_BATCH_REGSEQ(R300_VAP_PVS_CODE_CNTL_0, 3);
+               OUT_BATCH((0 << R300_PVS_FIRST_INST_SHIFT) |
+                         (0 << R300_PVS_XYZW_VALID_INST_SHIFT) |
+                         (1 << R300_PVS_LAST_INST_SHIFT));
+               OUT_BATCH((0 << R300_PVS_CONST_BASE_OFFSET_SHIFT) |
+                         (0 << R300_PVS_MAX_CONST_ADDR_SHIFT));
+               OUT_BATCH(1 << R300_PVS_LAST_VTX_SRC_INST_SHIFT);
+               END_BATCH();
+
+               vpu.check = check_vpu;
+               vpu.cmd = _cmd;
+               vpu.cmd[0] = cmdvpu(r300->radeon.radeonScreen, 0, 2);
+
+               vpu.cmd[1] = PVS_OP_DST_OPERAND(VE_ADD, GL_FALSE, GL_FALSE,
+                                         0, 0xf, PVS_DST_REG_OUT);
+               vpu.cmd[2] = 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);
+               vpu.cmd[3] = 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);
+               vpu.cmd[4] = 0x0;
+
+               vpu.cmd[5] = PVS_OP_DST_OPERAND(VE_ADD, GL_FALSE, GL_FALSE, 1, 0xf,
+                                         PVS_DST_REG_OUT);
+               vpu.cmd[6] = 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);
+               vpu.cmd[7] = 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);
+               vpu.cmd[8] = 0x0;
+
+               r300->vap_flush_needed = GL_TRUE;
+               emit_vpu(ctx, &vpu);
        }
 }
 
-/**
- * Buffer clear
- */
-static void r300Clear(GLcontext * ctx, GLbitfield mask)
+static void r300KernelClear(GLcontext *ctx, GLuint flags)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
-       __DRIdrawablePrivate *dPriv = r300->radeon.dri.drawable;
-       int flags = 0;
+       __DRIdrawablePrivate *dPriv = radeon_get_drawable(&r300->radeon);
+       struct radeon_framebuffer *rfb = dPriv->driverPrivate;
+       struct radeon_renderbuffer *rrb;
+       struct radeon_renderbuffer *rrbd;
        int bits = 0;
-       int swapped;
-
-       if (RADEON_DEBUG & DEBUG_IOCTL)
-               fprintf(stderr, "r300Clear\n");
-
-       {
-               LOCK_HARDWARE(&r300->radeon);
-               UNLOCK_HARDWARE(&r300->radeon);
-               if (dPriv->numClipRects == 0)
-                       return;
-       }
 
-       if (mask & BUFFER_BIT_FRONT_LEFT) {
-               flags |= BUFFER_BIT_FRONT_LEFT;
-               mask &= ~BUFFER_BIT_FRONT_LEFT;
-       }
-
-       if (mask & BUFFER_BIT_BACK_LEFT) {
-               flags |= BUFFER_BIT_BACK_LEFT;
-               mask &= ~BUFFER_BIT_BACK_LEFT;
-       }
-
-       if (mask & BUFFER_BIT_DEPTH) {
+       /* Make sure it fits there. */
+       rcommonEnsureCmdBufSpace(&r300->radeon, 421 * 3, __FUNCTION__);
+       if (flags || bits)
+               r300EmitClearState(ctx);
+       rrbd = radeon_get_renderbuffer(&rfb->base, BUFFER_DEPTH);
+       if (rrbd && (flags & BUFFER_BIT_DEPTH))
                bits |= CLEARBUFFER_DEPTH;
-               mask &= ~BUFFER_BIT_DEPTH;
-       }
 
-       if ((mask & BUFFER_BIT_STENCIL) && r300->state.stencil.hw_stencil) {
+       if (rrbd && (flags & BUFFER_BIT_STENCIL))
                bits |= CLEARBUFFER_STENCIL;
-               mask &= ~BUFFER_BIT_STENCIL;
-       }
 
-       if (mask) {
-               if (RADEON_DEBUG & DEBUG_FALLBACKS)
-                       fprintf(stderr, "%s: swrast clear, mask: %x\n",
-                               __FUNCTION__, mask);
-               _swrast_Clear(ctx, mask);
+       if (flags & BUFFER_BIT_COLOR0) {
+               rrb = radeon_get_renderbuffer(&rfb->base, BUFFER_COLOR0);
+               r300ClearBuffer(r300, CLEARBUFFER_COLOR, rrb, NULL);
+               bits = 0;
        }
 
-       swapped = r300->radeon.sarea->pfCurrentPage == 1;
-
-       /* Make sure it fits there. */
-       r300EnsureCmdBufSpace(r300, 421 * 3, __FUNCTION__);
-       if (flags || bits)
-               r300EmitClearState(ctx);
-
        if (flags & BUFFER_BIT_FRONT_LEFT) {
-               r300ClearBuffer(r300, bits | CLEARBUFFER_COLOR, swapped);
+               rrb = radeon_get_renderbuffer(&rfb->base, BUFFER_FRONT_LEFT);
+               r300ClearBuffer(r300, bits | CLEARBUFFER_COLOR, rrb, rrbd);
                bits = 0;
        }
 
        if (flags & BUFFER_BIT_BACK_LEFT) {
-               r300ClearBuffer(r300, bits | CLEARBUFFER_COLOR, swapped ^ 1);
+               rrb = radeon_get_renderbuffer(&rfb->base, BUFFER_BACK_LEFT);
+               r300ClearBuffer(r300, bits | CLEARBUFFER_COLOR, rrb, rrbd);
                bits = 0;
        }
 
        if (bits)
-               r300ClearBuffer(r300, bits, 0);
+               r300ClearBuffer(r300, bits, NULL, rrbd);
 
+       COMMIT_BATCH();
 }
 
-void r300Flush(GLcontext * ctx)
+/**
+ * Buffer clear
+ */
+static void r300Clear(GLcontext * ctx, GLbitfield mask)
 {
-       r300ContextPtr rmesa = R300_CONTEXT(ctx);
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       __DRIdrawablePrivate *dPriv = radeon_get_drawable(&r300->radeon);
+       const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask);
+       GLbitfield swrast_mask = 0, tri_mask = 0;
+       int i;
+       struct gl_framebuffer *fb = ctx->DrawBuffer;
 
        if (RADEON_DEBUG & DEBUG_IOCTL)
-               fprintf(stderr, "%s\n", __FUNCTION__);
-
-       if (rmesa->dma.flush)
-               rmesa->dma.flush( rmesa );
-
-       if (rmesa->cmdbuf.count_used > rmesa->cmdbuf.count_reemit)
-               r300FlushCmdBuf(rmesa, __FUNCTION__);
-}
-
-#ifdef USER_BUFFERS
-#include "r300_mem.h"
-
-void r300RefillCurrentDmaRegion(r300ContextPtr rmesa, int size)
-{
-       struct r300_dma_buffer *dmabuf;
-       size = MAX2(size, RADEON_BUFFER_SIZE * 16);
-
-       if (RADEON_DEBUG & (DEBUG_IOCTL | DEBUG_DMA))
-               fprintf(stderr, "%s\n", __FUNCTION__);
-
-       if (rmesa->dma.flush) {
-               rmesa->dma.flush(rmesa);
-       }
+               fprintf(stderr, "r300Clear\n");
 
-       if (rmesa->dma.current.buf) {
-#ifdef USER_BUFFERS
-               r300_mem_use(rmesa, rmesa->dma.current.buf->id);
-#endif
-               r300ReleaseDmaRegion(rmesa, &rmesa->dma.current, __FUNCTION__);
+       if (!r300->radeon.radeonScreen->driScreen->dri2.enabled) {
+               LOCK_HARDWARE(&r300->radeon);
+               UNLOCK_HARDWARE(&r300->radeon);
+               if (dPriv->numClipRects == 0)
+                       return;
        }
-       if (rmesa->dma.nr_released_bufs > 4)
-               r300FlushCmdBuf(rmesa, __FUNCTION__);
-
-       dmabuf = CALLOC_STRUCT(r300_dma_buffer);
-       dmabuf->buf = (void *)1;        /* hack */
-       dmabuf->refcount = 1;
 
-       dmabuf->id = r300_mem_alloc(rmesa, 4, size);
-       if (dmabuf->id == 0) {
-               LOCK_HARDWARE(&rmesa->radeon);  /* no need to validate */
-
-               r300FlushCmdBufLocked(rmesa, __FUNCTION__);
-               radeonWaitForIdleLocked(&rmesa->radeon);
+       /* Flush swtcl vertices if necessary, because we will change hardware
+        * state during clear. See also the state-related comment in
+        * r300EmitClearState.
+        */
+       R300_NEWPRIM(r300);
 
-               dmabuf->id = r300_mem_alloc(rmesa, 4, size);
+       if (colorMask == ~0)
+         tri_mask |= (mask & BUFFER_BITS_COLOR);
 
-               UNLOCK_HARDWARE(&rmesa->radeon);
 
-               if (dmabuf->id == 0) {
-                       fprintf(stderr,
-                               "Error: Could not get dma buffer... exiting\n");
-                       _mesa_exit(-1);
-               }
+       /* HW stencil */
+       if (mask & BUFFER_BIT_STENCIL) {
+               tri_mask |= BUFFER_BIT_STENCIL;
        }
 
-       rmesa->dma.current.buf = dmabuf;
-       rmesa->dma.current.address = r300_mem_ptr(rmesa, dmabuf->id);
-       rmesa->dma.current.end = size;
-       rmesa->dma.current.start = 0;
-       rmesa->dma.current.ptr = 0;
-}
-
-void r300ReleaseDmaRegion(r300ContextPtr rmesa,
-                         struct r300_dma_region *region, const char *caller)
-{
-       if (RADEON_DEBUG & DEBUG_IOCTL)
-               fprintf(stderr, "%s from %s\n", __FUNCTION__, caller);
-
-       if (!region->buf)
-               return;
-
-       if (rmesa->dma.flush)
-               rmesa->dma.flush(rmesa);
-
-       if (--region->buf->refcount == 0) {
-               r300_mem_free(rmesa, region->buf->id);
-               FREE(region->buf);
-               rmesa->dma.nr_released_bufs++;
+       /* HW depth */
+       if (mask & BUFFER_BIT_DEPTH) {
+               tri_mask |= BUFFER_BIT_DEPTH;
        }
 
-       region->buf = 0;
-       region->start = 0;
-}
-
-/* Allocates a region from rmesa->dma.current.  If there isn't enough
- * space in current, grab a new buffer (and discard what was left of current)
- */
-void r300AllocDmaRegion(r300ContextPtr rmesa,
-                       struct r300_dma_region *region,
-                       int bytes, int alignment)
-{
-       if (RADEON_DEBUG & DEBUG_IOCTL)
-               fprintf(stderr, "%s %d\n", __FUNCTION__, bytes);
-
-       if (rmesa->dma.flush)
-               rmesa->dma.flush(rmesa);
-
-       if (region->buf)
-               r300ReleaseDmaRegion(rmesa, region, __FUNCTION__);
-
-       alignment--;
-       rmesa->dma.current.start = rmesa->dma.current.ptr =
-           (rmesa->dma.current.ptr + alignment) & ~alignment;
-
-       if (rmesa->dma.current.ptr + bytes > rmesa->dma.current.end)
-               r300RefillCurrentDmaRegion(rmesa, (bytes + 0x7) & ~0x7);
-
-       region->start = rmesa->dma.current.start;
-       region->ptr = rmesa->dma.current.start;
-       region->end = rmesa->dma.current.start + bytes;
-       region->address = rmesa->dma.current.address;
-       region->buf = rmesa->dma.current.buf;
-       region->buf->refcount++;
-
-       rmesa->dma.current.ptr += bytes;        /* bug - if alignment > 7 */
-       rmesa->dma.current.start =
-           rmesa->dma.current.ptr = (rmesa->dma.current.ptr + 0x7) & ~0x7;
-
-       assert(rmesa->dma.current.ptr <= rmesa->dma.current.end);
-}
+       /* If we're doing a tri pass for depth/stencil, include a likely color
+        * buffer with it.
+        */
 
-#else
-static void r300RefillCurrentDmaRegion(r300ContextPtr rmesa)
-{
-       struct r300_dma_buffer *dmabuf;
-       int fd = rmesa->radeon.dri.fd;
-       int index = 0;
-       int size = 0;
-       drmDMAReq dma;
-       int ret;
-
-       if (RADEON_DEBUG & (DEBUG_IOCTL | DEBUG_DMA))
-               fprintf(stderr, "%s\n", __FUNCTION__);
-
-       if (rmesa->dma.flush) {
-               rmesa->dma.flush(rmesa);
+       for (i = 0; i < BUFFER_COUNT; i++) {
+         GLuint bufBit = 1 << i;
+         if ((tri_mask) & bufBit) {
+           if (!fb->Attachment[i].Renderbuffer->ClassID) {
+             tri_mask &= ~bufBit;
+             swrast_mask |= bufBit;
+           }
+         }
        }
 
-       if (rmesa->dma.current.buf)
-               r300ReleaseDmaRegion(rmesa, &rmesa->dma.current, __FUNCTION__);
-
-       if (rmesa->dma.nr_released_bufs > 4)
-               r300FlushCmdBuf(rmesa, __FUNCTION__);
-
-       dma.context = rmesa->radeon.dri.hwContext;
-       dma.send_count = 0;
-       dma.send_list = NULL;
-       dma.send_sizes = NULL;
-       dma.flags = 0;
-       dma.request_count = 1;
-       dma.request_size = RADEON_BUFFER_SIZE;
-       dma.request_list = &index;
-       dma.request_sizes = &size;
-       dma.granted_count = 0;
-
-       LOCK_HARDWARE(&rmesa->radeon);  /* no need to validate */
-
-       ret = drmDMA(fd, &dma);
-
-       if (ret != 0) {
-               /* Try to release some buffers and wait until we can't get any more */
-               if (rmesa->dma.nr_released_bufs) {
-                       r300FlushCmdBufLocked(rmesa, __FUNCTION__);
-               }
-
-               if (RADEON_DEBUG & DEBUG_DMA)
-                       fprintf(stderr, "Waiting for buffers\n");
-
-               radeonWaitForIdleLocked(&rmesa->radeon);
-               ret = drmDMA(fd, &dma);
+       /* SW fallback clearing */
+       swrast_mask = mask & ~tri_mask;
 
-               if (ret != 0) {
-                       UNLOCK_HARDWARE(&rmesa->radeon);
-                       fprintf(stderr,
-                               "Error: Could not get dma buffer... exiting\n");
-                       _mesa_exit(-1);
-               }
+       if (tri_mask) {
+               if (r300->radeon.radeonScreen->kernel_mm)
+                       r300UserClear(ctx, tri_mask);
+               else
+                       r300KernelClear(ctx, tri_mask);
        }
-
-       UNLOCK_HARDWARE(&rmesa->radeon);
-
-       if (RADEON_DEBUG & DEBUG_DMA)
-               fprintf(stderr, "Allocated buffer %d\n", index);
-
-       dmabuf = CALLOC_STRUCT(r300_dma_buffer);
-       dmabuf->buf = &rmesa->radeon.radeonScreen->buffers->list[index];
-       dmabuf->refcount = 1;
-
-       rmesa->dma.current.buf = dmabuf;
-       rmesa->dma.current.address = dmabuf->buf->address;
-       rmesa->dma.current.end = dmabuf->buf->total;
-       rmesa->dma.current.start = 0;
-       rmesa->dma.current.ptr = 0;
-}
-
-void r300ReleaseDmaRegion(r300ContextPtr rmesa,
-                         struct r300_dma_region *region, const char *caller)
-{
-       if (RADEON_DEBUG & DEBUG_IOCTL)
-               fprintf(stderr, "%s from %s\n", __FUNCTION__, caller);
-
-       if (!region->buf)
-               return;
-
-       if (rmesa->dma.flush)
-               rmesa->dma.flush(rmesa);
-
-       if (--region->buf->refcount == 0) {
-               drm_radeon_cmd_header_t *cmd;
-
-               if (RADEON_DEBUG & (DEBUG_IOCTL | DEBUG_DMA))
-                       fprintf(stderr, "%s -- DISCARD BUF %d\n",
-                               __FUNCTION__, region->buf->buf->idx);
-               cmd =
-                   (drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa,
-                                                               sizeof
-                                                               (*cmd) / 4,
-                                                               __FUNCTION__);
-               cmd->dma.cmd_type = R300_CMD_DMA_DISCARD;
-               cmd->dma.buf_idx = region->buf->buf->idx;
-
-               FREE(region->buf);
-               rmesa->dma.nr_released_bufs++;
+       if (swrast_mask) {
+               if (RADEON_DEBUG & DEBUG_FALLBACKS)
+                       fprintf(stderr, "%s: swrast clear, mask: %x\n",
+                               __FUNCTION__, swrast_mask);
+               _swrast_Clear(ctx, swrast_mask);
        }
-
-       region->buf = 0;
-       region->start = 0;
-}
-
-/* Allocates a region from rmesa->dma.current.  If there isn't enough
- * space in current, grab a new buffer (and discard what was left of current)
- */
-void r300AllocDmaRegion(r300ContextPtr rmesa,
-                       struct r300_dma_region *region,
-                       int bytes, int alignment)
-{
-       if (RADEON_DEBUG & DEBUG_IOCTL)
-               fprintf(stderr, "%s %d\n", __FUNCTION__, bytes);
-
-       if (rmesa->dma.flush)
-               rmesa->dma.flush(rmesa);
-
-       if (region->buf)
-               r300ReleaseDmaRegion(rmesa, region, __FUNCTION__);
-
-       alignment--;
-       rmesa->dma.current.start = rmesa->dma.current.ptr =
-           (rmesa->dma.current.ptr + alignment) & ~alignment;
-
-       if (rmesa->dma.current.ptr + bytes > rmesa->dma.current.end)
-               r300RefillCurrentDmaRegion(rmesa);
-
-       region->start = rmesa->dma.current.start;
-       region->ptr = rmesa->dma.current.start;
-       region->end = rmesa->dma.current.start + bytes;
-       region->address = rmesa->dma.current.address;
-       region->buf = rmesa->dma.current.buf;
-       region->buf->refcount++;
-
-       rmesa->dma.current.ptr += bytes;        /* bug - if alignment > 7 */
-       rmesa->dma.current.start =
-           rmesa->dma.current.ptr = (rmesa->dma.current.ptr + 0x7) & ~0x7;
-
-       assert(rmesa->dma.current.ptr <= rmesa->dma.current.end);
 }
 
-#endif
-
-GLboolean r300IsGartMemory(r300ContextPtr rmesa, const GLvoid * pointer,
-                          GLint size)
-{
-       int offset =
-           (char *)pointer -
-           (char *)rmesa->radeon.radeonScreen->gartTextures.map;
-       int valid = (size >= 0 && offset >= 0
-                    && offset + size <
-                    rmesa->radeon.radeonScreen->gartTextures.size);
-
-       if (RADEON_DEBUG & DEBUG_IOCTL)
-               fprintf(stderr, "r300IsGartMemory( %p ) : %d\n", pointer,
-                       valid);
-
-       return valid;
-}
-
-GLuint r300GartOffsetFromVirtual(r300ContextPtr rmesa, const GLvoid * pointer)
-{
-       int offset =
-           (char *)pointer -
-           (char *)rmesa->radeon.radeonScreen->gartTextures.map;
-
-       //fprintf(stderr, "offset=%08x\n", offset);
-
-       if (offset < 0
-           || offset > rmesa->radeon.radeonScreen->gartTextures.size)
-               return ~0;
-       else
-               return rmesa->radeon.radeonScreen->gart_texture_offset + offset;
-}
 
 void r300InitIoctlFuncs(struct dd_function_table *functions)
 {
        functions->Clear = r300Clear;
        functions->Finish = radeonFinish;
-       functions->Flush = r300Flush;
+       functions->Flush = radeonFlush;
 }
index e1143fb6c3439feb5fc45ed9bab6ee4e9656ba98..3abfa71a6e80f183a0f36f2dec6197bb92311ca9 100644 (file)
@@ -39,22 +39,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r300_context.h"
 #include "radeon_drm.h"
 
-extern GLboolean r300IsGartMemory(r300ContextPtr rmesa,
-                                 const GLvoid * pointer, GLint size);
-
-extern GLuint r300GartOffsetFromVirtual(r300ContextPtr rmesa,
-                                       const GLvoid * pointer);
-
-extern void r300Flush(GLcontext * ctx);
-
-extern void r300ReleaseDmaRegion(r300ContextPtr rmesa,
-                                struct r300_dma_region *region,
-                                const char *caller);
-extern void r300AllocDmaRegion(r300ContextPtr rmesa,
-                              struct r300_dma_region *region, int bytes,
-                              int alignment);
-
 extern void r300InitIoctlFuncs(struct dd_function_table *functions);
 
-extern void r300RefillCurrentDmaRegion(r300ContextPtr rmesa, int size);
 #endif                         /* __R300_IOCTL_H__ */
diff --git a/src/mesa/drivers/dri/r300/r300_mem.c b/src/mesa/drivers/dri/r300/r300_mem.c
deleted file mode 100644 (file)
index f8f9d4f..0000000
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- * Copyright (C) 2005 Aapo Tahkola.
- *
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial
- * portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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 Aapo Tahkola <aet@rasterburn.org>
- */
-
-#include <unistd.h>
-
-#include "r300_context.h"
-#include "r300_cmdbuf.h"
-#include "r300_ioctl.h"
-#include "r300_mem.h"
-#include "radeon_ioctl.h"
-
-#ifdef USER_BUFFERS
-
-static void resize_u_list(r300ContextPtr rmesa)
-{
-       void *temp;
-       int nsize;
-
-       temp = rmesa->rmm->u_list;
-       nsize = rmesa->rmm->u_size * 2;
-
-       rmesa->rmm->u_list = _mesa_malloc(nsize * sizeof(*rmesa->rmm->u_list));
-       _mesa_memset(rmesa->rmm->u_list, 0,
-                    nsize * sizeof(*rmesa->rmm->u_list));
-
-       if (temp) {
-               r300FlushCmdBuf(rmesa, __FUNCTION__);
-
-               _mesa_memcpy(rmesa->rmm->u_list, temp,
-                            rmesa->rmm->u_size * sizeof(*rmesa->rmm->u_list));
-               _mesa_free(temp);
-       }
-
-       rmesa->rmm->u_size = nsize;
-}
-
-void r300_mem_init(r300ContextPtr rmesa)
-{
-       rmesa->rmm = malloc(sizeof(struct r300_memory_manager));
-       memset(rmesa->rmm, 0, sizeof(struct r300_memory_manager));
-
-       rmesa->rmm->u_size = 128;
-       resize_u_list(rmesa);
-}
-
-void r300_mem_destroy(r300ContextPtr rmesa)
-{
-       _mesa_free(rmesa->rmm->u_list);
-       rmesa->rmm->u_list = NULL;
-
-       _mesa_free(rmesa->rmm);
-       rmesa->rmm = NULL;
-}
-
-void *r300_mem_ptr(r300ContextPtr rmesa, int id)
-{
-       assert(id <= rmesa->rmm->u_last);
-       return rmesa->rmm->u_list[id].ptr;
-}
-
-int r300_mem_find(r300ContextPtr rmesa, void *ptr)
-{
-       int i;
-
-       for (i = 1; i < rmesa->rmm->u_size + 1; i++)
-               if (rmesa->rmm->u_list[i].ptr &&
-                   ptr >= rmesa->rmm->u_list[i].ptr &&
-                   ptr <
-                   rmesa->rmm->u_list[i].ptr + rmesa->rmm->u_list[i].size)
-                       break;
-
-       if (i < rmesa->rmm->u_size + 1)
-               return i;
-
-       fprintf(stderr, "%p failed\n", ptr);
-       return 0;
-}
-
-//#define MM_DEBUG
-int r300_mem_alloc(r300ContextPtr rmesa, int alignment, int size)
-{
-       drm_radeon_mem_alloc_t alloc;
-       int offset = 0, ret;
-       int i, free = -1;
-       int done_age;
-       drm_radeon_mem_free_t memfree;
-       int tries = 0;
-       static int bytes_wasted = 0, allocated = 0;
-
-       if (size < 4096)
-               bytes_wasted += 4096 - size;
-
-       allocated += size;
-
-#if 0
-       static int t = 0;
-       if (t != time(NULL)) {
-               t = time(NULL);
-               fprintf(stderr, "slots used %d, wasted %d kb, allocated %d\n",
-                       rmesa->rmm->u_last, bytes_wasted / 1024,
-                       allocated / 1024);
-       }
-#endif
-
-       memfree.region = RADEON_MEM_REGION_GART;
-
-      again:
-
-       done_age = radeonGetAge((radeonContextPtr) rmesa);
-
-       if (rmesa->rmm->u_last + 1 >= rmesa->rmm->u_size)
-               resize_u_list(rmesa);
-
-       for (i = rmesa->rmm->u_last + 1; i > 0; i--) {
-               if (rmesa->rmm->u_list[i].ptr == NULL) {
-                       free = i;
-                       continue;
-               }
-
-               if (rmesa->rmm->u_list[i].h_pending == 0 &&
-                   rmesa->rmm->u_list[i].pending
-                   && rmesa->rmm->u_list[i].age <= done_age) {
-                       memfree.region_offset =
-                           (char *)rmesa->rmm->u_list[i].ptr -
-                           (char *)rmesa->radeon.radeonScreen->gartTextures.
-                           map;
-
-                       ret =
-                           drmCommandWrite(rmesa->radeon.radeonScreen->
-                                           driScreen->fd, DRM_RADEON_FREE,
-                                           &memfree, sizeof(memfree));
-
-                       if (ret) {
-                               fprintf(stderr, "Failed to free at %p\n",
-                                       rmesa->rmm->u_list[i].ptr);
-                               fprintf(stderr, "ret = %s\n", strerror(-ret));
-                               exit(1);
-                       } else {
-#ifdef MM_DEBUG
-                               fprintf(stderr, "really freed %d at age %x\n",
-                                       i,
-                                       radeonGetAge((radeonContextPtr) rmesa));
-#endif
-                               if (i == rmesa->rmm->u_last)
-                                       rmesa->rmm->u_last--;
-
-                               if (rmesa->rmm->u_list[i].size < 4096)
-                                       bytes_wasted -=
-                                           4096 - rmesa->rmm->u_list[i].size;
-
-                               allocated -= rmesa->rmm->u_list[i].size;
-                               rmesa->rmm->u_list[i].pending = 0;
-                               rmesa->rmm->u_list[i].ptr = NULL;
-                               free = i;
-                       }
-               }
-       }
-       rmesa->rmm->u_head = i;
-
-       if (free == -1) {
-               WARN_ONCE("Ran out of slots!\n");
-               //usleep(100);
-               r300FlushCmdBuf(rmesa, __FUNCTION__);
-               tries++;
-               if (tries > 100) {
-                       WARN_ONCE("Ran out of slots!\n");
-                       exit(1);
-               }
-               goto again;
-       }
-
-       alloc.region = RADEON_MEM_REGION_GART;
-       alloc.alignment = alignment;
-       alloc.size = size;
-       alloc.region_offset = &offset;
-
-       ret =
-           drmCommandWriteRead(rmesa->radeon.dri.fd, DRM_RADEON_ALLOC, &alloc,
-                               sizeof(alloc));
-       if (ret) {
-#if 0
-               WARN_ONCE("Ran out of mem!\n");
-               r300FlushCmdBuf(rmesa, __FUNCTION__);
-               //usleep(100);
-               tries2++;
-               tries = 0;
-               if (tries2 > 100) {
-                       WARN_ONCE("Ran out of GART memory!\n");
-                       exit(1);
-               }
-               goto again;
-#else
-               WARN_ONCE
-                   ("Ran out of GART memory (for %d)!\nPlease consider adjusting GARTSize option.\n",
-                    size);
-               return 0;
-#endif
-       }
-
-       i = free;
-
-       if (i > rmesa->rmm->u_last)
-               rmesa->rmm->u_last = i;
-
-       rmesa->rmm->u_list[i].ptr =
-           ((GLubyte *) rmesa->radeon.radeonScreen->gartTextures.map) + offset;
-       rmesa->rmm->u_list[i].size = size;
-       rmesa->rmm->u_list[i].age = 0;
-       //fprintf(stderr, "alloc %p at id %d\n", rmesa->rmm->u_list[i].ptr, i);
-
-#ifdef MM_DEBUG
-       fprintf(stderr, "allocated %d at age %x\n", i,
-               radeonGetAge((radeonContextPtr) rmesa));
-#endif
-
-       return i;
-}
-
-void r300_mem_use(r300ContextPtr rmesa, int id)
-{
-       uint64_t ull;
-#ifdef MM_DEBUG
-       fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id,
-               radeonGetAge((radeonContextPtr) rmesa));
-#endif
-       drm_r300_cmd_header_t *cmd;
-
-       assert(id <= rmesa->rmm->u_last);
-
-       if (id == 0)
-               return;
-
-       cmd =
-           (drm_r300_cmd_header_t *) r300AllocCmdBuf(rmesa,
-                                                     2 + sizeof(ull) / 4,
-                                                     __FUNCTION__);
-       cmd[0].scratch.cmd_type = R300_CMD_SCRATCH;
-       cmd[0].scratch.reg = R300_MEM_SCRATCH;
-       cmd[0].scratch.n_bufs = 1;
-       cmd[0].scratch.flags = 0;
-       cmd++;
-
-       ull = (uint64_t) (intptr_t) & rmesa->rmm->u_list[id].age;
-       _mesa_memcpy(cmd, &ull, sizeof(ull));
-       cmd += sizeof(ull) / 4;
-
-       cmd[0].u = /*id */ 0;
-
-       LOCK_HARDWARE(&rmesa->radeon);  /* Protect from DRM. */
-       rmesa->rmm->u_list[id].h_pending++;
-       UNLOCK_HARDWARE(&rmesa->radeon);
-}
-
-unsigned long r300_mem_offset(r300ContextPtr rmesa, int id)
-{
-       unsigned long offset;
-
-       assert(id <= rmesa->rmm->u_last);
-
-       offset = (char *)rmesa->rmm->u_list[id].ptr -
-           (char *)rmesa->radeon.radeonScreen->gartTextures.map;
-       offset += rmesa->radeon.radeonScreen->gart_texture_offset;
-
-       return offset;
-}
-
-void *r300_mem_map(r300ContextPtr rmesa, int id, int access)
-{
-#ifdef MM_DEBUG
-       fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id,
-               radeonGetAge((radeonContextPtr) rmesa));
-#endif
-       void *ptr;
-       int tries = 0;
-
-       assert(id <= rmesa->rmm->u_last);
-
-       if (access == R300_MEM_R) {
-
-               if (rmesa->rmm->u_list[id].mapped == 1)
-                       WARN_ONCE("buffer %d already mapped\n", id);
-
-               rmesa->rmm->u_list[id].mapped = 1;
-               ptr = r300_mem_ptr(rmesa, id);
-
-               return ptr;
-       }
-
-       if (rmesa->rmm->u_list[id].h_pending)
-               r300FlushCmdBuf(rmesa, __FUNCTION__);
-
-       if (rmesa->rmm->u_list[id].h_pending) {
-               return NULL;
-       }
-
-       while (rmesa->rmm->u_list[id].age >
-              radeonGetAge((radeonContextPtr) rmesa) && tries++ < 1000)
-               usleep(10);
-
-       if (tries >= 1000) {
-               fprintf(stderr, "Idling failed (%x vs %x)\n",
-                       rmesa->rmm->u_list[id].age,
-                       radeonGetAge((radeonContextPtr) rmesa));
-               return NULL;
-       }
-
-       if (rmesa->rmm->u_list[id].mapped == 1)
-               WARN_ONCE("buffer %d already mapped\n", id);
-
-       rmesa->rmm->u_list[id].mapped = 1;
-       ptr = r300_mem_ptr(rmesa, id);
-
-       return ptr;
-}
-
-void r300_mem_unmap(r300ContextPtr rmesa, int id)
-{
-#ifdef MM_DEBUG
-       fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id,
-               radeonGetAge((radeonContextPtr) rmesa));
-#endif
-
-       assert(id <= rmesa->rmm->u_last);
-
-       if (rmesa->rmm->u_list[id].mapped == 0)
-               WARN_ONCE("buffer %d not mapped\n", id);
-
-       rmesa->rmm->u_list[id].mapped = 0;
-}
-
-void r300_mem_free(r300ContextPtr rmesa, int id)
-{
-#ifdef MM_DEBUG
-       fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id,
-               radeonGetAge((radeonContextPtr) rmesa));
-#endif
-
-       assert(id <= rmesa->rmm->u_last);
-
-       if (id == 0)
-               return;
-
-       if (rmesa->rmm->u_list[id].ptr == NULL) {
-               WARN_ONCE("Not allocated!\n");
-               return;
-       }
-
-       if (rmesa->rmm->u_list[id].pending) {
-               WARN_ONCE("%p already pended!\n", rmesa->rmm->u_list[id].ptr);
-               return;
-       }
-
-       rmesa->rmm->u_list[id].pending = 1;
-}
-#endif
diff --git a/src/mesa/drivers/dri/r300/r300_mem.h b/src/mesa/drivers/dri/r300/r300_mem.h
deleted file mode 100644 (file)
index 625a7f6..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef __R300_MEM_H__
-#define __R300_MEM_H__
-
-//#define R300_MEM_PDL 0
-#define R300_MEM_UL 1
-
-#define R300_MEM_R 1
-#define R300_MEM_W 2
-#define R300_MEM_RW (R300_MEM_R | R300_MEM_W)
-
-#define R300_MEM_SCRATCH 2
-
-struct r300_memory_manager {
-       struct {
-               void *ptr;
-               uint32_t size;
-               uint32_t age;
-               uint32_t h_pending;
-               int pending;
-               int mapped;
-       } *u_list;
-       int u_head, u_size, u_last;
-
-};
-
-extern void r300_mem_init(r300ContextPtr rmesa);
-extern void r300_mem_destroy(r300ContextPtr rmesa);
-extern void *r300_mem_ptr(r300ContextPtr rmesa, int id);
-extern int r300_mem_find(r300ContextPtr rmesa, void *ptr);
-extern int r300_mem_alloc(r300ContextPtr rmesa, int alignment, int size);
-extern void r300_mem_use(r300ContextPtr rmesa, int id);
-extern unsigned long r300_mem_offset(r300ContextPtr rmesa, int id);
-extern void *r300_mem_map(r300ContextPtr rmesa, int id, int access);
-extern void r300_mem_unmap(r300ContextPtr rmesa, int id);
-extern void r300_mem_free(r300ContextPtr rmesa, int id);
-
-#endif
index 8f1a6630d5ce9cbd566071a56de06a77ffcbbf66..357c600af974ce87852db6cae3a253ba1a76ed78 100644 (file)
@@ -1467,6 +1467,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #      define R300_TX_FORMAT_3D                   (1 << 25)
 #      define R300_TX_FORMAT_CUBIC_MAP            (2 << 25)
 
+#      define R300_TX_FORMAT_GAMMA                     (1 << 21)
+
        /* gap */
        /* Floating point formats */
        /* Note - hardware supports both 16 and 32 bit floating point */
@@ -1531,6 +1533,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #      define R500_SEL_FILTER4_TC3              (3 << 18)
 
 #define R300_TX_OFFSET_0                    0x4540
+#define R300_TX_OFFSET_1                    0x4544
+#define R300_TX_OFFSET_2                    0x4548
+#define R300_TX_OFFSET_3                    0x454C
+#define R300_TX_OFFSET_4                    0x4550
+#define R300_TX_OFFSET_5                    0x4554
+#define R300_TX_OFFSET_6                    0x4558
+#define R300_TX_OFFSET_7                    0x455C
        /* BEGIN: Guess from R200 */
 #       define R300_TXO_ENDIAN_NO_SWAP           (0 << 0)
 #       define R300_TXO_ENDIAN_BYTE_SWAP         (1 << 0)
@@ -2425,6 +2434,12 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 /* Z Buffer Clear Value */
 #define R300_ZB_DEPTHCLEARVALUE                  0x4f28
 
+#define R300_ZB_ZMASK_OFFSET                     0x4f30
+#define R300_ZB_ZMASK_PITCH                      0x4f34
+#define R300_ZB_ZMASK_WRINDEX                    0x4f38
+#define R300_ZB_ZMASK_DWORD                      0x4f3c
+#define R300_ZB_ZMASK_RDINDEX                    0x4f40
+
 /* Hierarchical Z Memory Offset */
 #define R300_ZB_HIZ_OFFSET                       0x4f44
 
@@ -3165,6 +3180,9 @@ enum {
 #   define R300_W_SRC_RAS                              (1 << 2)
 
 
+/* Packet0 field ordering to write all values to the same reg */
+#define RADEON_ONE_REG_WR        (1 << 15)
+
 /* Draw a primitive from vertex data in arrays loaded via 3D_LOAD_VBPNTR.
  * Two parameter dwords:
  * 0. VAP_VTX_FMT: The first parameter is not written to hardware
index 16ce4a11999b30201628b7b28f41700e20ac9367..1356305a212a451cf33683fdecd9de1a38569158 100644 (file)
@@ -50,6 +50,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  * no bugs...
  */
 
+#include "r300_render.h"
+
 #include "main/glheader.h"
 #include "main/state.h"
 #include "main/imports.h"
@@ -66,16 +68,14 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "tnl/t_vp_build.h"
 #include "radeon_reg.h"
 #include "radeon_macros.h"
-#include "radeon_ioctl.h"
-#include "radeon_state.h"
 #include "r300_context.h"
 #include "r300_ioctl.h"
 #include "r300_state.h"
 #include "r300_reg.h"
 #include "r300_tex.h"
 #include "r300_emit.h"
-#include "r300_fragprog.h"
-extern int future_hw_tcl_on;
+#include "r300_fragprog_common.h"
+#include "r300_swtcl.h"
 
 /**
  * \brief Convert a OpenGL primitive type into a R300 primitive type.
@@ -172,96 +172,187 @@ int r300NumVerts(r300ContextPtr rmesa, int num_verts, int prim)
        return num_verts - verts_off;
 }
 
-static void r300EmitElts(GLcontext * ctx, void *elts, unsigned long n_elts)
+static void r300EmitElts(GLcontext * ctx, unsigned long n_elts)
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       struct r300_dma_region *rvb = &rmesa->state.elt_dma;
        void *out;
+       GLuint size;
 
-       if (r300IsGartMemory(rmesa, elts, n_elts * 4)) {
-               rvb->address = rmesa->radeon.radeonScreen->gartTextures.map;
-               rvb->start = ((char *)elts) - rvb->address;
-               rvb->aos_offset =
-                   rmesa->radeon.radeonScreen->gart_texture_offset +
-                   rvb->start;
-               return;
-       } else if (r300IsGartMemory(rmesa, elts, 1)) {
-               WARN_ONCE("Pointer not within GART memory!\n");
-               _mesa_exit(-1);
-       }
+       size = ((rmesa->ind_buf.is_32bit ? 4 : 2) * n_elts + 3) & ~3;
 
-       r300AllocDmaRegion(rmesa, rvb, n_elts * 4, 4);
-       rvb->aos_offset = GET_START(rvb);
-
-       out = rvb->address + rvb->start;
-       memcpy(out, elts, n_elts * 4);
+       radeonAllocDmaRegion(&rmesa->radeon, &rmesa->radeon.tcl.elt_dma_bo,
+                            &rmesa->radeon.tcl.elt_dma_offset, size, 4);
+       radeon_bo_map(rmesa->radeon.tcl.elt_dma_bo, 1);
+       out = rmesa->radeon.tcl.elt_dma_bo->ptr + rmesa->radeon.tcl.elt_dma_offset;
+       memcpy(out, rmesa->ind_buf.ptr, size);
+       radeon_bo_unmap(rmesa->radeon.tcl.elt_dma_bo);
 }
 
-static void r300FireEB(r300ContextPtr rmesa, unsigned long addr,
-                      int vertex_count, int type)
+static void r300FireEB(r300ContextPtr rmesa, int vertex_count, int type)
 {
-       int cmd_reserved = 0;
-       int cmd_written = 0;
-       drm_radeon_cmd_header_t *cmd = NULL;
-
-       start_packet3(CP_PACKET3(R300_PACKET3_3D_DRAW_INDX_2, 0), 0);
-       e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (vertex_count << 16) | type | R300_VAP_VF_CNTL__INDEX_SIZE_32bit);
-
-       start_packet3(CP_PACKET3(R300_PACKET3_INDX_BUFFER, 2), 2);
-       e32(R300_INDX_BUFFER_ONE_REG_WR | (0 << R300_INDX_BUFFER_SKIP_SHIFT) |
-           (R300_VAP_PORT_IDX0 >> 2));
-       e32(addr);
-       e32(vertex_count);
+       BATCH_LOCALS(&rmesa->radeon);
+
+    r300_emit_scissor(rmesa->radeon.glCtx);
+       if (vertex_count > 0) {
+               int size;
+
+               BEGIN_BATCH(10);
+               OUT_BATCH_PACKET3(R300_PACKET3_3D_DRAW_INDX_2, 0);
+               if (rmesa->ind_buf.is_32bit) {
+                       size = vertex_count;
+                       OUT_BATCH(R300_VAP_VF_CNTL__PRIM_WALK_INDICES |
+                         ((vertex_count + 0) << 16) | type |
+                         R300_VAP_VF_CNTL__INDEX_SIZE_32bit);
+               } else {
+                       size = (vertex_count + 1) >> 1;
+                       OUT_BATCH(R300_VAP_VF_CNTL__PRIM_WALK_INDICES |
+                          ((vertex_count + 0) << 16) | type);
+               }
+
+               if (!rmesa->radeon.radeonScreen->kernel_mm) {
+                       OUT_BATCH_PACKET3(R300_PACKET3_INDX_BUFFER, 2);
+                       OUT_BATCH(R300_INDX_BUFFER_ONE_REG_WR | (0 << R300_INDX_BUFFER_SKIP_SHIFT) |
+                                (R300_VAP_PORT_IDX0 >> 2));
+                       OUT_BATCH_RELOC(rmesa->radeon.tcl.elt_dma_offset,
+                                       rmesa->radeon.tcl.elt_dma_bo,
+                                       rmesa->radeon.tcl.elt_dma_offset,
+                                       RADEON_GEM_DOMAIN_GTT, 0, 0);
+                       OUT_BATCH(size);
+               } else {
+                       OUT_BATCH_PACKET3(R300_PACKET3_INDX_BUFFER, 2);
+                       OUT_BATCH(R300_INDX_BUFFER_ONE_REG_WR | (0 << R300_INDX_BUFFER_SKIP_SHIFT) |
+                                (R300_VAP_PORT_IDX0 >> 2));
+                       OUT_BATCH(rmesa->radeon.tcl.elt_dma_offset);
+                       OUT_BATCH(size);
+                       radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
+                                             rmesa->radeon.tcl.elt_dma_bo,
+                                             RADEON_GEM_DOMAIN_GTT, 0, 0);
+               }
+               END_BATCH();
+       }
 }
 
 static void r300EmitAOS(r300ContextPtr rmesa, GLuint nr, GLuint offset)
 {
+       BATCH_LOCALS(&rmesa->radeon);
+       uint32_t voffset;
        int sz = 1 + (nr >> 1) * 3 + (nr & 1) * 2;
        int i;
-       int cmd_reserved = 0;
-       int cmd_written = 0;
-       drm_radeon_cmd_header_t *cmd = NULL;
 
        if (RADEON_DEBUG & DEBUG_VERTS)
                fprintf(stderr, "%s: nr=%d, ofs=0x%08x\n", __FUNCTION__, nr,
                        offset);
 
-       start_packet3(CP_PACKET3(R300_PACKET3_3D_LOAD_VBPNTR, sz - 1), sz - 1);
-       e32(nr);
 
-       for (i = 0; i + 1 < nr; i += 2) {
-               e32((rmesa->state.aos[i].aos_size << 0) |
-                   (rmesa->state.aos[i].aos_stride << 8) |
-                   (rmesa->state.aos[i + 1].aos_size << 16) |
-                   (rmesa->state.aos[i + 1].aos_stride << 24));
+       if (!rmesa->radeon.radeonScreen->kernel_mm) {
+               BEGIN_BATCH(sz+2+(nr * 2));
+               OUT_BATCH_PACKET3(R300_PACKET3_3D_LOAD_VBPNTR, sz - 1);
+               OUT_BATCH(nr);
+
+               for (i = 0; i + 1 < nr; i += 2) {
+                       OUT_BATCH((rmesa->radeon.tcl.aos[i].components << 0) |
+                                 (rmesa->radeon.tcl.aos[i].stride << 8) |
+                                 (rmesa->radeon.tcl.aos[i + 1].components << 16) |
+                                 (rmesa->radeon.tcl.aos[i + 1].stride << 24));
+
+                       voffset =  rmesa->radeon.tcl.aos[i + 0].offset +
+                               offset * 4 * rmesa->radeon.tcl.aos[i + 0].stride;
+                       OUT_BATCH_RELOC(voffset,
+                                       rmesa->radeon.tcl.aos[i].bo,
+                                       voffset,
+                                       RADEON_GEM_DOMAIN_GTT,
+                                       0, 0);
+                       voffset =  rmesa->radeon.tcl.aos[i + 1].offset +
+                         offset * 4 * rmesa->radeon.tcl.aos[i + 1].stride;
+                       OUT_BATCH_RELOC(voffset,
+                                       rmesa->radeon.tcl.aos[i+1].bo,
+                                       voffset,
+                                       RADEON_GEM_DOMAIN_GTT,
+                                       0, 0);
+               }
 
-               e32(rmesa->state.aos[i].aos_offset + offset * 4 * rmesa->state.aos[i].aos_stride);
-               e32(rmesa->state.aos[i + 1].aos_offset + offset * 4 * rmesa->state.aos[i + 1].aos_stride);
-       }
+               if (nr & 1) {
+                       OUT_BATCH((rmesa->radeon.tcl.aos[nr - 1].components << 0) |
+                                 (rmesa->radeon.tcl.aos[nr - 1].stride << 8));
+                       voffset =  rmesa->radeon.tcl.aos[nr - 1].offset +
+                               offset * 4 * rmesa->radeon.tcl.aos[nr - 1].stride;
+                       OUT_BATCH_RELOC(voffset,
+                                       rmesa->radeon.tcl.aos[nr - 1].bo,
+                                       voffset,
+                                       RADEON_GEM_DOMAIN_GTT,
+                                       0, 0);
+               }
+               END_BATCH();
+       } else {
+
+               BEGIN_BATCH(sz+2+(nr * 2));
+               OUT_BATCH_PACKET3(R300_PACKET3_3D_LOAD_VBPNTR, sz - 1);
+               OUT_BATCH(nr);
+
+               for (i = 0; i + 1 < nr; i += 2) {
+                       OUT_BATCH((rmesa->radeon.tcl.aos[i].components << 0) |
+                                 (rmesa->radeon.tcl.aos[i].stride << 8) |
+                                 (rmesa->radeon.tcl.aos[i + 1].components << 16) |
+                                 (rmesa->radeon.tcl.aos[i + 1].stride << 24));
+
+                       voffset =  rmesa->radeon.tcl.aos[i + 0].offset +
+                               offset * 4 * rmesa->radeon.tcl.aos[i + 0].stride;
+                       OUT_BATCH(voffset);
+                       voffset =  rmesa->radeon.tcl.aos[i + 1].offset +
+                               offset * 4 * rmesa->radeon.tcl.aos[i + 1].stride;
+                       OUT_BATCH(voffset);
+               }
 
-       if (nr & 1) {
-               e32((rmesa->state.aos[nr - 1].aos_size << 0) |
-                   (rmesa->state.aos[nr - 1].aos_stride << 8));
-               e32(rmesa->state.aos[nr - 1].aos_offset + offset * 4 * rmesa->state.aos[nr - 1].aos_stride);
+               if (nr & 1) {
+                       OUT_BATCH((rmesa->radeon.tcl.aos[nr - 1].components << 0) |
+                         (rmesa->radeon.tcl.aos[nr - 1].stride << 8));
+                       voffset =  rmesa->radeon.tcl.aos[nr - 1].offset +
+                               offset * 4 * rmesa->radeon.tcl.aos[nr - 1].stride;
+                       OUT_BATCH(voffset);
+               }
+               for (i = 0; i + 1 < nr; i += 2) {
+                       voffset =  rmesa->radeon.tcl.aos[i + 0].offset +
+                               offset * 4 * rmesa->radeon.tcl.aos[i + 0].stride;
+                       radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
+                                             rmesa->radeon.tcl.aos[i+0].bo,
+                                             RADEON_GEM_DOMAIN_GTT,
+                                             0, 0);
+                       voffset =  rmesa->radeon.tcl.aos[i + 1].offset +
+                               offset * 4 * rmesa->radeon.tcl.aos[i + 1].stride;
+                       radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
+                                             rmesa->radeon.tcl.aos[i+1].bo,
+                                             RADEON_GEM_DOMAIN_GTT,
+                                             0, 0);
+               }
+               if (nr & 1) {
+                       voffset =  rmesa->radeon.tcl.aos[nr - 1].offset +
+                               offset * 4 * rmesa->radeon.tcl.aos[nr - 1].stride;
+                       radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
+                                             rmesa->radeon.tcl.aos[nr-1].bo,
+                                             RADEON_GEM_DOMAIN_GTT,
+                                             0, 0);
+               }
+               END_BATCH();
        }
+
 }
 
 static void r300FireAOS(r300ContextPtr rmesa, int vertex_count, int type)
 {
-       int cmd_reserved = 0;
-       int cmd_written = 0;
-       drm_radeon_cmd_header_t *cmd = NULL;
+       BATCH_LOCALS(&rmesa->radeon);
 
-       start_packet3(CP_PACKET3(R300_PACKET3_3D_DRAW_VBUF_2, 0), 0);
-       e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (vertex_count << 16) | type);
+    r300_emit_scissor(rmesa->radeon.glCtx);
+       BEGIN_BATCH(3);
+       OUT_BATCH_PACKET3(R300_PACKET3_3D_DRAW_VBUF_2, 0);
+       OUT_BATCH(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (vertex_count << 16) | type);
+       END_BATCH();
 }
 
-static void r300RunRenderPrimitive(r300ContextPtr rmesa, GLcontext * ctx,
-                                  int start, int end, int prim)
+void r300RunRenderPrimitive(GLcontext * ctx, int start, int end, int prim)
 {
+       r300ContextPtr rmesa = R300_CONTEXT(ctx);
+       BATCH_LOCALS(&rmesa->radeon);
        int type, num_verts;
-       TNLcontext *tnl = TNL_CONTEXT(ctx);
-       struct vertex_buffer *vb = &tnl->vb;
 
        type = r300PrimitiveType(rmesa, prim);
        num_verts = r300NumVerts(rmesa, end - start, prim);
@@ -269,7 +360,13 @@ static void r300RunRenderPrimitive(r300ContextPtr rmesa, GLcontext * ctx,
        if (type < 0 || num_verts <= 0)
                return;
 
-       if (vb->Elts) {
+       /* Make space for at least 64 dwords.
+        * This is supposed to ensure that we can get all rendering
+        * commands into a single command buffer.
+        */
+       rcommonEnsureCmdBufSpace(&rmesa->radeon, 128, __FUNCTION__);
+
+       if (rmesa->ind_buf.ptr) {
                if (num_verts > 65535) {
                        /* not implemented yet */
                        WARN_ONCE("Too many elts\n");
@@ -286,114 +383,142 @@ static void r300RunRenderPrimitive(r300ContextPtr rmesa, GLcontext * ctx,
                 * 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);
+               r300EmitElts(ctx, num_verts);
+               r300EmitAOS(rmesa, rmesa->radeon.tcl.aos_count, start);
+               if (rmesa->radeon.radeonScreen->kernel_mm) {
+                       BEGIN_BATCH_NO_AUTOSTATE(2);
+                       OUT_BATCH_REGSEQ(R300_VAP_VF_MAX_VTX_INDX, 1);
+                       OUT_BATCH(rmesa->radeon.tcl.aos[0].count);
+                       END_BATCH();
+               }
+               r300FireEB(rmesa, num_verts, type);
        } else {
-               r300EmitAOS(rmesa, rmesa->state.aos_count, start);
+               r300EmitAOS(rmesa, rmesa->radeon.tcl.aos_count, start);
                r300FireAOS(rmesa, num_verts, type);
        }
+       COMMIT_BATCH();
 }
 
-static GLboolean r300RunRender(GLcontext * ctx,
-                              struct tnl_pipeline_stage *stage)
+static void r300RunRender(GLcontext * ctx, struct tnl_pipeline_stage *stage)
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
        int i;
        TNLcontext *tnl = TNL_CONTEXT(ctx);
        struct vertex_buffer *vb = &tnl->vb;
 
-
        if (RADEON_DEBUG & DEBUG_PRIMS)
                fprintf(stderr, "%s\n", __FUNCTION__);
 
        r300UpdateShaders(rmesa);
-       if (r300EmitArrays(ctx))
-               return GL_TRUE;
+       r300EmitArrays(ctx);
 
        r300UpdateShaderStates(rmesa);
 
        r300EmitCacheFlush(rmesa);
-       r300EmitState(rmesa);
+       radeonEmitState(&rmesa->radeon);
 
        for (i = 0; i < vb->PrimitiveCount; i++) {
                GLuint prim = _tnl_translate_prim(&vb->Primitive[i]);
                GLuint start = vb->Primitive[i].start;
                GLuint end = vb->Primitive[i].start + vb->Primitive[i].count;
-               r300RunRenderPrimitive(rmesa, ctx, start, end, prim);
+               r300RunRenderPrimitive(ctx, start, end, prim);
        }
 
        r300EmitCacheFlush(rmesa);
 
-#ifdef USER_BUFFERS
-       r300UseArrays(ctx);
-#endif
+       radeonReleaseArrays(ctx, ~0);
+}
 
-       r300ReleaseArrays(ctx);
 
-       return GL_FALSE;
+static const char *getFallbackString(uint32_t bit)
+{
+       switch (bit) {
+               case R300_FALLBACK_VERTEX_PROGRAM :
+                       return "vertex program";
+               case R300_FALLBACK_LINE_SMOOTH:
+                       return "smooth lines";
+               case R300_FALLBACK_POINT_SMOOTH:
+                       return "smooth points";
+               case R300_FALLBACK_POLYGON_SMOOTH:
+                       return "smooth polygons";
+               case R300_FALLBACK_LINE_STIPPLE:
+                       return "line stipple";
+               case R300_FALLBACK_POLYGON_STIPPLE:
+                       return "polygon stipple";
+               case R300_FALLBACK_STENCIL_TWOSIDE:
+                       return "two-sided stencil";
+               case R300_FALLBACK_RENDER_MODE:
+                       return "render mode != GL_RENDER";
+               case R300_FALLBACK_FRAGMENT_PROGRAM:
+                       return "fragment program";
+               case R300_FALLBACK_AOS_LIMIT:
+                       return "aos limit";
+               case R300_FALLBACK_INVALID_BUFFERS:
+                       return "invalid buffers";
+               default:
+                       return "unknown";
+       }
 }
 
-#define FALLBACK_IF(expr)                                              \
-       do {                                                            \
-               if (expr) {                                             \
-                       if (1 || RADEON_DEBUG & DEBUG_FALLBACKS)        \
-                               WARN_ONCE("Software fallback:%s\n",     \
-                                         #expr);                       \
-                       return R300_FALLBACK_RAST;                      \
-               }                                                       \
-       } while(0)
-
-static int r300Fallback(GLcontext * ctx)
+void r300SwitchFallback(GLcontext *ctx, uint32_t bit, GLboolean mode)
 {
-       r300ContextPtr r300 = R300_CONTEXT(ctx);
-       const unsigned back = ctx->Stencil._BackFace;
-
-       /* 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) {
-                               r500TranslateFragmentShader(r300, fp);
-                               FALLBACK_IF(!fp->translated);
+       TNLcontext *tnl = TNL_CONTEXT(ctx);
+       r300ContextPtr rmesa = R300_CONTEXT(ctx);
+       uint32_t old_fallback = rmesa->fallback;
+       static uint32_t fallback_warn = 0;
+       
+       if (mode) {
+               if ((fallback_warn & bit) == 0) {
+                       _mesa_fprintf(stderr, "WARNING! Falling back to software for %s\n", getFallbackString(bit));
+                       fallback_warn |= bit;
+               }
+               rmesa->fallback |= bit;
+
+               /* update only if we change from no tcl fallbacks to some tcl fallbacks */
+               if (rmesa->options.hw_tcl_enabled) {
+                       if (((old_fallback & R300_TCL_FALLBACK_MASK) == 0) &&
+                               ((bit & R300_TCL_FALLBACK_MASK) > 0)) {
+                               R300_STATECHANGE(rmesa, vap_cntl_status);
+                               rmesa->hw.vap_cntl_status.cmd[1] |= R300_VAP_TCL_BYPASS;
                        }
                }
+
+               /* update only if we change from no raster fallbacks to some raster fallbacks */
+               if (((old_fallback & R300_RASTER_FALLBACK_MASK) == 0) &&
+                       ((bit & R300_RASTER_FALLBACK_MASK) > 0)) {
+                       
+                       radeon_firevertices(&rmesa->radeon);
+                       rmesa->radeon.swtcl.RenderIndex = ~0;
+                       _swsetup_Wakeup( ctx );
+               }
        } 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);
+               rmesa->fallback &= ~bit;
+
+               /* update only if we have disabled all tcl fallbacks */
+               if (rmesa->options.hw_tcl_enabled) {
+                       if ((old_fallback & R300_RASTER_FALLBACK_MASK) == bit) {
+                               R300_STATECHANGE(rmesa, vap_cntl_status);
+                               rmesa->hw.vap_cntl_status.cmd[1] &= ~R300_VAP_TCL_BYPASS;
                        }
                }
-       }
 
-       FALLBACK_IF(ctx->RenderMode != GL_RENDER);
-
-       /* If GL_EXT_stencil_two_side is disabled, this fallback check can
-        * be removed.
-        */
-       FALLBACK_IF(ctx->Stencil.Ref[0] != ctx->Stencil.Ref[back]
-                   || ctx->Stencil.ValueMask[0] !=
-                   ctx->Stencil.ValueMask[back]
-                   || ctx->Stencil.WriteMask[0] !=
-                   ctx->Stencil.WriteMask[back]);
-
-       if (ctx->Extensions.NV_point_sprite || ctx->Extensions.ARB_point_sprite)
-               FALLBACK_IF(ctx->Point.PointSprite);
-
-       if (!r300->disable_lowimpact_fallback) {
-               FALLBACK_IF(ctx->Polygon.StippleFlag);
-               FALLBACK_IF(ctx->Multisample._Enabled);
-               FALLBACK_IF(ctx->Line.StippleFlag);
-               FALLBACK_IF(ctx->Line.SmoothFlag);
-               FALLBACK_IF(ctx->Point.SmoothFlag);
+               /* update only if we have disabled all raster fallbacks */
+               if ((old_fallback & R300_RASTER_FALLBACK_MASK) == bit) {
+                       _swrast_flush( ctx );
+                       
+                       tnl->Driver.Render.Start = r300RenderStart;
+                       tnl->Driver.Render.Finish = r300RenderFinish;
+                       tnl->Driver.Render.PrimitiveNotify = r300RenderPrimitive;
+                       tnl->Driver.Render.ResetLineStipple = r300ResetLineStipple;
+                       tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+                       tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+                       tnl->Driver.Render.Interp = _tnl_interp;
+                       
+                       _tnl_invalidate_vertex_state( ctx, ~0 );
+                       _tnl_invalidate_vertices( ctx, ~0 );
+               }
        }
-
-       return R300_FALLBACK_NONE;
+       
 }
 
 static GLboolean r300RunNonTCLRender(GLcontext * ctx,
@@ -404,43 +529,15 @@ static GLboolean r300RunNonTCLRender(GLcontext * ctx,
        if (RADEON_DEBUG & DEBUG_PRIMS)
                fprintf(stderr, "%s\n", __FUNCTION__);
 
-       if (r300Fallback(ctx) >= R300_FALLBACK_RAST)
-               return GL_TRUE;
-
-       if (!(rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL))
-               return GL_TRUE;
-
-       return r300RunRender(ctx, stage);
-}
-
-static GLboolean r300RunTCLRender(GLcontext * ctx,
-                                 struct tnl_pipeline_stage *stage)
-{
-       r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       struct r300_vertex_program *vp;
-
-       hw_tcl_on = future_hw_tcl_on;
-
-       if (RADEON_DEBUG & DEBUG_PRIMS)
-               fprintf(stderr, "%s\n", __FUNCTION__);
-
-       if (hw_tcl_on == GL_FALSE)
+       if (rmesa->fallback & R300_RASTER_FALLBACK_MASK)
                return GL_TRUE;
 
-       if (r300Fallback(ctx) >= R300_FALLBACK_TCL) {
-               hw_tcl_on = GL_FALSE;
+       if (rmesa->options.hw_tcl_enabled == GL_FALSE)
                return GL_TRUE;
-       }
-
-       r300UpdateShaders(rmesa);
 
-       vp = (struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx);
-       if (vp->native == GL_FALSE) {
-               hw_tcl_on = GL_FALSE;
-               return GL_TRUE;
-       }
+       r300RunRender(ctx, stage);
 
-       return r300RunRender(ctx, stage);
+       return GL_FALSE;
 }
 
 const struct tnl_pipeline_stage _r300_render_stage = {
@@ -451,12 +548,3 @@ const struct tnl_pipeline_stage _r300_render_stage = {
        NULL,
        r300RunNonTCLRender
 };
-
-const struct tnl_pipeline_stage _r300_tcl_stage = {
-       "r300 Hardware Transform, Clipping and Lighting",
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       r300RunTCLRender
-};
diff --git a/src/mesa/drivers/dri/r300/r300_render.h b/src/mesa/drivers/dri/r300/r300_render.h
new file mode 100644 (file)
index 0000000..ec78547
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2009 Maciej Cencora <m.cencora@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.
+ *
+ */
+
+#ifndef __R300_RENDER_H__
+#define __R300_RENDER_H__
+
+#include "main/mtypes.h"
+
+#define R300_FALLBACK_VERTEX_PROGRAM    (1 << 0)
+#define R300_TCL_FALLBACK_MASK           0x0000ffff
+
+#define R300_FALLBACK_LINE_SMOOTH       (1 << 16)
+#define R300_FALLBACK_POINT_SMOOTH      (1 << 17)
+#define R300_FALLBACK_POLYGON_SMOOTH    (1 << 18)
+#define R300_FALLBACK_LINE_STIPPLE      (1 << 19)
+#define R300_FALLBACK_POLYGON_STIPPLE   (1 << 20)
+#define R300_FALLBACK_STENCIL_TWOSIDE   (1 << 21)
+#define R300_FALLBACK_RENDER_MODE       (1 << 22)
+#define R300_FALLBACK_FRAGMENT_PROGRAM  (1 << 23)
+#define R300_FALLBACK_AOS_LIMIT         (1 << 30)
+#define R300_FALLBACK_INVALID_BUFFERS   (1 << 31)
+#define R300_RASTER_FALLBACK_MASK        0xffff0000
+
+#define MASK_XYZW (R300_WRITE_ENA_X | R300_WRITE_ENA_Y | R300_WRITE_ENA_Z | R300_WRITE_ENA_W)
+#define MASK_X R300_WRITE_ENA_X
+#define MASK_Y R300_WRITE_ENA_Y
+#define MASK_Z R300_WRITE_ENA_Z
+#define MASK_W R300_WRITE_ENA_W
+
+#if SWIZZLE_X != R300_INPUT_ROUTE_SELECT_X || \
+    SWIZZLE_Y != R300_INPUT_ROUTE_SELECT_Y || \
+    SWIZZLE_Z != R300_INPUT_ROUTE_SELECT_Z || \
+    SWIZZLE_W != R300_INPUT_ROUTE_SELECT_W || \
+    SWIZZLE_ZERO != R300_INPUT_ROUTE_SELECT_ZERO || \
+    SWIZZLE_ONE != R300_INPUT_ROUTE_SELECT_ONE
+#error Cannot change these!
+#endif
+
+extern const struct tnl_pipeline_stage _r300_render_stage;
+
+extern void r300SwitchFallback(GLcontext *ctx, uint32_t bit, GLboolean mode);
+
+extern void r300RunRenderPrimitive(GLcontext * ctx, int start, int end, int prim);
+
+#endif
index f30fd986e0f0c1029b60eb9cd7158be259433704..0133b8379664abb392ae02bb70ab4072f173a7ff 100644 (file)
@@ -1,18 +1,42 @@
+/*
+ * Copyright 2009 Maciej Cencora <m.cencora@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 "main/glheader.h"
 
 #include "shader/program.h"
 #include "tnl/tnl.h"
 #include "r300_context.h"
-#include "r300_fragprog.h"
+#include "r300_fragprog_common.h"
 
 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 *r300_fp;
-       struct r500_fragment_program *r500_fp;
+       struct r300_fragment_program *fp;
 
        switch (target) {
        case GL_VERTEX_STATE_PROGRAM_NV:
@@ -20,28 +44,12 @@ static struct gl_program *r300NewProgram(GLcontext * ctx, GLenum target,
                vp = CALLOC_STRUCT(r300_vertex_program_cont);
                return _mesa_init_vertex_program(ctx, &vp->mesa_program,
                                                 target, id);
-       case GL_FRAGMENT_PROGRAM_ARB:
-               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:
-               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);
-               }
+       case GL_FRAGMENT_PROGRAM_ARB:
+               fp = CALLOC_STRUCT(r300_fragment_program);
+               return _mesa_init_fragment_program(ctx, &fp->Base, target, id);
+
        default:
                _mesa_problem(ctx, "Bad target in r300NewProgram");
        }
@@ -57,20 +65,15 @@ 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 *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:
-               if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515)
-                       r500_fp->translated = GL_FALSE;
-               else
-                       r300_fp->translated = GL_FALSE;
+               r300_fp->translated = GL_FALSE;
                break;
        }
 
@@ -81,7 +84,14 @@ r300ProgramStringNotify(GLcontext * ctx, GLenum target, struct gl_program *prog)
 static GLboolean
 r300IsProgramNative(GLcontext * ctx, GLenum target, struct gl_program *prog)
 {
-       return GL_TRUE;
+       if (target == GL_FRAGMENT_PROGRAM_ARB) {
+               struct r300_fragment_program *fp = (struct r300_fragment_program *)prog;
+               if (!fp->translated)
+                       r300TranslateFragmentShader(ctx, &fp->Base);
+
+               return !fp->error;
+       } else
+               return GL_TRUE;
 }
 
 void r300InitShaderFuncs(struct dd_function_table *functions)
index 79f0b3625ca8228ebd6b9a722fc3d2b5e6f445e3..c0eda977db83d4848d21017a7bba23c776e1489c 100644 (file)
@@ -42,6 +42,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/macros.h"
 #include "main/context.h"
 #include "main/dd.h"
+#include "main/framebuffer.h"
 #include "main/simple_list.h"
 #include "main/api_arrayelt.h"
 #include "main/texformat.h"
@@ -52,22 +53,22 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "shader/prog_statevars.h"
 #include "vbo/vbo.h"
 #include "tnl/tnl.h"
+#include "tnl/t_vp_build.h"
 
-#include "radeon_ioctl.h"
-#include "radeon_state.h"
 #include "r300_context.h"
 #include "r300_ioctl.h"
 #include "r300_state.h"
 #include "r300_reg.h"
 #include "r300_emit.h"
-#include "r300_fragprog.h"
 #include "r300_tex.h"
+#include "r300_fragprog_common.h"
+#include "r300_fragprog.h"
+#include "r500_fragprog.h"
+#include "r300_render.h"
+#include "r300_vertprog.h"
 
 #include "drirenderbuffer.h"
 
-extern int future_hw_tcl_on;
-extern void _tnl_UpdateFixedFunctionProgram(GLcontext * ctx);
-
 static void r300BlendColor(GLcontext * ctx, const GLfloat cf[4])
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
@@ -366,7 +367,7 @@ static void r300ClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *eq )
        GLint *ip;
 
        /* no VAP UCP on non-TCL chipsets */
-       if (!(rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL))
+       if (!rmesa->options.hw_tcl_enabled)
                        return;
 
        p = (GLint) plane - (GLint) GL_CLIP_PLANE0;
@@ -385,7 +386,7 @@ static void r300SetClipPlaneState(GLcontext * ctx, GLenum cap, GLboolean state)
        GLuint p;
 
        /* no VAP UCP on non-TCL chipsets */
-       if (!(r300->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL))
+       if (!r300->options.hw_tcl_enabled)
                return;
 
        p = cap - GL_CLIP_PLANE0;
@@ -451,24 +452,16 @@ static void r300SetPolygonOffsetState(GLcontext * ctx, GLboolean state)
 
 static GLboolean current_fragment_program_writes_depth(GLcontext* ctx)
 {
-       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       struct r300_fragment_program *fp = (struct r300_fragment_program *) ctx->FragmentProgram._Current;
 
-       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);
-       }
+       return (fp && fp->writes_depth);
 }
 
 static void r300SetEarlyZState(GLcontext * ctx)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
        GLuint topZ = R300_ZTOP_ENABLE;
+       GLuint w_fmt, fgdepthsrc;
 
        if (ctx->Color.AlphaEnabled && ctx->Color.AlphaFunc != GL_ALWAYS)
                topZ = R300_ZTOP_DISABLE;
@@ -485,6 +478,26 @@ static void r300SetEarlyZState(GLcontext * ctx)
                R300_STATECHANGE(r300, zstencil_format);
                r300->hw.zstencil_format.cmd[2] = topZ;
        }
+
+       /* w_fmt value is set to get best performance
+       * see p.130 R5xx 3D acceleration guide v1.3 */
+       if (current_fragment_program_writes_depth(ctx)) {
+               fgdepthsrc = R300_FG_DEPTH_SRC_SHADER;
+               w_fmt = R300_W_FMT_W24 | R300_W_SRC_US;
+       } else {
+               fgdepthsrc = R300_FG_DEPTH_SRC_SCAN;
+               w_fmt = R300_W_FMT_W0 | R300_W_SRC_US;
+       }
+
+       if (w_fmt != r300->hw.us_out_fmt.cmd[5]) {
+               R300_STATECHANGE(r300, us_out_fmt);
+               r300->hw.us_out_fmt.cmd[5] = w_fmt;
+       }
+
+       if (fgdepthsrc != r300->hw.fg_depth_src.cmd[1]) {
+               R300_STATECHANGE(r300, fg_depth_src);
+               r300->hw.fg_depth_src.cmd[1] = fgdepthsrc;
+       }
 }
 
 static void r300SetAlphaState(GLcontext * ctx)
@@ -535,8 +548,6 @@ static void r300SetAlphaState(GLcontext * ctx)
        R300_STATECHANGE(r300, at);
        r300->hw.at.cmd[R300_AT_ALPHA_TEST] = pp_misc;
        r300->hw.at.cmd[R300_AT_UNKNOWN] = 0;
-
-       r300SetEarlyZState(ctx);
 }
 
 static void r300AlphaFunc(GLcontext * ctx, GLenum func, GLfloat ref)
@@ -584,15 +595,35 @@ static void r300SetDepthState(GLcontext * ctx)
                r300->hw.zs.cmd[R300_ZS_CNTL_1] |=
                    translate_func(ctx->Depth.Func) << R300_Z_FUNC_SHIFT;
        }
+}
 
-       r300SetEarlyZState(ctx);
+static void r300CatchStencilFallback(GLcontext *ctx)
+{
+       const unsigned back = ctx->Stencil._BackFace;
+
+       if (ctx->Stencil._Enabled && (ctx->Stencil.Ref[0] != ctx->Stencil.Ref[back]
+               || ctx->Stencil.ValueMask[0] != ctx->Stencil.ValueMask[back]
+               || ctx->Stencil.WriteMask[0] != ctx->Stencil.WriteMask[back])) {
+               r300SwitchFallback(ctx, R300_FALLBACK_STENCIL_TWOSIDE, GL_TRUE);
+       } else {
+               r300SwitchFallback(ctx, R300_FALLBACK_STENCIL_TWOSIDE, GL_FALSE);
+       }
 }
 
 static void r300SetStencilState(GLcontext * ctx, GLboolean state)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
+       GLboolean hw_stencil = GL_FALSE;
 
-       if (r300->state.stencil.hw_stencil) {
+       r300CatchStencilFallback(ctx);
+
+       if (ctx->DrawBuffer) {
+               struct radeon_renderbuffer *rrbStencil
+                       = radeon_get_renderbuffer(ctx->DrawBuffer, BUFFER_STENCIL);
+               hw_stencil = (rrbStencil && rrbStencil->bo);
+       }
+
+       if (hw_stencil) {
                R300_STATECHANGE(r300, zs);
                if (state) {
                        r300->hw.zs.cmd[R300_ZS_CNTL_0] |=
@@ -601,10 +632,6 @@ static void r300SetStencilState(GLcontext * ctx, GLboolean state)
                        r300->hw.zs.cmd[R300_ZS_CNTL_0] &=
                            ~R300_STENCIL_ENABLE;
                }
-       } else {
-#if R200_MERGED
-               FALLBACK(&r300->radeon, RADEON_FALLBACK_STENCIL, state);
-#endif
        }
 }
 
@@ -737,7 +764,12 @@ static void r300ColorMask(GLcontext * ctx,
 static void r300PointSize(GLcontext * ctx, GLfloat size)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
-        /* same size limits for AA, non-AA points */
+
+       /* We need to clamp to user defined range here, because
+        * the HW clamping happens only for per vertex point size. */
+       size = CLAMP(size, ctx->Point.MinSize, ctx->Point.MaxSize);
+
+       /* same size limits for AA, non-AA points */
        size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize);
 
        R300_STATECHANGE(r300, ps);
@@ -830,29 +862,33 @@ static void r300ShadeModel(GLcontext * ctx, GLenum mode)
 
        R300_STATECHANGE(rmesa, shade);
        rmesa->hw.shade.cmd[1] = 0x00000002;
+       R300_STATECHANGE(rmesa, shade2);
        switch (mode) {
        case GL_FLAT:
-               rmesa->hw.shade.cmd[2] = R300_RE_SHADE_MODEL_FLAT;
+               rmesa->hw.shade2.cmd[1] = R300_RE_SHADE_MODEL_FLAT;
                break;
        case GL_SMOOTH:
-               rmesa->hw.shade.cmd[2] = R300_RE_SHADE_MODEL_SMOOTH;
+               rmesa->hw.shade2.cmd[1] = R300_RE_SHADE_MODEL_SMOOTH;
                break;
        default:
                return;
        }
-       rmesa->hw.shade.cmd[3] = 0x00000000;
-       rmesa->hw.shade.cmd[4] = 0x00000000;
+       rmesa->hw.shade2.cmd[2] = 0x00000000;
+       rmesa->hw.shade2.cmd[3] = 0x00000000;
 }
 
 static void r300StencilFuncSeparate(GLcontext * ctx, GLenum face,
                                    GLenum func, GLint ref, GLuint mask)
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       GLuint refmask =
-           ((ctx->Stencil.Ref[0] & 0xff) << R300_STENCILREF_SHIFT)
-            | ((ctx->Stencil.ValueMask[0] & 0xff) << R300_STENCILMASK_SHIFT);
-       const unsigned back = ctx->Stencil._BackFace;
+       GLuint refmask;
        GLuint flag;
+       const unsigned back = ctx->Stencil._BackFace;
+
+       r300CatchStencilFallback(ctx);
+
+       refmask = ((ctx->Stencil.Ref[0] & 0xff) << R300_STENCILREF_SHIFT)
+            | ((ctx->Stencil.ValueMask[0] & 0xff) << R300_STENCILMASK_SHIFT);
 
        R300_STATECHANGE(rmesa, zs);
        rmesa->hw.zs.cmd[R300_ZS_CNTL_0] |= R300_STENCIL_FRONT_BACK;
@@ -880,6 +916,8 @@ static void r300StencilMaskSeparate(GLcontext * ctx, GLenum face, GLuint mask)
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
 
+       r300CatchStencilFallback(ctx);
+
        R300_STATECHANGE(rmesa, zs);
        rmesa->hw.zs.cmd[R300_ZS_CNTL_2] &=
            ~(R300_STENCILREF_MASK <<
@@ -896,6 +934,8 @@ static void r300StencilOpSeparate(GLcontext * ctx, GLenum face,
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
        const unsigned back = ctx->Stencil._BackFace;
 
+       r300CatchStencilFallback(ctx);
+
        R300_STATECHANGE(rmesa, zs);
        /* It is easier to mask what's left.. */
        rmesa->hw.zs.cmd[R300_ZS_CNTL_1] &=
@@ -924,28 +964,32 @@ static void r300StencilOpSeparate(GLcontext * ctx, GLenum face,
  * Window position and viewport transformation
  */
 
-/*
- * To correctly position primitives:
- */
-#define SUBPIXEL_X 0.125
-#define SUBPIXEL_Y 0.125
-
 static void r300UpdateWindow(GLcontext * ctx)
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       __DRIdrawablePrivate *dPriv = rmesa->radeon.dri.drawable;
+       __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
        GLfloat xoffset = dPriv ? (GLfloat) dPriv->x : 0;
        GLfloat yoffset = dPriv ? (GLfloat) dPriv->y + dPriv->h : 0;
        const GLfloat *v = ctx->Viewport._WindowMap.m;
+       const GLfloat depthScale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
+       const GLboolean render_to_fbo = (ctx->DrawBuffer->Name != 0);
+       GLfloat y_scale, y_bias;
+
+       if (render_to_fbo) {
+               y_scale = 1.0;
+               y_bias = 0;
+       } else {
+               y_scale = -1.0;
+               y_bias = yoffset;
+       }
 
        GLfloat sx = v[MAT_SX];
-       GLfloat tx = v[MAT_TX] + xoffset + SUBPIXEL_X;
-       GLfloat sy = -v[MAT_SY];
-       GLfloat ty = (-v[MAT_TY]) + yoffset + SUBPIXEL_Y;
-       GLfloat sz = v[MAT_SZ] * rmesa->state.depth.scale;
-       GLfloat tz = v[MAT_TZ] * rmesa->state.depth.scale;
+       GLfloat tx = v[MAT_TX] + xoffset;
+       GLfloat sy = v[MAT_SY] * y_scale;
+       GLfloat ty = (v[MAT_TY] * y_scale) + y_bias;
+       GLfloat sz = v[MAT_SZ] * depthScale;
+       GLfloat tz = v[MAT_TZ] * depthScale;
 
-       R300_FIREVERTICES(rmesa);
        R300_STATECHANGE(rmesa, vpt);
 
        rmesa->hw.vpt.cmd[R300_VPT_XSCALE] = r300PackFloat32(sx);
@@ -964,6 +1008,8 @@ static void r300Viewport(GLcontext * ctx, GLint x, GLint y,
         * values, or keep the originals hanging around.
         */
        r300UpdateWindow(ctx);
+
+       radeon_viewport(ctx, x, y, width, height);
 }
 
 static void r300DepthRange(GLcontext * ctx, GLclampd nearval, GLclampd farval)
@@ -974,13 +1020,13 @@ static void r300DepthRange(GLcontext * ctx, GLclampd nearval, GLclampd farval)
 void r300UpdateViewportOffset(GLcontext * ctx)
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       __DRIdrawablePrivate *dPriv = ((radeonContextPtr) rmesa)->dri.drawable;
+       __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
        GLfloat xoffset = (GLfloat) dPriv->x;
        GLfloat yoffset = (GLfloat) dPriv->y + dPriv->h;
        const GLfloat *v = ctx->Viewport._WindowMap.m;
 
-       GLfloat tx = v[MAT_TX] + xoffset + SUBPIXEL_X;
-       GLfloat ty = (-v[MAT_TY]) + yoffset + SUBPIXEL_Y;
+       GLfloat tx = v[MAT_TX] + xoffset;
+       GLfloat ty = (-v[MAT_TY]) + yoffset;
 
        if (rmesa->hw.vpt.cmd[R300_VPT_XOFFSET] != r300PackFloat32(tx) ||
            rmesa->hw.vpt.cmd[R300_VPT_YOFFSET] != r300PackFloat32(ty)) {
@@ -996,64 +1042,6 @@ void r300UpdateViewportOffset(GLcontext * ctx)
        radeonUpdateScissor(ctx);
 }
 
-/**
- * Tell the card where to render (offset, pitch).
- * Effected by glDrawBuffer, etc
- */
-void r300UpdateDrawBuffer(GLcontext * ctx)
-{
-       r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       r300ContextPtr r300 = rmesa;
-       struct gl_framebuffer *fb = ctx->DrawBuffer;
-       driRenderbuffer *drb;
-
-       if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
-               /* draw to front */
-               drb =
-                   (driRenderbuffer *) fb->Attachment[BUFFER_FRONT_LEFT].
-                   Renderbuffer;
-       } else if (fb->_ColorDrawBufferIndexes[0] == BUFFER_BACK_LEFT) {
-               /* draw to back */
-               drb =
-                   (driRenderbuffer *) fb->Attachment[BUFFER_BACK_LEFT].
-                   Renderbuffer;
-       } else {
-               /* drawing to multiple buffers, or none */
-               return;
-       }
-
-       assert(drb);
-       assert(drb->flippedPitch);
-
-       R300_STATECHANGE(rmesa, cb);
-
-       r300->hw.cb.cmd[R300_CB_OFFSET] = drb->flippedOffset +  //r300->radeon.state.color.drawOffset +
-           r300->radeon.radeonScreen->fbLocation;
-       r300->hw.cb.cmd[R300_CB_PITCH] = drb->flippedPitch;     //r300->radeon.state.color.drawPitch;
-
-       if (r300->radeon.radeonScreen->cpp == 4)
-               r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_FORMAT_ARGB8888;
-       else
-               r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_FORMAT_RGB565;
-
-       if (r300->radeon.sarea->tiling_enabled)
-               r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_TILE_ENABLE;
-#if 0
-       R200_STATECHANGE(rmesa, ctx);
-
-       /* Note: we used the (possibly) page-flipped values */
-       rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET]
-           = ((drb->flippedOffset + rmesa->r200Screen->fbLocation)
-              & R200_COLOROFFSET_MASK);
-       rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = drb->flippedPitch;
-
-       if (rmesa->sarea->tiling_enabled) {
-               rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |=
-                   R200_COLOR_TILE_ENABLE;
-       }
-#endif
-}
-
 static void
 r300FetchStateParameter(GLcontext * ctx,
                        const gl_state_index state[STATE_LENGTH],
@@ -1064,12 +1052,14 @@ r300FetchStateParameter(GLcontext * ctx,
        switch (state[0]) {
        case STATE_INTERNAL:
                switch (state[1]) {
-               case STATE_R300_WINDOW_DIMENSION:
-                       value[0] = r300->radeon.dri.drawable->w * 0.5f; /* width*0.5 */
-                       value[1] = r300->radeon.dri.drawable->h * 0.5f; /* height*0.5 */
-                       value[2] = 0.5F;        /* for moving range [-1 1] -> [0 1] */
-                       value[3] = 1.0F;        /* not used */
-                       break;
+               case STATE_R300_WINDOW_DIMENSION: {
+                               __DRIdrawablePrivate * drawable = radeon_get_drawable(&r300->radeon);
+                               value[0] = drawable->w * 0.5f;  /* width*0.5 */
+                               value[1] = drawable->h * 0.5f;  /* height*0.5 */
+                               value[2] = 0.5F;        /* for moving range [-1 1] -> [0 1] */
+                               value[3] = 1.0F;        /* not used */
+                               break;
+                       }
 
                case STATE_R300_TEXRECT_FACTOR:{
                                struct gl_texture_object *t =
@@ -1109,14 +1099,14 @@ void r300UpdateStateParameters(GLcontext * ctx, GLuint new_state)
        struct gl_program_parameter_list *paramList;
        GLuint i;
 
-       if (!(new_state & (_NEW_BUFFERS | _NEW_PROGRAM)))
+       if (!(new_state & (_NEW_BUFFERS | _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS)))
                return;
 
        fp = (struct r300_fragment_program *)ctx->FragmentProgram._Current;
        if (!fp)
                return;
 
-       paramList = fp->mesa_program.Base.Parameters;
+       paramList = fp->Base.Base.Parameters;
 
        if (!paramList)
                return;
@@ -1235,9 +1225,8 @@ 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;
+       struct r300_fragment_program *fp = (struct r300_fragment_program *) ctx->FragmentProgram._Current;
+       struct r300_fragment_program_code *code = &fp->code.r300;
 
        R300_STATECHANGE(r300, fpt);
 
@@ -1271,15 +1260,15 @@ static void r300SetupFragmentShaderTextures(GLcontext *ctx, int *tmu_mappings)
        }
 
        r300->hw.fpt.cmd[R300_FPT_CMD_0] =
-               cmdpacket0(R300_US_TEX_INST_0, code->tex.length);
+               cmdpacket0(r300->radeon.radeonScreen,
+                   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;
+       struct r300_fragment_program *fp = (struct r300_fragment_program *) ctx->FragmentProgram._Current;
+       struct r500_fragment_program_code *code = &fp->code.r500;
 
        /* find all the texture instructions and relocate the texture units */
        for (i = 0; i < code->inst_end + 1; i++) {
@@ -1322,7 +1311,7 @@ static GLuint translate_lod_bias(GLfloat bias)
 static void r300SetupTextures(GLcontext * ctx)
 {
        int i, mtu;
-       struct r300_tex_obj *t;
+       struct radeon_tex_obj *t;
        r300ContextPtr r300 = R300_CONTEXT(ctx);
        int hw_tmu = 0;
        int last_hw_tmu = -1;   /* -1 translates into no setup costs for fields */
@@ -1356,21 +1345,16 @@ static void r300SetupTextures(GLcontext * ctx)
        /* We cannot let disabled tmu offsets pass DRM */
        for (i = 0; i < mtu; i++) {
                if (ctx->Texture.Unit[i]._ReallyEnabled) {
-
-#if 0                          /* Enables old behaviour */
-                       hw_tmu = i;
-#endif
                        tmu_mappings[i] = hw_tmu;
 
-                       t = (r300TexObjPtr) r300->state.texture.unit[i].texobj->DriverData;
-                       /* XXX questionable fix for bug 9170: */
+                       t = radeon_tex_obj(ctx->Texture.Unit[i]._Current);
                        if (!t)
                                continue;
 
-                       if ((t->format & 0xffffff00) == 0xffffff00) {
+                       if ((t->pp_txformat & 0xffffff00) == 0xffffff00) {
                                WARN_ONCE
                                    ("unknown texture format (entry %x) encountered. Help me !\n",
-                                    t->format & 0xff);
+                                    t->pp_txformat & 0xff);
                        }
 
                        if (RADEON_DEBUG & DEBUG_STATE)
@@ -1381,29 +1365,28 @@ static void r300SetupTextures(GLcontext * ctx)
 
                        r300->hw.tex.filter.cmd[R300_TEX_VALUE_0 +
                                                hw_tmu] =
-                           gen_fixed_filter(t->filter) | (hw_tmu << 28);
+                           gen_fixed_filter(t->pp_txfilter) | (hw_tmu << 28);
                        /* 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);
+                               t->pp_txfilter_1 |
+                               translate_lod_bias(ctx->Texture.Unit[i].LodBias + t->base.LodBias);
                        r300->hw.tex.size.cmd[R300_TEX_VALUE_0 + hw_tmu] =
-                           t->size;
+                           t->pp_txsize;
                        r300->hw.tex.format.cmd[R300_TEX_VALUE_0 +
-                                               hw_tmu] = t->format;
+                                               hw_tmu] = t->pp_txformat;
                        r300->hw.tex.pitch.cmd[R300_TEX_VALUE_0 + hw_tmu] =
-                           t->pitch_reg;
-                       r300->hw.tex.offset.cmd[R300_TEX_VALUE_0 +
-                                               hw_tmu] = t->offset;
+                         t->pp_txpitch;
+                       r300->hw.textures[hw_tmu] = t;
 
-                       if (t->offset & R300_TXO_MACRO_TILE) {
+                       if (t->tile_bits & R300_TXO_MACRO_TILE) {
                                WARN_ONCE("macro tiling enabled!\n");
                        }
 
-                       if (t->offset & R300_TXO_MICRO_TILE) {
+                       if (t->tile_bits & R300_TXO_MICRO_TILE) {
                                WARN_ONCE("micro tiling enabled!\n");
                        }
 
@@ -1420,37 +1403,33 @@ static void r300SetupTextures(GLcontext * ctx)
        }
 
        r300->hw.tex.filter.cmd[R300_TEX_CMD_0] =
-           cmdpacket0(R300_TX_FILTER0_0, last_hw_tmu + 1);
+           cmdpacket0(r300->radeon.radeonScreen, 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);
+           cmdpacket0(r300->radeon.radeonScreen, R300_TX_FILTER1_0, last_hw_tmu + 1);
        r300->hw.tex.size.cmd[R300_TEX_CMD_0] =
-           cmdpacket0(R300_TX_SIZE_0, last_hw_tmu + 1);
+           cmdpacket0(r300->radeon.radeonScreen, R300_TX_SIZE_0, last_hw_tmu + 1);
        r300->hw.tex.format.cmd[R300_TEX_CMD_0] =
-           cmdpacket0(R300_TX_FORMAT_0, last_hw_tmu + 1);
+           cmdpacket0(r300->radeon.radeonScreen, R300_TX_FORMAT_0, last_hw_tmu + 1);
        r300->hw.tex.pitch.cmd[R300_TEX_CMD_0] =
-           cmdpacket0(R300_TX_FORMAT2_0, last_hw_tmu + 1);
+           cmdpacket0(r300->radeon.radeonScreen, 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);
+           cmdpacket0(r300->radeon.radeonScreen, R300_TX_OFFSET_0, last_hw_tmu + 1);
        r300->hw.tex.chroma_key.cmd[R300_TEX_CMD_0] =
-           cmdpacket0(R300_TX_CHROMA_KEY_0, last_hw_tmu + 1);
+           cmdpacket0(r300->radeon.radeonScreen, R300_TX_CHROMA_KEY_0, last_hw_tmu + 1);
        r300->hw.tex.border_color.cmd[R300_TEX_CMD_0] =
-           cmdpacket0(R300_TX_BORDER_COLOR_0, last_hw_tmu + 1);
-
-       if (!fp)                /* should only happenen once, just after context is created */
-               return;
+           cmdpacket0(r300->radeon.radeonScreen, R300_TX_BORDER_COLOR_0, last_hw_tmu + 1);
 
        if (r300->radeon.radeonScreen->chip_family < CHIP_FAMILY_RV515) {
-               if (fp->mesa_program.UsesKill && last_hw_tmu < 0) {
+               if (fp->Base.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);
+                               cmdpacket0(r300->radeon.radeonScreen, R300_TX_FILTER0_0, 1);
                }
-               r300SetupFragmentShaderTextures(ctx, tmu_mappings);
-       } else
-               r500SetupFragmentShaderTextures(ctx, tmu_mappings);
+       }
+       r300->vtbl.SetupFragmentShaderTextures(ctx, tmu_mappings);
 
        if (RADEON_DEBUG & DEBUG_STATE)
                fprintf(stderr, "TX_ENABLE: %08x  last_hw_tmu=%d\n",
@@ -1469,26 +1448,21 @@ union r300_outputs_written {
 static void r300SetupRSUnit(GLcontext * ctx)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
-        TNLcontext *tnl = TNL_CONTEXT(ctx);
-       struct vertex_buffer *VB = &tnl->vb;
        union r300_outputs_written OutputsWritten;
        GLuint InputsRead;
        int fp_reg, high_rr;
        int col_ip, tex_ip;
        int rs_tex_count = 0;
-       int i, count, col_fmt;
+       int i, col_fmt, hw_tcl_on;
+
+       hw_tcl_on = r300->options.hw_tcl_enabled;
 
        if (hw_tcl_on)
-               OutputsWritten.vp_outputs = CURRENT_VERTEX_SHADER(ctx)->key.OutputsWritten;
+               OutputsWritten.vp_outputs = r300->selected_vp->key.OutputsWritten;
        else
-               RENDERINPUTS_COPY(OutputsWritten.index_bitset, r300->state.render_inputs_bitset);
+               RENDERINPUTS_COPY(OutputsWritten.index_bitset, r300->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.. */
-       }
+       InputsRead = ctx->FragmentProgram._Current->Base.InputsRead;
 
        R300_STATECHANGE(r300, ri);
        R300_STATECHANGE(r300, rc);
@@ -1507,15 +1481,7 @@ static void r300SetupRSUnit(GLcontext * ctx)
 
        if (InputsRead & FRAG_BIT_COL0) {
                if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten, VERT_RESULT_COL0, _TNL_ATTRIB_COLOR0)) {
-                       count = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->size;
-                       if (count == 4)
-                           col_fmt = R300_RS_COL_FMT_RGBA;
-                       else if (count == 3)
-                           col_fmt = R300_RS_COL_FMT_RGB1;
-                       else
-                           col_fmt = R300_RS_COL_FMT_0001;
-
-                       r300->hw.ri.cmd[R300_RI_INTERP_0 + col_ip] = R300_RS_COL_PTR(col_ip) | R300_RS_COL_FMT(col_fmt);
+                       r300->hw.ri.cmd[R300_RI_INTERP_0 + col_ip] = R300_RS_COL_PTR(col_ip) | R300_RS_COL_FMT(R300_RS_COL_FMT_RGBA);
                        r300->hw.rr.cmd[R300_RR_INST_0 + col_ip] = R300_RS_INST_COL_ID(col_ip) | R300_RS_INST_COL_CN_WRITE | R300_RS_INST_COL_ADDR(fp_reg);
                        InputsRead &= ~FRAG_BIT_COL0;
                        ++col_ip;
@@ -1527,15 +1493,7 @@ static void r300SetupRSUnit(GLcontext * ctx)
 
        if (InputsRead & FRAG_BIT_COL1) {
                if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten, VERT_RESULT_COL1, _TNL_ATTRIB_COLOR1)) {
-                       count = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->size;
-                       if (count == 4)
-                           col_fmt = R300_RS_COL_FMT_RGBA;
-                       else if (count == 3)
-                           col_fmt = R300_RS_COL_FMT_RGB1;
-                       else
-                           col_fmt = R300_RS_COL_FMT_0001;
-
-                       r300->hw.ri.cmd[R300_RI_INTERP_0 + col_ip] = R300_RS_COL_PTR(col_ip) | R300_RS_COL_FMT(col_fmt);
+                       r300->hw.ri.cmd[R300_RI_INTERP_0 + col_ip] = R300_RS_COL_PTR(col_ip) | R300_RS_COL_FMT(R300_RS_COL_FMT_RGBA);
                        r300->hw.rr.cmd[R300_RR_INST_0 + col_ip] = R300_RS_INST_COL_ID(col_ip) | R300_RS_INST_COL_CN_WRITE | R300_RS_INST_COL_ADDR(fp_reg);
                        InputsRead &= ~FRAG_BIT_COL1;
                        ++col_ip;
@@ -1545,6 +1503,7 @@ static void r300SetupRSUnit(GLcontext * ctx)
                }
        }
 
+       /* We always route 4 texcoord components */
        for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
                if (! ( InputsRead & FRAG_BIT_TEX(i) ) )
                    continue;
@@ -1554,33 +1513,27 @@ static void r300SetupRSUnit(GLcontext * ctx)
                    continue;
                }
 
-               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;
-
-               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 + tex_ip] |= swiz | R300_RS_TEX_PTR(rs_tex_count);
+               r300->hw.ri.cmd[R300_RI_INTERP_0 + tex_ip] |= R300_RS_SEL_S(0) | R300_RS_SEL_T(1) | R300_RS_SEL_R(2) | R300_RS_SEL_Q(3) | R300_RS_TEX_PTR(rs_tex_count);
                r300->hw.rr.cmd[R300_RR_INST_0 + tex_ip] |= R300_RS_INST_TEX_ID(tex_ip) | R300_RS_INST_TEX_CN_WRITE | R300_RS_INST_TEX_ADDR(fp_reg);
                InputsRead &= ~(FRAG_BIT_TEX0 << i);
-               rs_tex_count += count;
+               rs_tex_count += 4;
+               ++tex_ip;
+               ++fp_reg;
+       }
+
+       if (InputsRead & FRAG_BIT_WPOS) {
+               r300->hw.ri.cmd[R300_RI_INTERP_0 + tex_ip] |= R300_RS_SEL_S(0) | R300_RS_SEL_T(1) | R300_RS_SEL_R(2) | R300_RS_SEL_Q(3) | R300_RS_TEX_PTR(rs_tex_count);
+               r300->hw.rr.cmd[R300_RR_INST_0 + tex_ip] |= R300_RS_INST_TEX_ID(tex_ip) | R300_RS_INST_TEX_CN_WRITE | R300_RS_INST_TEX_ADDR(fp_reg);
+               InputsRead &= ~FRAG_BIT_WPOS;
+               rs_tex_count += 4;
                ++tex_ip;
                ++fp_reg;
        }
 
        if (InputsRead & FRAG_BIT_FOGC) {
                if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten, VERT_RESULT_FOGC, _TNL_ATTRIB_FOG)) {
-                       r300->hw.ri.cmd[R300_RI_INTERP_0 + tex_ip] |=  R300_RS_SEL_S(0) | R300_RS_SEL_T(1) | R300_RS_SEL_R(2) | R300_RS_SEL_Q(3) |  R300_RS_TEX_PTR(rs_tex_count);
+                       r300->hw.ri.cmd[R300_RI_INTERP_0 + tex_ip] |= R300_RS_SEL_S(0) | R300_RS_SEL_T(R300_RS_SEL_K0) | R300_RS_SEL_R(R300_RS_SEL_K0);
+                       r300->hw.ri.cmd[R300_RI_INTERP_0 + tex_ip] |= R300_RS_SEL_Q(R300_RS_SEL_K1) | R300_RS_TEX_PTR(rs_tex_count);
                        r300->hw.rr.cmd[R300_RR_INST_0 + tex_ip] |= R300_RS_INST_TEX_ID(tex_ip) | R300_RS_INST_TEX_CN_WRITE | R300_RS_INST_TEX_ADDR(fp_reg);
                        InputsRead &= ~FRAG_BIT_FOGC;
                        rs_tex_count += 4;
@@ -1591,27 +1544,19 @@ static void r300SetupRSUnit(GLcontext * ctx)
                }
        }
 
-       if (InputsRead & FRAG_BIT_WPOS) {
-               r300->hw.ri.cmd[R300_RI_INTERP_0 + tex_ip] |=  R300_RS_SEL_S(0) | R300_RS_SEL_T(1) | R300_RS_SEL_R(2) | R300_RS_SEL_Q(3) |  R300_RS_TEX_PTR(rs_tex_count);
-               r300->hw.rr.cmd[R300_RR_INST_0 + tex_ip] |= R300_RS_INST_TEX_ID(tex_ip) | R300_RS_INST_TEX_CN_WRITE | R300_RS_INST_TEX_ADDR(fp_reg);
-               InputsRead &= ~FRAG_BIT_WPOS;
-               rs_tex_count += 4;
-               ++tex_ip;
-               ++fp_reg;
-       }
-       InputsRead &= ~FRAG_BIT_WPOS;
-
        /* Setup default color if no color or tex was set */
        if (rs_tex_count == 0 && col_ip == 0) {
-               r300->hw.rr.cmd[R300_RR_INST_0] = R300_RS_INST_COL_ID(0) | R300_RS_INST_COL_CN_WRITE | R300_RS_INST_COL_ADDR(0) | R300_RS_COL_FMT(R300_RS_COL_FMT_0001);
+               r300->hw.rr.cmd[R300_RR_INST_0] = R300_RS_INST_COL_ID(0) | R300_RS_INST_COL_ADDR(0);
+               r300->hw.ri.cmd[R300_RI_INTERP_0] = R300_RS_COL_PTR(0) | R300_RS_COL_FMT(R300_RS_COL_FMT_0001);
                ++col_ip;
        }
 
        high_rr = (col_ip > tex_ip) ? col_ip : tex_ip;
-       r300->hw.rc.cmd[1] |= (rs_tex_count << R300_IT_COUNT_SHIFT)  | (col_ip << R300_IC_COUNT_SHIFT) | R300_HIRES_EN;
+       r300->hw.rc.cmd[1] |= (rs_tex_count << R300_IT_COUNT_SHIFT) | (col_ip << R300_IC_COUNT_SHIFT) | R300_HIRES_EN;
        r300->hw.rc.cmd[2] |= high_rr - 1;
 
-       r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(R300_RS_INST_0, high_rr);
+       r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, R300_RS_INST_0, high_rr);
+       r300->hw.ri.cmd[R300_RI_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, R300_RS_IP_0, high_rr);
 
        if (InputsRead)
                WARN_ONCE("Don't know how to satisfy InputsRead=0x%08x\n", InputsRead);
@@ -1620,26 +1565,21 @@ static void r300SetupRSUnit(GLcontext * ctx)
 static void r500SetupRSUnit(GLcontext * ctx)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
-        TNLcontext *tnl = TNL_CONTEXT(ctx);
-       struct vertex_buffer *VB = &tnl->vb;
        union r300_outputs_written OutputsWritten;
        GLuint InputsRead;
        int fp_reg, high_rr;
        int col_ip, tex_ip;
        int rs_tex_count = 0;
-       int i, count, col_fmt;
+       int i, col_fmt, hw_tcl_on;
+
+       hw_tcl_on = r300->options.hw_tcl_enabled;
 
        if (hw_tcl_on)
-               OutputsWritten.vp_outputs = CURRENT_VERTEX_SHADER(ctx)->key.OutputsWritten;
+               OutputsWritten.vp_outputs = r300->selected_vp->key.OutputsWritten;
        else
-               RENDERINPUTS_COPY(OutputsWritten.index_bitset, r300->state.render_inputs_bitset);
+               RENDERINPUTS_COPY(OutputsWritten.index_bitset, r300->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.. */
-       }
+       InputsRead = ctx->FragmentProgram._Current->Base.InputsRead;
 
        R300_STATECHANGE(r300, ri);
        R300_STATECHANGE(r300, rc);
@@ -1658,15 +1598,7 @@ static void r500SetupRSUnit(GLcontext * ctx)
 
        if (InputsRead & FRAG_BIT_COL0) {
                if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten, VERT_RESULT_COL0, _TNL_ATTRIB_COLOR0)) {
-                       count = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->size;
-                       if (count == 4)
-                           col_fmt = R300_RS_COL_FMT_RGBA;
-                       else if (count == 3)
-                           col_fmt = R300_RS_COL_FMT_RGB1;
-                       else
-                           col_fmt = R300_RS_COL_FMT_0001;
-
-                       r300->hw.ri.cmd[R300_RI_INTERP_0 + col_ip] = R500_RS_COL_PTR(col_ip) | R500_RS_COL_FMT(col_fmt);
+                       r300->hw.ri.cmd[R300_RI_INTERP_0 + col_ip] = R500_RS_COL_PTR(col_ip) | R500_RS_COL_FMT(R300_RS_COL_FMT_RGBA);
                        r300->hw.rr.cmd[R300_RR_INST_0 + col_ip] = R500_RS_INST_COL_ID(col_ip) | R500_RS_INST_COL_CN_WRITE | R500_RS_INST_COL_ADDR(fp_reg);
                        InputsRead &= ~FRAG_BIT_COL0;
                        ++col_ip;
@@ -1678,15 +1610,7 @@ static void r500SetupRSUnit(GLcontext * ctx)
 
        if (InputsRead & FRAG_BIT_COL1) {
                if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten, VERT_RESULT_COL1, _TNL_ATTRIB_COLOR1)) {
-                       count = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->size;
-                       if (count == 4)
-                           col_fmt = R300_RS_COL_FMT_RGBA;
-                       else if (count == 3)
-                           col_fmt = R300_RS_COL_FMT_RGB1;
-                       else
-                           col_fmt = R300_RS_COL_FMT_0001;
-
-                       r300->hw.ri.cmd[R300_RI_INTERP_0 + col_ip] = R500_RS_COL_PTR(col_ip) | R500_RS_COL_FMT(col_fmt);
+                       r300->hw.ri.cmd[R300_RI_INTERP_0 + col_ip] = R500_RS_COL_PTR(col_ip) | R500_RS_COL_FMT(R300_RS_COL_FMT_RGBA);
                        r300->hw.rr.cmd[R300_RR_INST_0 + col_ip] = R500_RS_INST_COL_ID(col_ip) | R500_RS_INST_COL_CN_WRITE | R500_RS_INST_COL_ADDR(fp_reg);
                        InputsRead &= ~FRAG_BIT_COL1;
                        ++col_ip;
@@ -1696,7 +1620,7 @@ static void r500SetupRSUnit(GLcontext * ctx)
                }
        }
 
-
+       /* We always route 4 texcoord components */
        for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
                if (! ( InputsRead & FRAG_BIT_TEX(i) ) )
                    continue;
@@ -1706,55 +1630,37 @@ static void r500SetupRSUnit(GLcontext * ctx)
                    continue;
                }
 
-               int swiz = 0;
-
-               /* with TCL we always seem to route 4 components */
-               if (hw_tcl_on)
-                 count = 4;
-               else
-                 count = VB->AttribPtr[_TNL_ATTRIB_TEX(i)]->size;
-
-               if (count == 4) {
-                       swiz |= (rs_tex_count + 0) << R500_RS_IP_TEX_PTR_S_SHIFT;
-                       swiz |= (rs_tex_count + 1) << R500_RS_IP_TEX_PTR_T_SHIFT;
-                       swiz |= (rs_tex_count + 2) << R500_RS_IP_TEX_PTR_R_SHIFT;
-                       swiz |= (rs_tex_count + 3) << R500_RS_IP_TEX_PTR_Q_SHIFT;
-               } else if (count == 3) {
-                       swiz |= (rs_tex_count + 0) << R500_RS_IP_TEX_PTR_S_SHIFT;
-                       swiz |= (rs_tex_count + 1) << R500_RS_IP_TEX_PTR_T_SHIFT;
-                       swiz |= (rs_tex_count + 2) << R500_RS_IP_TEX_PTR_R_SHIFT;
-                       swiz |= R500_RS_IP_PTR_K1 << R500_RS_IP_TEX_PTR_Q_SHIFT;
-               } else if (count == 2) {
-                       swiz |= (rs_tex_count + 0) << R500_RS_IP_TEX_PTR_S_SHIFT;
-                       swiz |= (rs_tex_count + 1) << R500_RS_IP_TEX_PTR_T_SHIFT;
-                       swiz |= R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_R_SHIFT;
-                       swiz |= R500_RS_IP_PTR_K1 << R500_RS_IP_TEX_PTR_Q_SHIFT;
-               } else if (count == 1) {
-                       swiz |= (rs_tex_count + 0) << R500_RS_IP_TEX_PTR_S_SHIFT;
-                       swiz |= R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_T_SHIFT;
-                       swiz |= R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_R_SHIFT;
-                       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;
-                       swiz |= R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_T_SHIFT;
-                       swiz |= R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_R_SHIFT;
-                       swiz |= R500_RS_IP_PTR_K1 << R500_RS_IP_TEX_PTR_Q_SHIFT;
-               }
+               r300->hw.ri.cmd[R300_RI_INTERP_0 + tex_ip] |= ((rs_tex_count + 0) << R500_RS_IP_TEX_PTR_S_SHIFT) |
+                       ((rs_tex_count + 1) << R500_RS_IP_TEX_PTR_T_SHIFT) |
+                       ((rs_tex_count + 2) << R500_RS_IP_TEX_PTR_R_SHIFT) |
+                       ((rs_tex_count + 3) << R500_RS_IP_TEX_PTR_Q_SHIFT);
 
-               r300->hw.ri.cmd[R300_RI_INTERP_0 + tex_ip] |= swiz;
                r300->hw.rr.cmd[R300_RR_INST_0 + tex_ip] |= R500_RS_INST_TEX_ID(tex_ip) | R500_RS_INST_TEX_CN_WRITE | R500_RS_INST_TEX_ADDR(fp_reg);
                InputsRead &= ~(FRAG_BIT_TEX0 << i);
-               rs_tex_count += count;
+               rs_tex_count += 4;
+               ++tex_ip;
+               ++fp_reg;
+       }
+
+       if (InputsRead & FRAG_BIT_WPOS) {
+               r300->hw.ri.cmd[R300_RI_INTERP_0 + tex_ip] |= ((rs_tex_count + 0) << R500_RS_IP_TEX_PTR_S_SHIFT) |
+                       ((rs_tex_count + 1) << R500_RS_IP_TEX_PTR_T_SHIFT) |
+                       ((rs_tex_count + 2) << R500_RS_IP_TEX_PTR_R_SHIFT) |
+                       ((rs_tex_count + 3) << R500_RS_IP_TEX_PTR_Q_SHIFT);
+
+               r300->hw.rr.cmd[R300_RR_INST_0 + tex_ip] |= R500_RS_INST_TEX_ID(tex_ip) | R500_RS_INST_TEX_CN_WRITE | R500_RS_INST_TEX_ADDR(fp_reg);
+               InputsRead &= ~FRAG_BIT_WPOS;
+               rs_tex_count += 4;
                ++tex_ip;
                ++fp_reg;
        }
 
        if (InputsRead & FRAG_BIT_FOGC) {
                if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten, VERT_RESULT_FOGC, _TNL_ATTRIB_FOG)) {
-                       r300->hw.ri.cmd[R300_RI_INTERP_0 + tex_ip] |= ((rs_tex_count + 0) << R500_RS_IP_TEX_PTR_S_SHIFT) |
-                               ((rs_tex_count + 1) << R500_RS_IP_TEX_PTR_T_SHIFT) |
-                               ((rs_tex_count + 2) << R500_RS_IP_TEX_PTR_R_SHIFT) |
-                               ((rs_tex_count + 3) << R500_RS_IP_TEX_PTR_Q_SHIFT);
+                       r300->hw.ri.cmd[R300_RI_INTERP_0 + tex_ip] |= (rs_tex_count << 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.rr.cmd[R300_RR_INST_0 + tex_ip] |= R500_RS_INST_TEX_ID(tex_ip) | R500_RS_INST_TEX_CN_WRITE | R500_RS_INST_TEX_ADDR(fp_reg);
                        InputsRead &= ~FRAG_BIT_FOGC;
@@ -1766,87 +1672,27 @@ static void r500SetupRSUnit(GLcontext * ctx)
                }
        }
 
-       if (InputsRead & FRAG_BIT_WPOS) {
-               r300->hw.ri.cmd[R300_RI_INTERP_0 + tex_ip] |= ((rs_tex_count + 0) << R500_RS_IP_TEX_PTR_S_SHIFT) |
-                               ((rs_tex_count + 1) << R500_RS_IP_TEX_PTR_T_SHIFT) |
-                               ((rs_tex_count + 2) << R500_RS_IP_TEX_PTR_R_SHIFT) |
-                               ((rs_tex_count + 3) << R500_RS_IP_TEX_PTR_Q_SHIFT);
-
-               r300->hw.rr.cmd[R300_RR_INST_0 + tex_ip] |= R500_RS_INST_TEX_ID(tex_ip) | R500_RS_INST_TEX_CN_WRITE | R500_RS_INST_TEX_ADDR(fp_reg);
-               InputsRead &= ~FRAG_BIT_WPOS;
-               rs_tex_count += 4;
-               ++tex_ip;
-               ++fp_reg;
-       }
-
        /* Setup default color if no color or tex was set */
        if (rs_tex_count == 0 && col_ip == 0) {
-               r300->hw.rr.cmd[R300_RR_INST_0] |= R500_RS_INST_COL_ID(0) | R500_RS_INST_COL_CN_WRITE | R500_RS_INST_COL_ADDR(0) | R500_RS_COL_FMT(R300_RS_COL_FMT_0001);
+               r300->hw.rr.cmd[R300_RR_INST_0] = R500_RS_INST_COL_ID(0) | R500_RS_INST_COL_ADDR(0);
+               r300->hw.ri.cmd[R300_RI_INTERP_0] = R500_RS_COL_PTR(0) | R500_RS_COL_FMT(R300_RS_COL_FMT_0001);
                ++col_ip;
        }
 
        high_rr = (col_ip > tex_ip) ? col_ip : tex_ip;
-       r300->hw.rc.cmd[1] |= (rs_tex_count << R300_IT_COUNT_SHIFT)  | (col_ip << R300_IC_COUNT_SHIFT) | R300_HIRES_EN;
-       r300->hw.rc.cmd[2] |= 0xC0 | (high_rr - 1);
+       r300->hw.rc.cmd[1] = (rs_tex_count << R300_IT_COUNT_SHIFT) | (col_ip << R300_IC_COUNT_SHIFT) | R300_HIRES_EN;
+       r300->hw.rc.cmd[2] = 0xC0 | (high_rr - 1);
 
-       r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(R500_RS_INST_0, high_rr);
+       r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, R500_RS_INST_0, high_rr);
+       r300->hw.ri.cmd[R300_RI_CMD_0] = cmdpacket0(r300->radeon.radeonScreen, R500_RS_IP_0, 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; \
-       assert(_nc < 256); \
-       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)
-{
-       int i;
-
-       if (vsf->length == 0)
-               return;
-
-       if (vsf->length & 0x3) {
-               fprintf(stderr, "VERTEX_SHADER_FRAGMENT must have length divisible by 4\n");
-               _mesa_exit(-1);
-       }
-
-       switch ((dest >> 8) & 0xf) {
-       case 0:
-               R300_STATECHANGE(r300, vpi);
-               for (i = 0; i < vsf->length; i++)
-                       r300->hw.vpi.cmd[R300_VPI_INSTR_0 + i + 4 * (dest & 0xff)] = (vsf->body.d[i]);
-               bump_vpu_count(r300->hw.vpi.cmd, vsf->length + 4 * (dest & 0xff));
-               break;
-
-       case 2:
-               R300_STATECHANGE(r300, vpp);
-               for (i = 0; i < vsf->length; i++)
-                       r300->hw.vpp.cmd[R300_VPP_PARAM_0 + i + 4 * (dest & 0xff)] = (vsf->body.d[i]);
-               bump_vpu_count(r300->hw.vpp.cmd, vsf->length + 4 * (dest & 0xff));
-               break;
-       case 4:
-               R300_STATECHANGE(r300, vps);
-               for (i = 0; i < vsf->length; i++)
-                       r300->hw.vps.cmd[1 + i + 4 * (dest & 0xff)] = (vsf->body.d[i]);
-               bump_vpu_count(r300->hw.vps.cmd, vsf->length + 4 * (dest & 0xff));
-               break;
-       default:
-               fprintf(stderr, "%s:%s don't know how to handle dest %04x\n", __FILE__, __FUNCTION__, dest);
-               _mesa_exit(-1);
-       }
-}
-
 #define MIN3(a, b, c)  ((a) < (b) ? MIN2(a, c) : MIN2(b, c))
 
-
-static void r300VapCntl(r300ContextPtr rmesa, GLuint input_count,
+void r300VapCntl(r300ContextPtr rmesa, GLuint input_count,
                        GLuint output_count, GLuint temp_count)
 {
     int vtx_mem_size;
@@ -1870,7 +1716,7 @@ static void r300VapCntl(r300ContextPtr rmesa, GLuint input_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) {
+    if (rmesa->options.hw_tcl_enabled) {
        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) |
@@ -1900,114 +1746,6 @@ static void r300VapCntl(r300ContextPtr rmesa, GLuint input_count,
 
 }
 
-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;
-       int program_end = 0;
-
-       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] = 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_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_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_CONST_BASE_OFFSET_SHIFT) |
-           (param_count << R300_PVS_MAX_CONST_ADDR_SHIFT);
-       rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] =
-           (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)
-{
-       GLcontext *ctx = rmesa->radeon.glCtx;
-       struct r300_vertex_program *prog = (struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx);
-       int inst_count = 0;
-       int param_count = 0;
-
-       /* FIXME: r300SetupVertexProgramFragment */
-       R300_STATECHANGE(rmesa, vpp);
-       param_count =
-           r300VertexProgUpdateParams(ctx,
-                                      (struct r300_vertex_program_cont *)
-                                      ctx->VertexProgram._Current,
-                                      (float *)&rmesa->hw.vpp.
-                                      cmd[R300_VPP_PARAM_0]);
-       bump_vpu_count(rmesa->hw.vpp.cmd, param_count);
-       param_count /= 4;
-
-       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_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_CONST_BASE_OFFSET_SHIFT) |
-         (param_count << R300_PVS_MAX_CONST_ADDR_SHIFT);
-       rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] =
-         (inst_count << R300_PVS_LAST_VTX_SRC_INST_SHIFT);
-}
-
-static void r300SetupVertexProgram(r300ContextPtr rmesa)
-{
-       GLcontext *ctx = rmesa->radeon.glCtx;
-
-       /* Reset state, in case we don't use something */
-       ((drm_r300_cmd_header_t *) rmesa->hw.vpp.cmd)->vpu.count = 0;
-       ((drm_r300_cmd_header_t *) rmesa->hw.vpi.cmd)->vpu.count = 0;
-       ((drm_r300_cmd_header_t *) rmesa->hw.vps.cmd)->vpu.count = 0;
-
-       /* Not sure why this doesnt work...
-          0x400 area might have something to do with pixel shaders as it appears right after pfs programming.
-          0x406 is set to { 0.0, 0.0, 1.0, 0.0 } most of the time but should change with smooth points and in other rare cases. */
-       //setup_vertex_shader_fragment(rmesa, 0x406, &unk4);
-       if (hw_tcl_on && ((struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx))->translated) {
-               r300SetupRealVertexProgram(rmesa);
-       } else {
-               /* FIXME: This needs to be replaced by vertex shader generation code. */
-               r300SetupDefaultVertexProgram(rmesa);
-       }
-
-}
-
 /**
  * Enable/Disable states.
  *
@@ -2015,20 +1753,13 @@ static void r300SetupVertexProgram(r300ContextPtr rmesa)
  */
 static void r300Enable(GLcontext * ctx, GLenum cap, GLboolean state)
 {
+       r300ContextPtr rmesa = 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) {
-       case GL_TEXTURE_1D:
-       case GL_TEXTURE_2D:
-       case GL_TEXTURE_3D:
-               /* empty */
-               break;
-       case GL_FOG:
-               /* empty */
-               break;
        case GL_ALPHA_TEST:
                r300SetAlphaState(ctx);
                break;
@@ -2046,22 +1777,46 @@ static void r300Enable(GLcontext * ctx, GLenum cap, GLboolean state)
        case GL_CLIP_PLANE5:
                r300SetClipPlaneState(ctx, cap, state);
                break;
+       case GL_CULL_FACE:
+               r300UpdateCulling(ctx);
+               break;
        case GL_DEPTH_TEST:
                r300SetDepthState(ctx);
                break;
-       case GL_STENCIL_TEST:
-               r300SetStencilState(ctx, state);
+       case GL_LINE_SMOOTH:
+               if (rmesa->options.conformance_mode)
+                       r300SwitchFallback(ctx, R300_FALLBACK_LINE_SMOOTH, ctx->Line.SmoothFlag);
                break;
-       case GL_CULL_FACE:
-               r300UpdateCulling(ctx);
+       case GL_LINE_STIPPLE:
+               if (rmesa->options.conformance_mode)
+                       r300SwitchFallback(ctx, R300_FALLBACK_LINE_STIPPLE, ctx->Line.StippleFlag);
+               break;
+       case GL_POINT_SMOOTH:
+               if (rmesa->options.conformance_mode)
+                       r300SwitchFallback(ctx, R300_FALLBACK_POINT_SMOOTH, ctx->Point.SmoothFlag);
+               break;
+       case GL_POLYGON_SMOOTH:
+               if (rmesa->options.conformance_mode)
+                       r300SwitchFallback(ctx, R300_FALLBACK_POLYGON_SMOOTH, ctx->Polygon.SmoothFlag);
+               break;
+       case GL_POLYGON_STIPPLE:
+               if (rmesa->options.conformance_mode)
+                       r300SwitchFallback(ctx, R300_FALLBACK_POLYGON_STIPPLE, ctx->Polygon.StippleFlag);
                break;
        case GL_POLYGON_OFFSET_POINT:
        case GL_POLYGON_OFFSET_LINE:
        case GL_POLYGON_OFFSET_FILL:
                r300SetPolygonOffsetState(ctx, state);
                break;
+       case GL_SCISSOR_TEST:
+               radeon_firevertices(&rmesa->radeon);
+               rmesa->radeon.state.scissor.enabled = state;
+               radeonUpdateScissor( ctx );
+               break;
+       case GL_STENCIL_TEST:
+               r300SetStencilState(ctx, state);
+               break;
        default:
-               radeonEnable(ctx, cap, state);
                break;
        }
 }
@@ -2072,15 +1827,14 @@ static void r300Enable(GLcontext * ctx, GLenum cap, GLboolean state)
 static void r300ResetHwState(r300ContextPtr r300)
 {
        GLcontext *ctx = r300->radeon.glCtx;
-       int has_tcl = 1;
+       int has_tcl;
 
-       if (!(r300->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL))
-               has_tcl = 0;
+       has_tcl = r300->options.hw_tcl_enabled;
 
        if (RADEON_DEBUG & DEBUG_STATE)
                fprintf(stderr, "%s\n", __FUNCTION__);
 
-       r300UpdateWindow(ctx);
+       radeon_firevertices(&r300->radeon);
 
        r300ColorMask(ctx,
                      ctx->Color.ColorMask[RCOMP],
@@ -2102,8 +1856,6 @@ static void r300ResetHwState(r300ContextPtr r300)
 
        r300UpdateCulling(ctx);
 
-       r300UpdateTextureState(ctx);
-
        r300SetBlendState(ctx);
        r300SetLogicOpState(ctx);
 
@@ -2182,8 +1934,8 @@ static void r300ResetHwState(r300ContextPtr r300)
        }
 
        /* XXX: Enable anti-aliasing? */
-       r300->hw.gb_misc.cmd[R300_GB_MISC_AA_CONFIG] = GB_AA_CONFIG_AA_DISABLE;
-       r300->hw.gb_misc.cmd[R300_GB_MISC_SELECT] = 0;
+       r300->hw.gb_misc2.cmd[R300_GB_MISC2_AA_CONFIG] = GB_AA_CONFIG_AA_DISABLE;
+       r300->hw.gb_misc2.cmd[R300_GB_MISC2_SELECT] = 0;
 
        r300->hw.ga_point_s0.cmd[1] = r300PackFloat32(0.0);
        r300->hw.ga_point_s0.cmd[2] = r300PackFloat32(0.0);
@@ -2242,20 +1994,6 @@ static void r300ResetHwState(r300ContextPtr r300)
 
        r300BlendColor(ctx, ctx->Color.BlendColor);
 
-       /* Again, r300ClearBuffer uses this */
-       r300->hw.cb.cmd[R300_CB_OFFSET] =
-           r300->radeon.state.color.drawOffset +
-           r300->radeon.radeonScreen->fbLocation;
-       r300->hw.cb.cmd[R300_CB_PITCH] = r300->radeon.state.color.drawPitch;
-
-       if (r300->radeon.radeonScreen->cpp == 4)
-               r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_FORMAT_ARGB8888;
-       else
-               r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_FORMAT_RGB565;
-
-       if (r300->radeon.sarea->tiling_enabled)
-               r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_TILE_ENABLE;
-
        r300->hw.rb3d_dither_ctl.cmd[1] = 0;
        r300->hw.rb3d_dither_ctl.cmd[2] = 0;
        r300->hw.rb3d_dither_ctl.cmd[3] = 0;
@@ -2268,44 +2006,18 @@ static void r300ResetHwState(r300ContextPtr r300)
 
        r300->hw.rb3d_aaresolve_ctl.cmd[1] = 0;
 
-       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 +
-           r300->radeon.radeonScreen->fbLocation;
-       r300->hw.zb.cmd[R300_ZB_PITCH] = r300->radeon.radeonScreen->depthPitch;
-
-       if (r300->radeon.sarea->tiling_enabled) {
-               /* XXX: Turn off when clearing buffers ? */
-               r300->hw.zb.cmd[R300_ZB_PITCH] |= R300_DEPTHMACROTILE_ENABLE;
-
-               if (ctx->Visual.depthBits == 24)
-                       r300->hw.zb.cmd[R300_ZB_PITCH] |=
-                           R300_DEPTHMICROTILE_TILED;
-       }
+    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_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.zb_zmask.cmd[1] = 0;
+       r300->hw.zb_zmask.cmd[2] = 0;
 
        r300->hw.zb_hiz_offset.cmd[1] = 0;
 
@@ -2319,20 +2031,26 @@ static void r300ResetHwState(r300ContextPtr r300)
                r300->hw.vps.cmd[R300_VPS_ZERO_3] = 0;
        }
 
-       r300->hw.all_dirty = GL_TRUE;
+       r300->radeon.hw.all_dirty = GL_TRUE;
 }
 
 void r300UpdateShaders(r300ContextPtr rmesa)
 {
        GLcontext *ctx;
-       struct r300_vertex_program *vp;
+       struct r300_fragment_program *fp;
        int i;
 
        ctx = rmesa->radeon.glCtx;
+       fp = (struct r300_fragment_program *) ctx->FragmentProgram._Current;
 
-       if (rmesa->NewGLState && hw_tcl_on) {
-               rmesa->NewGLState = 0;
+       /* should only happenen once, just after context is created */
+       /* TODO: shouldn't we fallback to sw here? */
+       if (!fp) {
+               _mesa_fprintf(stderr, "No ctx->FragmentProgram._Current!!\n");
+               return;
+       }
 
+       if (rmesa->radeon.NewGLState && rmesa->options.hw_tcl_enabled) {
                for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) {
                        rmesa->temp_attrib[i] =
                            TNL_CONTEXT(ctx)->vb.AttribPtr[i];
@@ -2348,20 +2066,16 @@ void r300UpdateShaders(r300ContextPtr rmesa)
                }
 
                r300SelectVertexShader(rmesa);
-               vp = (struct r300_vertex_program *)
-                   CURRENT_VERTEX_SHADER(ctx);
-               /*if (vp->translated == GL_FALSE)
-                  r300TranslateVertexShader(vp); */
-               if (vp->translated == GL_FALSE) {
-                       fprintf(stderr, "Failing back to sw-tcl\n");
-                       hw_tcl_on = future_hw_tcl_on = 0;
-                       r300ResetHwState(rmesa);
-
-                       r300UpdateStateParameters(ctx, _NEW_PROGRAM);
-                       return;
-               }
+               r300SwitchFallback(ctx, R300_FALLBACK_VERTEX_PROGRAM, rmesa->selected_vp->error);
        }
-       r300UpdateStateParameters(ctx, _NEW_PROGRAM);
+
+       if (!fp->translated || rmesa->radeon.NewGLState)
+               r300TranslateFragmentShader(ctx, ctx->FragmentProgram._Current);
+
+       r300SwitchFallback(ctx, R300_FALLBACK_FRAGMENT_PROGRAM, fp->error);
+
+       r300UpdateStateParameters(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
+       rmesa->radeon.NewGLState = 0;
 }
 
 static const GLfloat *get_fragmentprogram_constant(GLcontext *ctx,
@@ -2385,35 +2099,23 @@ static const GLfloat *get_fragmentprogram_constant(GLcontext *ctx,
 }
 
 
-static void r300SetupPixelShader(r300ContextPtr rmesa)
+static void r300SetupPixelShader(GLcontext *ctx)
 {
-       GLcontext *ctx = rmesa->radeon.glCtx;
-       struct r300_fragment_program *fp = (struct r300_fragment_program *)
-           (char *)ctx->FragmentProgram._Current;
+       r300ContextPtr rmesa = R300_CONTEXT(ctx);
+       struct r300_fragment_program *fp = (struct r300_fragment_program *) ctx->FragmentProgram._Current;
        struct r300_fragment_program_code *code;
        int i, k;
 
-       if (!fp)                /* should only happenen once, just after context is created */
-               return;
-
-       r300TranslateFragmentShader(rmesa, fp);
-       if (!fp->translated) {
-               fprintf(stderr, "%s: No valid fragment shader, exiting\n",
-                       __FUNCTION__);
-               return;
-       }
-       code = &fp->code;
-
-       r300SetupTextures(ctx);
+       code = &fp->code.r300;
 
        R300_STATECHANGE(rmesa, fpi[0]);
        R300_STATECHANGE(rmesa, fpi[1]);
        R300_STATECHANGE(rmesa, fpi[2]);
        R300_STATECHANGE(rmesa, fpi[3]);
-       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);
+       rmesa->hw.fpi[0].cmd[R300_FPI_CMD_0] = cmdpacket0(rmesa->radeon.radeonScreen, R300_US_ALU_RGB_INST_0, code->alu.length);
+       rmesa->hw.fpi[1].cmd[R300_FPI_CMD_0] = cmdpacket0(rmesa->radeon.radeonScreen, R300_US_ALU_RGB_ADDR_0, code->alu.length);
+       rmesa->hw.fpi[2].cmd[R300_FPI_CMD_0] = cmdpacket0(rmesa->radeon.radeonScreen, R300_US_ALU_ALPHA_INST_0, code->alu.length);
+       rmesa->hw.fpi[3].cmd[R300_FPI_CMD_0] = cmdpacket0(rmesa->radeon.radeonScreen, 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;
@@ -2444,10 +2146,10 @@ static void r300SetupPixelShader(r300ContextPtr rmesa)
        }
 
        R300_STATECHANGE(rmesa, fpp);
-       rmesa->hw.fpp.cmd[R300_FPP_CMD_0] = cmdpacket0(R300_PFS_PARAM_0_X, code->const_nr * 4);
+       rmesa->hw.fpp.cmd[R300_FPP_CMD_0] = cmdpacket0(rmesa->radeon.radeonScreen, 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]);
+                       &fp->Base.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]);
@@ -2469,29 +2171,17 @@ static void r300SetupPixelShader(r300ContextPtr rmesa)
        if(_nc>_p->r500fp.count)_p->r500fp.count=_nc;\
 } while(0)
 
-static void r500SetupPixelShader(r300ContextPtr rmesa)
+static void r500SetupPixelShader(GLcontext *ctx)
 {
-       GLcontext *ctx = rmesa->radeon.glCtx;
-       struct r500_fragment_program *fp = (struct r500_fragment_program *)
-           (char *)ctx->FragmentProgram._Current;
+       r300ContextPtr rmesa = R300_CONTEXT(ctx);
+       struct r300_fragment_program *fp = (struct r300_fragment_program *) 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;
-
-       r300SetupTextures(ctx);
+       code = &fp->code.r500;
 
        R300_STATECHANGE(rmesa, fp);
        rmesa->hw.fp.cmd[R500_FP_PIXSIZE] = code->max_temp_idx;
@@ -2521,58 +2211,96 @@ static void r500SetupPixelShader(r300ContextPtr rmesa)
        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]);
+                       &fp->Base.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 r300SetupVAP(GLcontext *ctx, GLuint InputsRead, GLuint OutputsWritten)
+{
+       r300ContextPtr rmesa = R300_CONTEXT( ctx );
+       struct vertex_attribute *attrs = rmesa->vbuf.attribs;
+       int i, j, reg_count;
+       uint32_t *vir0 = &rmesa->hw.vir[0].cmd[1];
+       uint32_t *vir1 = &rmesa->hw.vir[1].cmd[1];
+
+       for (i = 0; i < R300_VIR_CMDSIZE-1; ++i)
+               vir0[i] = vir1[i] = 0;
+
+       for (i = 0, j = 0; i < rmesa->vbuf.num_attribs; ++i) {
+               int tmp;
+
+               tmp = attrs[i].data_type | (attrs[i].dst_loc << R300_DST_VEC_LOC_SHIFT);
+               if (attrs[i]._signed)
+                       tmp |= R300_SIGNED;
+               if (attrs[i].normalize)
+                       tmp |= R300_NORMALIZE;
+
+               if (i % 2 == 0) {
+                       vir0[j] = tmp << R300_DATA_TYPE_0_SHIFT;
+                       vir1[j] = attrs[i].swizzle | (attrs[i].write_mask << R300_WRITE_ENA_SHIFT);
+               } else {
+                       vir0[j] |= tmp << R300_DATA_TYPE_1_SHIFT;
+                       vir1[j] |= (attrs[i].swizzle | (attrs[i].write_mask << R300_WRITE_ENA_SHIFT)) << R300_SWIZZLE1_SHIFT;
+                       ++j;
+               }
+       }
+
+       reg_count = (rmesa->vbuf.num_attribs + 1) >> 1;
+       if (rmesa->vbuf.num_attribs % 2 != 0) {
+               vir0[reg_count-1] |= R300_LAST_VEC << R300_DATA_TYPE_0_SHIFT;
+       } else {
+               vir0[reg_count-1] |= R300_LAST_VEC << R300_DATA_TYPE_1_SHIFT;
+       }
+
+       R300_STATECHANGE(rmesa, vir[0]);
+       R300_STATECHANGE(rmesa, vir[1]);
+       R300_STATECHANGE(rmesa, vof);
+       R300_STATECHANGE(rmesa, vic);
+
+       if (rmesa->radeon.radeonScreen->kernel_mm) {
+               rmesa->hw.vir[0].cmd[0] &= 0xC000FFFF;
+               rmesa->hw.vir[1].cmd[0] &= 0xC000FFFF;
+               rmesa->hw.vir[0].cmd[0] |= (reg_count & 0x3FFF) << 16;
+               rmesa->hw.vir[1].cmd[0] |= (reg_count & 0x3FFF) << 16;
+       } else {
+               ((drm_r300_cmd_header_t *) rmesa->hw.vir[0].cmd)->packet0.count = reg_count;
+               ((drm_r300_cmd_header_t *) rmesa->hw.vir[1].cmd)->packet0.count = reg_count;
+       }
 
+       rmesa->hw.vic.cmd[R300_VIC_CNTL_0] = r300VAPInputCntl0(ctx, InputsRead);
+       rmesa->hw.vic.cmd[R300_VIC_CNTL_1] = r300VAPInputCntl1(ctx, InputsRead);
+       rmesa->hw.vof.cmd[R300_VOF_CNTL_0] = r300VAPOutputCntl0(ctx, OutputsWritten, ctx->FragmentProgram._Current->Base.InputsRead);
+       rmesa->hw.vof.cmd[R300_VOF_CNTL_1] = r300VAPOutputCntl1(ctx, OutputsWritten, ctx->FragmentProgram._Current->Base.InputsRead);
 }
 
 void r300UpdateShaderStates(r300ContextPtr rmesa)
 {
        GLcontext *ctx;
        ctx = rmesa->radeon.glCtx;
+       struct r300_fragment_program *r300_fp;
 
-       r300UpdateTextureState(ctx);
-       r300SetEarlyZState(ctx);
+       r300_fp = (struct r300_fragment_program *) ctx->FragmentProgram._Current;
 
-       /* w_fmt value is set to get best performance
-        * see p.130 R5xx 3D acceleration guide v1.3 */
-       GLuint w_fmt, fgdepthsrc;
-       if (current_fragment_program_writes_depth(ctx)) {
-               fgdepthsrc = R300_FG_DEPTH_SRC_SHADER;
-               w_fmt = R300_W_FMT_W24 | R300_W_SRC_US;
-       } else {
-               fgdepthsrc = R300_FG_DEPTH_SRC_SCAN;
-               w_fmt = R300_W_FMT_W0 | R300_W_SRC_US;
-       }
+       /* should only happenen once, just after context is created */
+       if (!r300_fp)
+               return;
 
-       if (w_fmt != rmesa->hw.us_out_fmt.cmd[5]) {
-               R300_STATECHANGE(rmesa, us_out_fmt);
-               rmesa->hw.us_out_fmt.cmd[5] = w_fmt;
-       }
+       r300SetEarlyZState(ctx);
 
-       if (fgdepthsrc != rmesa->hw.fg_depth_src.cmd[1]) {
-               R300_STATECHANGE(rmesa, fg_depth_src);
-               rmesa->hw.fg_depth_src.cmd[1] = fgdepthsrc;
-       }
+       r300SetupTextures(ctx);
 
-       if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515)
-               r500SetupPixelShader(rmesa);
-       else
-               r300SetupPixelShader(rmesa);
+       rmesa->vtbl.SetupPixelShader(ctx);
 
-       if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515)
-               r500SetupRSUnit(ctx);
-       else
-               r300SetupRSUnit(ctx);
+       rmesa->vtbl.SetupRSUnit(ctx);
 
-       if ((rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL))
+       if (rmesa->options.hw_tcl_enabled) {
                r300SetupVertexProgram(rmesa);
-
+       }
 }
 
 /**
@@ -2586,15 +2314,18 @@ static void r300InvalidateState(GLcontext * ctx, GLuint new_state)
        _swsetup_InvalidateState(ctx, new_state);
        _vbo_InvalidateState(ctx, new_state);
        _tnl_InvalidateState(ctx, new_state);
-       _ae_invalidate_state(ctx, new_state);
 
-       if (new_state & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL)) {
-               r300UpdateDrawBuffer(ctx);
+       if (new_state & _NEW_BUFFERS) {
+               _mesa_update_framebuffer(ctx);
+               /* this updates the DrawBuffer's Width/Height if it's a FBO */
+               _mesa_update_draw_buffer_bounds(ctx);
+
+               R300_STATECHANGE(r300, cb);
        }
 
        r300UpdateStateParameters(ctx, new_state);
 
-       r300->NewGLState |= new_state;
+       r300->radeon.NewGLState |= new_state;
 }
 
 /**
@@ -2604,58 +2335,12 @@ static void r300InvalidateState(GLcontext * ctx, GLuint new_state)
  */
 void r300InitState(r300ContextPtr r300)
 {
-       GLcontext *ctx = r300->radeon.glCtx;
-       GLuint depth_fmt;
-
-       radeonInitState(&r300->radeon);
-
-       switch (ctx->Visual.depthBits) {
-       case 16:
-               r300->state.depth.scale = 1.0 / (GLfloat) 0xffff;
-               depth_fmt = R300_DEPTHFORMAT_16BIT_INT_Z;
-               break;
-       case 24:
-               r300->state.depth.scale = 1.0 / (GLfloat) 0xffffff;
-               depth_fmt = R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL;
-               break;
-       default:
-               fprintf(stderr, "Error: Unsupported depth %d... exiting\n",
-                       ctx->Visual.depthBits);
-               _mesa_exit(-1);
-       }
-
-       /* Only have hw stencil when depth buffer is 24 bits deep */
-       r300->state.stencil.hw_stencil = (ctx->Visual.stencilBits > 0 &&
-                                         ctx->Visual.depthBits == 24);
-
-       memset(&(r300->state.texture), 0, sizeof(r300->state.texture));
-
        r300ResetHwState(r300);
 }
 
 static void r300RenderMode(GLcontext * ctx, GLenum mode)
 {
-       r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       (void)rmesa;
-       (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];
-               }
-       }
+       r300SwitchFallback(ctx, R300_FALLBACK_RENDER_MODE, ctx->RenderMode != GL_RENDER);
 }
 
 /**
@@ -2663,7 +2348,6 @@ void r300UpdateClipPlanes( GLcontext *ctx )
  */
 void r300InitStateFuncs(struct dd_function_table *functions)
 {
-       radeonInitStateFuncs(functions);
 
        functions->UpdateState = r300InvalidateState;
        functions->AlphaFunc = r300AlphaFunc;
@@ -2699,4 +2383,25 @@ void r300InitStateFuncs(struct dd_function_table *functions)
        functions->RenderMode = r300RenderMode;
 
        functions->ClipPlane = r300ClipPlane;
+       functions->Scissor = radeonScissor;
+
+       functions->DrawBuffer           = radeonDrawBuffer;
+       functions->ReadBuffer           = radeonReadBuffer;
+}
+
+void r300InitShaderFunctions(r300ContextPtr r300)
+{
+       if (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) {
+               r300->vtbl.SetupRSUnit = r500SetupRSUnit;
+               r300->vtbl.SetupPixelShader = r500SetupPixelShader;
+               r300->vtbl.SetupFragmentShaderTextures = r500SetupFragmentShaderTextures;
+               r300->vtbl.BuildFragmentProgramHwCode = r500BuildFragmentProgramHwCode;
+               r300->vtbl.FragmentProgramDump = r500FragmentProgramDump;
+       } else {
+               r300->vtbl.SetupRSUnit = r300SetupRSUnit;
+               r300->vtbl.SetupPixelShader = r300SetupPixelShader;
+               r300->vtbl.SetupFragmentShaderTextures = r300SetupFragmentShaderTextures;
+               r300->vtbl.BuildFragmentProgramHwCode = r300BuildFragmentProgramHwCode;
+               r300->vtbl.FragmentProgramDump = r300FragmentProgramDump;
+       }
 }
index 0589ab7cad97f1e262ed1875d427b6f9e434edf2..23282894202f3ae66e41ff4f40913a02eae793ac 100644 (file)
@@ -39,42 +39,25 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define R300_NEWPRIM( rmesa )                  \
   do {                                         \
-    if ( rmesa->dma.flush )                    \
-      rmesa->dma.flush( rmesa );               \
+  if ( rmesa->radeon.dma.flush )                       \
+    rmesa->radeon.dma.flush( rmesa->radeon.glCtx );    \
   } while (0)
 
 #define R300_STATECHANGE(r300, atom) \
        do {                                            \
          R300_NEWPRIM(r300);                           \
                r300->hw.atom.dirty = GL_TRUE;          \
-               r300->hw.is_dirty = GL_TRUE;            \
+               r300->radeon.hw.is_dirty = GL_TRUE;             \
        } while(0)
 
-#define R300_PRINT_STATE(r300, atom) \
-               r300PrintStateAtom(r300, &r300->hw.atom)
-
-/* Fire the buffered vertices no matter what.
-   TODO: This has not been implemented yet
- */
-#define R300_FIREVERTICES( r300 )                      \
-do {                                                   \
-    \
-   if ( (r300)->cmdbuf.count_used || (r300)->dma.flush ) {     \
-      r300Flush( (r300)->radeon.glCtx );               \
-   }                                                   \
-    \
-} while (0)
-
-// 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);
+void r300VapCntl(r300ContextPtr rmesa, GLuint input_count, GLuint output_count, GLuint temp_count);
+void r300SetupVAP(GLcontext *ctx, GLuint InputsRead, GLuint OutputsWritten);
 
 #endif                         /* __R300_STATE_H__ */
index ba3621b16b232bef0d8f2774d427f0fa9da49f2f..ce4179208ebba26579c219b74147c76242a67fa0 100644 (file)
@@ -28,362 +28,237 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 /*
  * Authors:
  *   Dave Airlie <airlied@linux.ie>
+ *   Maciej Cencora <m.cencora@gmail.com>
  */
 
-/* derived from r200 swtcl path */
-
-
-
-#include "main/glheader.h"
-#include "main/mtypes.h"
-#include "main/colormac.h"
-#include "main/enums.h"
-#include "main/image.h"
-#include "main/imports.h"
-#include "main/light.h"
-#include "main/macros.h"
-
-#include "swrast/s_context.h"
-#include "swrast/s_fog.h"
-#include "swrast_setup/swrast_setup.h"
-#include "math/m_translate.h"
 #include "tnl/tnl.h"
-#include "tnl/t_context.h"
 #include "tnl/t_pipeline.h"
 
-#include "r300_context.h"
-#include "r300_swtcl.h"
 #include "r300_state.h"
-#include "r300_ioctl.h"
+#include "r300_swtcl.h"
 #include "r300_emit.h"
-#include "r300_mem.h"
-
-static void flush_last_swtcl_prim( r300ContextPtr rmesa  );
+#include "r300_tex.h"
+#include "r300_render.h"
 
-
-void r300EmitVertexAOS(r300ContextPtr rmesa, GLuint vertex_size, GLuint offset);
-void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vertex_nr);
 #define EMIT_ATTR( ATTR, STYLE )                                       \
 do {                                                                   \
-   rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].attrib = (ATTR);  \
-   rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].format = (STYLE); \
-   rmesa->swtcl.vertex_attr_count++;                                   \
+   rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].attrib = (ATTR);    \
+   rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].format = (STYLE);   \
+   rmesa->radeon.swtcl.vertex_attr_count++;                                    \
 } while (0)
 
 #define EMIT_PAD( N )                                                  \
 do {                                                                   \
-   rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].attrib = 0;               \
-   rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].format = EMIT_PAD;        \
-   rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].offset = (N);             \
-   rmesa->swtcl.vertex_attr_count++;                                   \
+   rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].attrib = 0;         \
+   rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].format = EMIT_PAD;  \
+   rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].offset = (N);               \
+   rmesa->radeon.swtcl.vertex_attr_count++;                                    \
+} while (0)
+
+#define ADD_ATTR(_attr, _format, _dst_loc, _swizzle, _write_mask, _normalize) \
+do { \
+       attrs[num_attrs].element = (_attr); \
+       attrs[num_attrs].data_type = (_format); \
+       attrs[num_attrs].dst_loc = (_dst_loc); \
+       attrs[num_attrs].swizzle = (_swizzle); \
+       attrs[num_attrs].write_mask = (_write_mask); \
+       attrs[num_attrs]._signed = 0; \
+       attrs[num_attrs].normalize = (_normalize); \
+       ++num_attrs; \
 } while (0)
 
-static void r300SetVertexFormat( GLcontext *ctx )
+void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *_InputsRead,  GLuint *_OutputsWritten)
 {
        r300ContextPtr rmesa = R300_CONTEXT( ctx );
        TNLcontext *tnl = TNL_CONTEXT(ctx);
        struct vertex_buffer *VB = &tnl->vb;
-       DECLARE_RENDERINPUTS(index_bitset);
-       GLuint InputsRead = 0, OutputsWritten = 0;
-       int vap_fmt_1 = 0;
-       int offset = 0;
-       int vte = 0;
-       int fog_id;
-       GLint inputs[VERT_ATTRIB_MAX];
-       GLint tab[VERT_ATTRIB_MAX];
-       int swizzle[VERT_ATTRIB_MAX][4];
-       GLuint i, nr;
-       GLuint sz;
-
-       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 );
-       rmesa->swtcl.vertex_attr_count = 0;
-
-       /* EMIT_ATTR's must be in order as they tell t_vertex.c how to
-        * build up a hardware vertex.
-        */
-       if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POS)) {
-               sz = VB->AttribPtr[VERT_ATTRIB_POS]->size;
-               InputsRead |= 1 << VERT_ATTRIB_POS;
-               OutputsWritten |= 1 << VERT_RESULT_HPOS;
-               EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_1F + sz - 1 );
-               offset = sz;
-       } else {
-               offset = 4;
-               EMIT_PAD(4 * sizeof(float));
-       }
-/*
-       if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POINTSIZE )) {
-               EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F );
-               offset += 1;
-       }
-*/
-       if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_COLOR0)) {
-               sz = VB->AttribPtr[VERT_ATTRIB_COLOR0]->size;
-               rmesa->swtcl.coloroffset = offset;
+       int first_free_tex = 0;
+       GLuint InputsRead = 0;
+       GLuint OutputsWritten = 0;
+       int num_attrs = 0;
+       GLuint fp_reads = ctx->FragmentProgram._Current->Base.InputsRead;
+       struct vertex_attribute *attrs = rmesa->vbuf.attribs;
+
+       rmesa->swtcl.coloroffset = rmesa->swtcl.specoffset = 0;
+       rmesa->radeon.swtcl.vertex_attr_count = 0;
+
+       /* We always want non Ndc coords format */
+       VB->AttribPtr[VERT_ATTRIB_POS] = VB->ClipPtr;
+
+       /* Always write position vector */
+       InputsRead |= 1 << VERT_ATTRIB_POS;
+       OutputsWritten |= 1 << VERT_RESULT_HPOS;
+       EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F );
+       ADD_ATTR(VERT_ATTRIB_POS, R300_DATA_TYPE_FLOAT_4, SWTCL_OVM_POS, SWIZZLE_XYZW, MASK_XYZW, 0);
+       rmesa->swtcl.coloroffset = 4;
+
+       if (fp_reads & FRAG_BIT_COL0) {
                InputsRead |= 1 << VERT_ATTRIB_COLOR0;
                OutputsWritten |= 1 << VERT_RESULT_COL0;
-               EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_1F + sz - 1 );
-               offset += sz;
+#if MESA_LITTLE_ENDIAN
+               EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_RGBA );
+               ADD_ATTR(VERT_ATTRIB_COLOR0, R300_DATA_TYPE_BYTE, SWTCL_OVM_COLOR0, SWIZZLE_XYZW, MASK_XYZW, 1);
+#else
+               EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_ABGR );
+               ADD_ATTR(VERT_ATTRIB_COLOR0, R300_DATA_TYPE_BYTE, SWTCL_OVM_COLOR0, SWIZZLE_XYZW, MASK_XYZW, 1);
+#endif
        }
 
-       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_1F + sz - 1 );
+       if (fp_reads & FRAG_BIT_COL1) {
+               GLuint swiz = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ONE);
                InputsRead |= 1 << VERT_ATTRIB_COLOR1;
                OutputsWritten |= 1 << VERT_RESULT_COL1;
+#if MESA_LITTLE_ENDIAN
+               EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4UB_4F_RGBA );
+               ADD_ATTR(VERT_ATTRIB_COLOR1, R300_DATA_TYPE_BYTE, SWTCL_OVM_COLOR1, swiz, MASK_XYZW, 1);
+#else
+               EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4UB_4F_ABGR );
+               ADD_ATTR(VERT_ATTRIB_COLOR1, R300_DATA_TYPE_BYTE, SWTCL_OVM_COLOR1, swiz, MASK_XYZW, 1);
+#endif
+               rmesa->swtcl.specoffset = rmesa->swtcl.coloroffset + 1;
        }
 
-       fog_id = -1;
-       if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_FOG)) {
-               /* find first free tex coord slot */
-               if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) {
-                       int i;
-                       for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
-                               if (!RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(i) )) {
-                                       fog_id = i;
-                                       break;
-                               }
-                       }
-               } else {
-                       fog_id = 0;
-               }
-
-               if (fog_id == -1) {
-                       fprintf(stderr, "\tout of free texcoords to do fog\n");
-                       _mesa_exit(-1);
+       if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) {
+               VB->AttribPtr[VERT_ATTRIB_GENERIC0] = VB->ColorPtr[1];
+               OutputsWritten |= 1 << VERT_RESULT_BFC0;
+#if MESA_LITTLE_ENDIAN
+               EMIT_ATTR( _TNL_ATTRIB_GENERIC0, EMIT_4UB_4F_RGBA );
+               ADD_ATTR(VERT_ATTRIB_GENERIC0, R300_DATA_TYPE_BYTE, SWTCL_OVM_COLOR2, SWIZZLE_XYZW, MASK_XYZW, 1);
+#else
+               EMIT_ATTR( _TNL_ATTRIB_GENERIC0, EMIT_4UB_4F_ABGR );
+               ADD_ATTR(VERT_ATTRIB_GENERIC0, R300_DATA_TYPE_BYTE, SWTCL_OVM_COLOR2, SWIZZLE_XYZW, MASK_XYZW, 1);
+#endif
+               if (fp_reads & FRAG_BIT_COL1) {
+                       VB->AttribPtr[VERT_ATTRIB_GENERIC1] = VB->SecondaryColorPtr[1];
+                       GLuint swiz = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ONE);
+                       OutputsWritten |= 1 << VERT_RESULT_BFC1;
+#if MESA_LITTLE_ENDIAN
+                       EMIT_ATTR( _TNL_ATTRIB_GENERIC1, EMIT_4UB_4F_RGBA );
+                       ADD_ATTR(VERT_ATTRIB_GENERIC1, R300_DATA_TYPE_BYTE, SWTCL_OVM_COLOR3, swiz, MASK_XYZW, 1);
+#else
+                       EMIT_ATTR( _TNL_ATTRIB_GENERIC1, EMIT_4UB_4F_ABGR );
+                       ADD_ATTR(VERT_ATTRIB_GENERIC1, R300_DATA_TYPE_BYTE, SWTCL_OVM_COLOR3, swiz, MASK_XYZW, 1);
+#endif
                }
+       }
 
-               sz = VB->AttribPtr[VERT_ATTRIB_FOG]->size;
-               EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1F + sz - 1);
-               InputsRead |= 1 << VERT_ATTRIB_FOG;
-               OutputsWritten |= 1 << VERT_RESULT_FOGC;
-               vap_fmt_1 |= sz << (3 * fog_id);
+       if (RENDERINPUTS_TEST(tnl->render_inputs_bitset, _TNL_ATTRIB_POINTSIZE )) {
+               GLuint swiz = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ZERO);
+               InputsRead |= 1 << VERT_ATTRIB_POINT_SIZE;
+               OutputsWritten |= 1 << VERT_RESULT_PSIZ;
+               EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F );
+               ADD_ATTR(VERT_ATTRIB_POINT_SIZE, R300_DATA_TYPE_FLOAT_1, SWTCL_OVM_POINT_SIZE, swiz, MASK_X, 0);
        }
 
-       if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) {
+       /**
+        *  Sending only one texcoord component may lead to lock up,
+        *  so for all textures always output 4 texcoord components to RS.
+        */
+       {
                int i;
-
+               GLuint swiz, format, hw_format;
                for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
-                       if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(i) )) {
-                               sz = VB->TexCoordPtr[i]->size;
+                       if (fp_reads & FRAG_BIT_TEX(i)) {
+                               switch (VB->TexCoordPtr[i]->size) {
+                                       case 1:
+                                               format = EMIT_1F;
+                                               hw_format = R300_DATA_TYPE_FLOAT_1;
+                                               swiz = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE);
+                                               break;
+                                       case 2:
+                                               format = EMIT_2F;
+                                               hw_format = R300_DATA_TYPE_FLOAT_2;
+                                               swiz = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_ZERO, SWIZZLE_ONE);
+                                               break;
+                                       case 3:
+                                               format = EMIT_3F;
+                                               hw_format = R300_DATA_TYPE_FLOAT_3;
+                                               swiz = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ONE);
+                                               break;
+                                       case 4:
+                                               format = EMIT_4F;
+                                               hw_format = R300_DATA_TYPE_FLOAT_4;
+                                               swiz = SWIZZLE_XYZW;
+                                               break;
+                                       default:
+                                               continue;
+                               }
                                InputsRead |= 1 << (VERT_ATTRIB_TEX0 + i);
                                OutputsWritten |= 1 << (VERT_RESULT_TEX0 + i);
-                               EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_1F + sz - 1 );
-                               vap_fmt_1 |= sz << (3 * i);
+                               EMIT_ATTR(_TNL_ATTRIB_TEX(i), format);
+                               ADD_ATTR(VERT_ATTRIB_TEX0 + i, hw_format, SWTCL_OVM_TEX(first_free_tex), swiz, MASK_XYZW, 0);
+                               ++first_free_tex;
                        }
                }
        }
 
        /* RS can't put fragment position on the pixel stack, so stuff it in texcoord if needed */
-       if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POS) && (ctx->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_WPOS)) {
-               int first_free_tex = -1;
-               if (fog_id >= 0) {
-                       first_free_tex = fog_id+1;
-               } else {
-                       if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) {
-                               int i;
-                               for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
-                                       if (!RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(i) )) {
-                                               first_free_tex = i;
-                                               break;
-                                       }
-                               }
-                       } else {
-                               first_free_tex = 0;
-                       }
-               }
-
-               if (first_free_tex == -1) {
+       if (fp_reads & FRAG_BIT_WPOS) {
+               if (first_free_tex >= ctx->Const.MaxTextureUnits) {
                        fprintf(stderr, "\tout of free texcoords to write w pos\n");
                        _mesa_exit(-1);
                }
 
-               sz = VB->AttribPtr[VERT_ATTRIB_POS]->size;
                InputsRead |= 1 << (VERT_ATTRIB_TEX0 + first_free_tex);
                OutputsWritten |= 1 << (VERT_RESULT_TEX0 + first_free_tex);
-               EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_1F + sz - 1 );
-               vap_fmt_1 |= sz << (3 * first_free_tex);
-       }
-
-       for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++) {
-               if (InputsRead & (1 << i)) {
-                       inputs[i] = nr++;
-               } else {
-                       inputs[i] = -1;
-               }
+               EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F );
+               ADD_ATTR(VERT_ATTRIB_POS, R300_DATA_TYPE_FLOAT_4, SWTCL_OVM_TEX(first_free_tex), SWIZZLE_XYZW, MASK_XYZW, 0);
+               ++first_free_tex;
        }
 
-       /* Fixed, apply to vir0 only */
-       if (InputsRead & (1 << VERT_ATTRIB_POS))
-               inputs[VERT_ATTRIB_POS] = 0;
-       if (InputsRead & (1 << VERT_ATTRIB_COLOR0))
-               inputs[VERT_ATTRIB_COLOR0] = 2;
-       if (InputsRead & (1 << VERT_ATTRIB_COLOR1))
-               inputs[VERT_ATTRIB_COLOR1] = 3;
-       if (InputsRead & (1 << VERT_ATTRIB_FOG))
-               inputs[VERT_ATTRIB_FOG] = 6 + fog_id;
-       for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++)
-               if (InputsRead & (1 << i))
-                       inputs[i] = 6 + (i - VERT_ATTRIB_TEX0);
-
-       for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++) {
-               if (InputsRead & (1 << i)) {
-                       tab[nr++] = i;
+       if (fp_reads & FRAG_BIT_FOGC) {
+               if (first_free_tex >= ctx->Const.MaxTextureUnits) {
+                       fprintf(stderr, "\tout of free texcoords to write fog coordinate\n");
+                       _mesa_exit(-1);
                }
-       }
-
-       for (i = 0; i < nr; i++) {
-               int ci;
 
-               swizzle[i][0] = SWIZZLE_ZERO;
-               swizzle[i][1] = SWIZZLE_ZERO;
-               swizzle[i][2] = SWIZZLE_ZERO;
-               swizzle[i][3] = SWIZZLE_ONE;
-
-               for (ci = 0; ci < VB->AttribPtr[tab[i]]->size; ci++) {
-                       swizzle[i][ci] = ci;
-               }
+               InputsRead |= 1 << VERT_ATTRIB_FOG;
+               OutputsWritten |= 1 << VERT_RESULT_FOGC;
+               GLuint swiz = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ZERO);
+               EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1F );
+               ADD_ATTR(VERT_ATTRIB_FOG, R300_DATA_TYPE_FLOAT_1, SWTCL_OVM_TEX(first_free_tex), swiz, MASK_XYZW, 0);
        }
 
        R300_NEWPRIM(rmesa);
-       R300_STATECHANGE(rmesa, vir[0]);
-       ((drm_r300_cmd_header_t *) rmesa->hw.vir[0].cmd)->packet0.count =
-               r300VAPInputRoute0(&rmesa->hw.vir[0].cmd[R300_VIR_CNTL_0],
-                                  VB->AttribPtr, inputs, tab, nr);
-       R300_STATECHANGE(rmesa, vir[1]);
-       ((drm_r300_cmd_header_t *) rmesa->hw.vir[1].cmd)->packet0.count =
-               r300VAPInputRoute1(&rmesa->hw.vir[1].cmd[R300_VIR_CNTL_0], swizzle,
-                                  nr);
-
-       R300_STATECHANGE(rmesa, vic);
-       rmesa->hw.vic.cmd[R300_VIC_CNTL_0] = r300VAPInputCntl0(ctx, InputsRead);
-       rmesa->hw.vic.cmd[R300_VIC_CNTL_1] = r300VAPInputCntl1(ctx, InputsRead);
-
-       R300_STATECHANGE(rmesa, vof);
-       rmesa->hw.vof.cmd[R300_VOF_CNTL_0] = r300VAPOutputCntl0(ctx, OutputsWritten);
-       rmesa->hw.vof.cmd[R300_VOF_CNTL_1] = vap_fmt_1;
-
-       rmesa->swtcl.vertex_size =
-               _tnl_install_attrs( ctx,
-                                   rmesa->swtcl.vertex_attrs,
-                                   rmesa->swtcl.vertex_attr_count,
-                                   NULL, 0 );
-
-       rmesa->swtcl.vertex_size /= 4;
+       rmesa->vbuf.num_attribs = num_attrs;
+       *_InputsRead = InputsRead;
+       *_OutputsWritten = OutputsWritten;
 
-       RENDERINPUTS_COPY( rmesa->tnl_index_bitset, index_bitset );
-
-
-       R300_STATECHANGE(rmesa, vte);
-       rmesa->hw.vte.cmd[1] = vte;
-       rmesa->hw.vte.cmd[2] = rmesa->swtcl.vertex_size;
+       RENDERINPUTS_COPY(rmesa->render_inputs_bitset, tnl->render_inputs_bitset);
 }
 
-
-/* Flush vertices in the current dma region.
- */
-static void flush_last_swtcl_prim( r300ContextPtr rmesa  )
+static void r300PrepareVertices(GLcontext *ctx)
 {
-       if (RADEON_DEBUG & DEBUG_IOCTL)
-               fprintf(stderr, "%s\n", __FUNCTION__);
-
-       rmesa->dma.flush = NULL;
-
-       if (rmesa->dma.current.buf) {
-               struct r300_dma_region *current = &rmesa->dma.current;
-               GLuint current_offset = GET_START(current);
-
-               assert (current->start +
-                       rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 ==
-                       current->ptr);
-
-               if (rmesa->dma.current.start != rmesa->dma.current.ptr) {
-
-                       r300EnsureCmdBufSpace( rmesa, rmesa->hw.max_state_size + (12*sizeof(int)), __FUNCTION__);
-
-                       r300EmitState(rmesa);
-
-                       r300EmitVertexAOS( rmesa,
-                                          rmesa->swtcl.vertex_size,
-                                          current_offset);
+       r300ContextPtr rmesa = R300_CONTEXT(ctx);
+       GLuint InputsRead, OutputsWritten;
 
-                       r300EmitVbufPrim( rmesa,
-                                         rmesa->swtcl.hw_primitive,
-                                         rmesa->swtcl.numverts);
+       r300ChooseSwtclVertexFormat(ctx, &InputsRead, &OutputsWritten);
+       r300SetupVAP(ctx, InputsRead, OutputsWritten);
 
-                       r300EmitCacheFlush(rmesa);
-               }
+       rmesa->radeon.swtcl.vertex_size =
+               _tnl_install_attrs( ctx,
+                                   rmesa->radeon.swtcl.vertex_attrs,
+                                   rmesa->radeon.swtcl.vertex_attr_count,
+                                   NULL, 0 );
 
-               rmesa->swtcl.numverts = 0;
-               current->start = current->ptr;
-       }
+       rmesa->radeon.swtcl.vertex_size /= 4;
 }
 
-/* Alloc space in the current dma region.
- */
-static void *
-r300AllocDmaLowVerts( r300ContextPtr rmesa, int nverts, int vsize )
-{
-       GLuint bytes = vsize * nverts;
-
-       if ( rmesa->dma.current.ptr + bytes > rmesa->dma.current.end )
-               r300RefillCurrentDmaRegion( rmesa, bytes);
-
-       if (!rmesa->dma.flush) {
-               rmesa->radeon.glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
-               rmesa->dma.flush = flush_last_swtcl_prim;
-       }
-
-       ASSERT( vsize == rmesa->swtcl.vertex_size * 4 );
-       ASSERT( rmesa->dma.flush == flush_last_swtcl_prim );
-       ASSERT( rmesa->dma.current.start +
-               rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 ==
-               rmesa->dma.current.ptr );
-
-       {
-               GLubyte *head = (GLubyte *) (rmesa->dma.current.address + rmesa->dma.current.ptr);
-               rmesa->dma.current.ptr += bytes;
-               rmesa->swtcl.numverts += nverts;
-               return head;
-       }
-}
 
 static GLuint reduced_prim[] = {
-  GL_POINTS,
-  GL_LINES,
-  GL_LINES,
-  GL_LINES,
-  GL_TRIANGLES,
-  GL_TRIANGLES,
-  GL_TRIANGLES,
-  GL_TRIANGLES,
-  GL_TRIANGLES,
-  GL_TRIANGLES,
+       GL_POINTS,
+       GL_LINES,
+       GL_LINES,
+       GL_LINES,
+       GL_TRIANGLES,
+       GL_TRIANGLES,
+       GL_TRIANGLES,
+       GL_TRIANGLES,
+       GL_TRIANGLES,
+       GL_TRIANGLES,
 };
 
 static void r300RasterPrimitive( GLcontext *ctx, GLuint prim );
-static void r300RenderPrimitive( GLcontext *ctx, GLenum prim );
-//static void r300ResetLineStipple( GLcontext *ctx );
 
 /***********************************************************************
  *                    Emit primitives as inline vertices               *
@@ -405,15 +280,13 @@ static void r300RenderPrimitive( GLcontext *ctx, GLenum prim );
 #undef LOCAL_VARS
 #undef ALLOC_VERTS
 #define CTX_ARG r300ContextPtr rmesa
-#define GET_VERTEX_DWORDS() rmesa->swtcl.vertex_size
-#define ALLOC_VERTS( n, size ) r300AllocDmaLowVerts( rmesa, n, size * 4 )
+#define GET_VERTEX_DWORDS() rmesa->radeon.swtcl.vertex_size
+#define ALLOC_VERTS( n, size ) rcommonAllocDmaLowVerts( &rmesa->radeon, n, size * 4 )
 #define LOCAL_VARS                                             \
    r300ContextPtr rmesa = R300_CONTEXT(ctx);           \
-   const char *r300verts = (char *)rmesa->swtcl.verts;
+   const char *r300verts = (char *)rmesa->radeon.swtcl.verts;
 #define VERT(x) (r300Vertex *)(r300verts + ((x) * vertsize * sizeof(int)))
 #define VERTEX r300Vertex
-#define DO_DEBUG_VERTS (1 && (RADEON_DEBUG & DEBUG_VERTS))
-#define PRINT_VERTEX(x)
 #undef TAG
 #define TAG(x) r300_##x
 #include "tnl_dd/t_dd_triemit.h"
@@ -433,9 +306,8 @@ static void r300RenderPrimitive( GLcontext *ctx, GLenum prim );
  *              Build render functions from dd templates               *
  ***********************************************************************/
 
-#define R300_TWOSIDE_BIT       0x01
-#define R300_UNFILLED_BIT      0x02
-#define R300_MAX_TRIFUNC       0x04
+#define R300_UNFILLED_BIT      0x01
+#define R300_MAX_TRIFUNC       0x02
 
 static struct {
    tnl_points_func             points;
@@ -446,9 +318,9 @@ static struct {
 
 #define DO_FALLBACK  0
 #define DO_UNFILLED (IND & R300_UNFILLED_BIT)
-#define DO_TWOSIDE  (IND & R300_TWOSIDE_BIT)
+#define DO_TWOSIDE   0
 #define DO_FLAT      0
-#define DO_OFFSET     0
+#define DO_OFFSET    0
 #define DO_TRI       1
 #define DO_QUAD      1
 #define DO_LINE      1
@@ -468,33 +340,39 @@ static struct {
 #define VERT_Y(_v) _v->v.y
 #define VERT_Z(_v) _v->v.z
 #define AREA_IS_CCW( a ) (a < 0)
-#define GET_VERTEX(e) (rmesa->swtcl.verts + (e*rmesa->swtcl.vertex_size*sizeof(int)))
-
-/* Only used to pull back colors into vertices (ie, we know color is
- * floating point).
- */
-#define R300_COLOR( dst, src )                         \
-do {                                                   \
-   UNCLAMPED_FLOAT_TO_UBYTE((dst)[0], (src)[2]);       \
-   UNCLAMPED_FLOAT_TO_UBYTE((dst)[1], (src)[1]);       \
-   UNCLAMPED_FLOAT_TO_UBYTE((dst)[2], (src)[0]);       \
-   UNCLAMPED_FLOAT_TO_UBYTE((dst)[3], (src)[3]);       \
+#define GET_VERTEX(e) (rmesa->radeon.swtcl.verts + (e*rmesa->radeon.swtcl.vertex_size*sizeof(int)))
+
+#define VERT_SET_RGBA( v, c ) \
+do { \
+   r300_color_t *color = (r300_color_t *)&((v)->ui[coloroffset]); \
+   UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \
+   UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \
+   UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \
+   UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]); \
 } while (0)
 
-#define VERT_SET_RGBA( v, c )    if (coloroffset) R300_COLOR( v->ub4[coloroffset], c )
-#define VERT_COPY_RGBA( v0, v1 ) if (coloroffset) v0->ui[coloroffset] = v1->ui[coloroffset]
-#define VERT_SAVE_RGBA( idx )    if (coloroffset) color[idx] = v[idx]->ui[coloroffset]
-#define VERT_RESTORE_RGBA( idx ) if (coloroffset) v[idx]->ui[coloroffset] = color[idx]
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
+
+#define VERT_SET_SPEC( v0, c ) \
+do { \
+   if (specoffset) { \
+   UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.red, (c)[0]); \
+   UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.green, (c)[1]); \
+   UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.blue, (c)[2]); \
+   } \
+} while (0)
 
-#define R300_SPEC( dst, src )                          \
-do {                                                   \
-   UNCLAMPED_FLOAT_TO_UBYTE((dst)[0], (src)[2]);       \
-   UNCLAMPED_FLOAT_TO_UBYTE((dst)[1], (src)[1]);       \
-   UNCLAMPED_FLOAT_TO_UBYTE((dst)[2], (src)[0]);       \
+#define VERT_COPY_SPEC( v0, v1 ) \
+do { \
+   if (specoffset) { \
+       v0->v.specular.red = v1->v.specular.red; \
+       v0->v.specular.green = v1->v.specular.green; \
+       v0->v.specular.blue = v1->v.specular.blue; \
+   } \
 } while (0)
 
-#define VERT_SET_SPEC( v, c )    if (specoffset) R300_SPEC( v->ub4[specoffset], c )
-#define VERT_COPY_SPEC( v0, v1 ) if (specoffset) COPY_3V(v0->ub4[specoffset], v1->ub4[specoffset])
+#define VERT_SAVE_RGBA( idx )    color[idx] = v[idx]->ui[coloroffset]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
 #define VERT_SAVE_SPEC( idx )    if (specoffset) spec[idx] = v[idx]->ui[specoffset]
 #define VERT_RESTORE_SPEC( idx ) if (specoffset) v[idx]->ui[specoffset] = spec[idx]
 
@@ -514,7 +392,7 @@ do {                                                        \
  ***********************************************************************/
 
 #define RASTERIZE(x) r300RasterPrimitive( ctx, reduced_prim[x] )
-#define RENDER_PRIMITIVE rmesa->swtcl.render_primitive
+#define RENDER_PRIMITIVE rmesa->radeon.swtcl.render_primitive
 #undef TAG
 #define TAG(x) x
 #include "tnl_dd/t_dd_unfilled.h"
@@ -530,26 +408,15 @@ do {                                                      \
 #define TAG(x) x
 #include "tnl_dd/t_dd_tritmp.h"
 
-#define IND (R300_TWOSIDE_BIT)
-#define TAG(x) x##_twoside
-#include "tnl_dd/t_dd_tritmp.h"
-
 #define IND (R300_UNFILLED_BIT)
 #define TAG(x) x##_unfilled
 #include "tnl_dd/t_dd_tritmp.h"
 
-#define IND (R300_TWOSIDE_BIT|R300_UNFILLED_BIT)
-#define TAG(x) x##_twoside_unfilled
-#include "tnl_dd/t_dd_tritmp.h"
-
-
 
 static void init_rast_tab( void )
 {
    init();
-   init_twoside();
    init_unfilled();
-   init_twoside_unfilled();
 }
 
 /**********************************************************************/
@@ -571,8 +438,8 @@ static void init_rast_tab( void )
 #undef LOCAL_VARS
 #define LOCAL_VARS                                             \
    r300ContextPtr rmesa = R300_CONTEXT(ctx);           \
-   const GLuint vertsize = rmesa->swtcl.vertex_size;           \
-   const char *r300verts = (char *)rmesa->swtcl.verts;         \
+   const GLuint vertsize = rmesa->radeon.swtcl.vertex_size;            \
+   const char *r300verts = (char *)rmesa->radeon.swtcl.verts;          \
    const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts;       \
    const GLboolean stipple = ctx->Line.StippleFlag;            \
    (void) elt; (void) stipple;
@@ -601,10 +468,9 @@ static void r300ChooseRenderState( GLcontext *ctx )
        GLuint index = 0;
        GLuint flags = ctx->_TriangleCaps;
 
-       if (flags & DD_TRI_LIGHT_TWOSIDE) index |= R300_TWOSIDE_BIT;
        if (flags & DD_TRI_UNFILLED)      index |= R300_UNFILLED_BIT;
 
-       if (index != rmesa->swtcl.RenderIndex) {
+       if (index != rmesa->radeon.swtcl.RenderIndex) {
                tnl->Driver.Render.Points = rast_tab[index].points;
                tnl->Driver.Render.Line = rast_tab[index].line;
                tnl->Driver.Render.ClippedLine = rast_tab[index].line;
@@ -621,30 +487,32 @@ static void r300ChooseRenderState( GLcontext *ctx )
                        tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon;
                }
 
-               rmesa->swtcl.RenderIndex = index;
+               rmesa->radeon.swtcl.RenderIndex = index;
        }
 }
 
 
-static void r300RenderStart(GLcontext *ctx)
+void r300RenderStart(GLcontext *ctx)
 {
-        r300ContextPtr rmesa = R300_CONTEXT( ctx );
+       r300ContextPtr rmesa = R300_CONTEXT( ctx );
 
        r300ChooseRenderState(ctx);
-       r300SetVertexFormat(ctx);
+       r300PrepareVertices(ctx);
+
+       r300ValidateBuffers(ctx);
 
        r300UpdateShaders(rmesa);
        r300UpdateShaderStates(rmesa);
 
        r300EmitCacheFlush(rmesa);
 
-       if (rmesa->dma.flush != 0 &&
-           rmesa->dma.flush != flush_last_swtcl_prim)
-               rmesa->dma.flush( rmesa );
-
+       /* investigate if we can put back flush optimisation if needed */
+       if (rmesa->radeon.dma.flush != NULL) {
+               rmesa->radeon.dma.flush(ctx);
+       }
 }
 
-static void r300RenderFinish(GLcontext *ctx)
+void r300RenderFinish(GLcontext *ctx)
 {
 }
 
@@ -652,28 +520,26 @@ static void r300RasterPrimitive( GLcontext *ctx, GLuint hwprim )
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
 
-       if (rmesa->swtcl.hw_primitive != hwprim) {
-               R300_NEWPRIM( rmesa );
-               rmesa->swtcl.hw_primitive = hwprim;
+       if (rmesa->radeon.swtcl.hw_primitive != hwprim) {
+               R300_NEWPRIM( rmesa );
+               rmesa->radeon.swtcl.hw_primitive = hwprim;
        }
 }
 
-static void r300RenderPrimitive(GLcontext *ctx, GLenum prim)
+void r300RenderPrimitive(GLcontext *ctx, GLenum prim)
 {
 
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       rmesa->swtcl.render_primitive = prim;
+       rmesa->radeon.swtcl.render_primitive = prim;
 
        if ((prim == GL_TRIANGLES) && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
-         return;
+               return;
 
        r300RasterPrimitive( ctx, reduced_prim[prim] );
 }
 
-static void r300ResetLineStipple(GLcontext *ctx)
+void r300ResetLineStipple(GLcontext *ctx)
 {
-
-
 }
 
 void r300InitSwtcl(GLcontext *ctx)
@@ -699,50 +565,68 @@ void r300InitSwtcl(GLcontext *ctx)
        _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
                            48 * sizeof(GLfloat) );
 
-       rmesa->swtcl.verts = (GLubyte *)tnl->clipspace.vertex_buf;
-       rmesa->swtcl.RenderIndex = ~0;
-       rmesa->swtcl.render_primitive = GL_TRIANGLES;
-       rmesa->swtcl.hw_primitive = 0;
+       rmesa->radeon.swtcl.verts = (GLubyte *)tnl->clipspace.vertex_buf;
+       rmesa->radeon.swtcl.RenderIndex = ~0;
+       rmesa->radeon.swtcl.render_primitive = GL_TRIANGLES;
+       rmesa->radeon.swtcl.hw_primitive = 0;
 
        _tnl_invalidate_vertex_state( ctx, ~0 );
        _tnl_invalidate_vertices( ctx, ~0 );
-       RENDERINPUTS_ZERO( rmesa->tnl_index_bitset );
 
        _tnl_need_projected_coords( ctx, GL_FALSE );
-       r300ChooseRenderState(ctx);
 }
 
 void r300DestroySwtcl(GLcontext *ctx)
 {
 }
 
-void r300EmitVertexAOS(r300ContextPtr rmesa, GLuint vertex_size, GLuint offset)
+static void r300EmitVertexAOS(r300ContextPtr rmesa, GLuint vertex_size, struct radeon_bo *bo, GLuint offset)
 {
-       int cmd_reserved = 0;
-       int cmd_written = 0;
+       BATCH_LOCALS(&rmesa->radeon);
 
-       drm_radeon_cmd_header_t *cmd = NULL;
        if (RADEON_DEBUG & DEBUG_VERTS)
-         fprintf(stderr, "%s:  vertex_size %d, offset 0x%x \n",
-                 __FUNCTION__, vertex_size, offset);
-
-       start_packet3(CP_PACKET3(R300_PACKET3_3D_LOAD_VBPNTR, 2), 2);
-       e32(1);
-       e32(vertex_size | (vertex_size << 8));
-       e32(offset);
+               fprintf(stderr, "%s:  vertex_size %d, offset 0x%x \n",
+                       __FUNCTION__, vertex_size, offset);
+
+       BEGIN_BATCH(7);
+       OUT_BATCH_PACKET3(R300_PACKET3_3D_LOAD_VBPNTR, 2);
+       OUT_BATCH(1);
+       OUT_BATCH(vertex_size | (vertex_size << 8));
+       OUT_BATCH_RELOC(offset, bo, offset, RADEON_GEM_DOMAIN_GTT, 0, 0);
+       END_BATCH();
 }
 
-void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vertex_nr)
+static void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vertex_nr)
 {
-
-       int cmd_reserved = 0;
-       int cmd_written = 0;
+       BATCH_LOCALS(&rmesa->radeon);
        int type, num_verts;
-       drm_radeon_cmd_header_t *cmd = NULL;
 
        type = r300PrimitiveType(rmesa, primitive);
        num_verts = r300NumVerts(rmesa, vertex_nr, primitive);
 
-       start_packet3(CP_PACKET3(R300_PACKET3_3D_DRAW_VBUF_2, 0), 0);
-       e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (num_verts << 16) | type);
+       BEGIN_BATCH(3);
+       OUT_BATCH_PACKET3(R300_PACKET3_3D_DRAW_VBUF_2, 0);
+       OUT_BATCH(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (num_verts << 16) | type);
+       END_BATCH();
+}
+
+void r300_swtcl_flush(GLcontext *ctx, uint32_t current_offset)
+{
+       r300ContextPtr rmesa = R300_CONTEXT(ctx);
+
+       rcommonEnsureCmdBufSpace(&rmesa->radeon,
+                          rmesa->radeon.hw.max_state_size + (12*sizeof(int)),
+                          __FUNCTION__);
+       radeonEmitState(&rmesa->radeon);
+    r300_emit_scissor(ctx);
+       r300EmitVertexAOS(rmesa,
+                       rmesa->radeon.swtcl.vertex_size,
+                       rmesa->radeon.dma.current,
+                       current_offset);
+
+       r300EmitVbufPrim(rmesa,
+                  rmesa->radeon.swtcl.hw_primitive,
+                  rmesa->radeon.swtcl.numverts);
+       r300EmitCacheFlush(rmesa);
+       COMMIT_BATCH();
 }
index 55df53c1adff05346fc4cae7233167a0cec023f1..c271d2654687875d4eb3124480c5b5bf07c8d587 100644 (file)
@@ -39,7 +39,27 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "swrast/swrast.h"
 #include "r300_context.h"
 
+/*
+ * Here are definitions of OVM locations of vertex attributes for non TCL hw
+ */
+#define SWTCL_OVM_POS 0
+#define SWTCL_OVM_COLOR0 2
+#define SWTCL_OVM_COLOR1 3
+#define SWTCL_OVM_COLOR2 4
+#define SWTCL_OVM_COLOR3 5
+#define SWTCL_OVM_TEX(n) ((n) + 6)
+#define SWTCL_OVM_POINT_SIZE 15
+
+extern void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *InputsRead,  GLuint *OutputsWritten);
+
 extern void r300InitSwtcl( GLcontext *ctx );
 extern void r300DestroySwtcl( GLcontext *ctx );
 
+extern void r300RenderStart(GLcontext *ctx);
+extern void r300RenderFinish(GLcontext *ctx);
+extern void r300RenderPrimitive(GLcontext *ctx, GLenum prim);
+extern void r300ResetLineStipple(GLcontext *ctx);
+
+extern void r300_swtcl_flush(GLcontext *ctx, uint32_t current_offset);
+
 #endif
index 7c699ec572c7bd2a85fbfb7d8fce373378c2d11f..0af5bb4f469b3114017f48d9a71278a973e38148 100644 (file)
@@ -38,6 +38,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/context.h"
 #include "main/enums.h"
 #include "main/image.h"
+#include "main/mipmap.h"
 #include "main/simple_list.h"
 #include "main/texformat.h"
 #include "main/texstore.h"
@@ -49,6 +50,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r300_context.h"
 #include "r300_state.h"
 #include "r300_ioctl.h"
+#include "radeon_mipmap_tree.h"
 #include "r300_tex.h"
 
 #include "xmlpool.h"
@@ -77,20 +79,20 @@ static unsigned int translate_wrap_mode(GLenum wrapmode)
  *
  * \param t Texture object whose wrap modes are to be set
  */
-static void r300UpdateTexWrap(r300TexObjPtr t)
+static void r300UpdateTexWrap(radeonTexObjPtr t)
 {
-       struct gl_texture_object *tObj = t->base.tObj;
+       struct gl_texture_object *tObj = &t->base;
 
-       t->filter &=
+       t->pp_txfilter &=
            ~(R300_TX_WRAP_S_MASK | R300_TX_WRAP_T_MASK | R300_TX_WRAP_R_MASK);
 
-       t->filter |= translate_wrap_mode(tObj->WrapS) << R300_TX_WRAP_S_SHIFT;
+       t->pp_txfilter |= translate_wrap_mode(tObj->WrapS) << R300_TX_WRAP_S_SHIFT;
 
        if (tObj->Target != GL_TEXTURE_1D) {
-               t->filter |= translate_wrap_mode(tObj->WrapT) << R300_TX_WRAP_T_SHIFT;
+               t->pp_txfilter |= translate_wrap_mode(tObj->WrapT) << R300_TX_WRAP_T_SHIFT;
 
                if (tObj->Target == GL_TEXTURE_3D)
-                       t->filter |= translate_wrap_mode(tObj->WrapR) << R300_TX_WRAP_R_SHIFT;
+                       t->pp_txfilter |= translate_wrap_mode(tObj->WrapR) << R300_TX_WRAP_R_SHIFT;
        }
 }
 
@@ -117,10 +119,13 @@ static GLuint aniso_filter(GLfloat anisotropy)
  * \param magf Texture magnification mode
  * \param anisotropy Maximum anisotropy level
  */
-static void r300SetTexFilter(r300TexObjPtr t, GLenum minf, GLenum magf, GLfloat anisotropy)
+static void r300SetTexFilter(radeonTexObjPtr t, GLenum minf, GLenum magf, GLfloat anisotropy)
 {
-       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;
+       /* Force revalidation to account for switches from/to mipmapping. */
+       t->validated = GL_FALSE;
+
+       t->pp_txfilter &= ~(R300_TX_MIN_FILTER_MASK | R300_TX_MIN_FILTER_MIP_MASK | R300_TX_MAG_FILTER_MASK | R300_TX_MAX_ANISO_MASK);
+       t->pp_txfilter_1 &= ~R300_EDGE_ANISO_EDGE_ONLY;
 
        /* Note that EXT_texture_filter_anisotropic is extremely vague about
         * how anisotropic filtering interacts with the "normal" filter modes.
@@ -128,7 +133,7 @@ static void r300SetTexFilter(r300TexObjPtr t, GLenum minf, GLenum magf, GLfloat
         * 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
+               t->pp_txfilter |= R300_TX_MAG_FILTER_ANISO
                        | R300_TX_MIN_FILTER_ANISO
                        | R300_TX_MIN_FILTER_MIP_LINEAR
                        | aniso_filter(anisotropy);
@@ -139,22 +144,22 @@ static void r300SetTexFilter(r300TexObjPtr t, GLenum minf, GLenum magf, GLfloat
 
        switch (minf) {
        case GL_NEAREST:
-               t->filter |= R300_TX_MIN_FILTER_NEAREST;
+               t->pp_txfilter |= R300_TX_MIN_FILTER_NEAREST;
                break;
        case GL_LINEAR:
-               t->filter |= R300_TX_MIN_FILTER_LINEAR;
+               t->pp_txfilter |= R300_TX_MIN_FILTER_LINEAR;
                break;
        case GL_NEAREST_MIPMAP_NEAREST:
-               t->filter |= R300_TX_MIN_FILTER_NEAREST|R300_TX_MIN_FILTER_MIP_NEAREST;
+               t->pp_txfilter |= 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;
+               t->pp_txfilter |= 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;
+               t->pp_txfilter |= 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;
+               t->pp_txfilter |= R300_TX_MIN_FILTER_LINEAR|R300_TX_MIN_FILTER_MIP_LINEAR;
                break;
        }
 
@@ -163,15 +168,15 @@ static void r300SetTexFilter(r300TexObjPtr t, GLenum minf, GLenum magf, GLfloat
         */
        switch (magf) {
        case GL_NEAREST:
-               t->filter |= R300_TX_MAG_FILTER_NEAREST;
+               t->pp_txfilter |= R300_TX_MAG_FILTER_NEAREST;
                break;
        case GL_LINEAR:
-               t->filter |= R300_TX_MAG_FILTER_LINEAR;
+               t->pp_txfilter |= R300_TX_MAG_FILTER_LINEAR;
                break;
        }
 }
 
-static void r300SetTexBorderColor(r300TexObjPtr t, const GLfloat color[4])
+static void r300SetTexBorderColor(radeonTexObjPtr t, const GLfloat color[4])
 {
        GLubyte c[4];
        CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]);
@@ -181,729 +186,6 @@ static void r300SetTexBorderColor(r300TexObjPtr t, const GLfloat color[4])
        t->pp_border_color = PACK_COLOR_8888(c[3], c[0], c[1], c[2]);
 }
 
-/**
- * Allocate space for and load the mesa images into the texture memory block.
- * This will happen before drawing with a new texture, or drawing with a
- * texture after it was swapped out or teximaged again.
- */
-
-static r300TexObjPtr r300AllocTexObj(struct gl_texture_object *texObj)
-{
-       r300TexObjPtr t;
-
-       t = CALLOC_STRUCT(r300_tex_obj);
-       texObj->DriverData = t;
-       if (t != NULL) {
-               if (RADEON_DEBUG & DEBUG_TEXTURE) {
-                       fprintf(stderr, "%s( %p, %p )\n", __FUNCTION__,
-                               (void *)texObj, (void *)t);
-               }
-
-               /* Initialize non-image-dependent parts of the state:
-                */
-               t->base.tObj = texObj;
-               t->border_fallback = GL_FALSE;
-
-               make_empty_list(&t->base);
-
-               r300UpdateTexWrap(t);
-               r300SetTexFilter(t, texObj->MinFilter, texObj->MagFilter, texObj->MaxAnisotropy);
-               r300SetTexBorderColor(t, texObj->BorderColor);
-       }
-
-       return t;
-}
-
-/* try to find a format which will only need a memcopy */
-static const struct gl_texture_format *r300Choose8888TexFormat(GLenum srcFormat,
-                                                              GLenum srcType)
-{
-       const GLuint ui = 1;
-       const GLubyte littleEndian = *((const GLubyte *)&ui);
-
-       if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
-           (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
-           (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
-           (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && littleEndian)) {
-               return &_mesa_texformat_rgba8888;
-       } else if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
-                  (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && littleEndian) ||
-                  (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
-                  (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && !littleEndian)) {
-               return &_mesa_texformat_rgba8888_rev;
-       } else if (srcFormat == GL_BGRA && ((srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
-                                           srcType == GL_UNSIGNED_INT_8_8_8_8)) {
-               return &_mesa_texformat_argb8888_rev;
-       } else if (srcFormat == GL_BGRA && ((srcType == GL_UNSIGNED_BYTE && littleEndian) ||
-                                           srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) {
-               return &_mesa_texformat_argb8888;
-       } else
-               return _dri_texformat_argb8888;
-}
-
-static const struct gl_texture_format *r300ChooseTextureFormat(GLcontext * ctx,
-                                                              GLint
-                                                              internalFormat,
-                                                              GLenum format,
-                                                              GLenum type)
-{
-       r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       const GLboolean do32bpt =
-           (rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32);
-       const GLboolean force16bpt =
-           (rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16);
-       (void)format;
-
-#if 0
-       fprintf(stderr, "InternalFormat=%s(%d) type=%s format=%s\n",
-               _mesa_lookup_enum_by_nr(internalFormat), internalFormat,
-               _mesa_lookup_enum_by_nr(type), _mesa_lookup_enum_by_nr(format));
-       fprintf(stderr, "do32bpt=%d force16bpt=%d\n", do32bpt, force16bpt);
-#endif
-
-       switch (internalFormat) {
-       case 4:
-       case GL_RGBA:
-       case GL_COMPRESSED_RGBA:
-               switch (type) {
-               case GL_UNSIGNED_INT_10_10_10_2:
-               case GL_UNSIGNED_INT_2_10_10_10_REV:
-                       return do32bpt ? _dri_texformat_argb8888 :
-                           _dri_texformat_argb1555;
-               case GL_UNSIGNED_SHORT_4_4_4_4:
-               case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-                       return _dri_texformat_argb4444;
-               case GL_UNSIGNED_SHORT_5_5_5_1:
-               case GL_UNSIGNED_SHORT_1_5_5_5_REV:
-                       return _dri_texformat_argb1555;
-               default:
-                       return do32bpt ? r300Choose8888TexFormat(format, type) :
-                           _dri_texformat_argb4444;
-               }
-
-       case 3:
-       case GL_RGB:
-       case GL_COMPRESSED_RGB:
-               switch (type) {
-               case GL_UNSIGNED_SHORT_4_4_4_4:
-               case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-                       return _dri_texformat_argb4444;
-               case GL_UNSIGNED_SHORT_5_5_5_1:
-               case GL_UNSIGNED_SHORT_1_5_5_5_REV:
-                       return _dri_texformat_argb1555;
-               case GL_UNSIGNED_SHORT_5_6_5:
-               case GL_UNSIGNED_SHORT_5_6_5_REV:
-                       return _dri_texformat_rgb565;
-               default:
-                       return do32bpt ? _dri_texformat_argb8888 :
-                           _dri_texformat_rgb565;
-               }
-
-       case GL_RGBA8:
-       case GL_RGB10_A2:
-       case GL_RGBA12:
-       case GL_RGBA16:
-               return !force16bpt ?
-                   r300Choose8888TexFormat(format,
-                                           type) : _dri_texformat_argb4444;
-
-       case GL_RGBA4:
-       case GL_RGBA2:
-               return _dri_texformat_argb4444;
-
-       case GL_RGB5_A1:
-               return _dri_texformat_argb1555;
-
-       case GL_RGB8:
-       case GL_RGB10:
-       case GL_RGB12:
-       case GL_RGB16:
-               return !force16bpt ? _dri_texformat_argb8888 :
-                   _dri_texformat_rgb565;
-
-       case GL_RGB5:
-       case GL_RGB4:
-       case GL_R3_G3_B2:
-               return _dri_texformat_rgb565;
-
-       case GL_ALPHA:
-       case GL_ALPHA4:
-       case GL_ALPHA8:
-       case GL_ALPHA12:
-       case GL_ALPHA16:
-       case GL_COMPRESSED_ALPHA:
-               return _dri_texformat_a8;
-
-       case 1:
-       case GL_LUMINANCE:
-       case GL_LUMINANCE4:
-       case GL_LUMINANCE8:
-       case GL_LUMINANCE12:
-       case GL_LUMINANCE16:
-       case GL_COMPRESSED_LUMINANCE:
-               return _dri_texformat_l8;
-
-       case 2:
-       case GL_LUMINANCE_ALPHA:
-       case GL_LUMINANCE4_ALPHA4:
-       case GL_LUMINANCE6_ALPHA2:
-       case GL_LUMINANCE8_ALPHA8:
-       case GL_LUMINANCE12_ALPHA4:
-       case GL_LUMINANCE12_ALPHA12:
-       case GL_LUMINANCE16_ALPHA16:
-       case GL_COMPRESSED_LUMINANCE_ALPHA:
-               return _dri_texformat_al88;
-
-       case GL_INTENSITY:
-       case GL_INTENSITY4:
-       case GL_INTENSITY8:
-       case GL_INTENSITY12:
-       case GL_INTENSITY16:
-       case GL_COMPRESSED_INTENSITY:
-               return _dri_texformat_i8;
-
-       case GL_YCBCR_MESA:
-               if (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
-                   type == GL_UNSIGNED_BYTE)
-                       return &_mesa_texformat_ycbcr;
-               else
-                       return &_mesa_texformat_ycbcr_rev;
-
-       case GL_RGB_S3TC:
-       case GL_RGB4_S3TC:
-       case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-               return &_mesa_texformat_rgb_dxt1;
-
-       case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-               return &_mesa_texformat_rgba_dxt1;
-
-       case GL_RGBA_S3TC:
-       case GL_RGBA4_S3TC:
-       case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
-               return &_mesa_texformat_rgba_dxt3;
-
-       case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
-               return &_mesa_texformat_rgba_dxt5;
-
-       case GL_ALPHA16F_ARB:
-               return &_mesa_texformat_alpha_float16;
-       case GL_ALPHA32F_ARB:
-               return &_mesa_texformat_alpha_float32;
-       case GL_LUMINANCE16F_ARB:
-               return &_mesa_texformat_luminance_float16;
-       case GL_LUMINANCE32F_ARB:
-               return &_mesa_texformat_luminance_float32;
-       case GL_LUMINANCE_ALPHA16F_ARB:
-               return &_mesa_texformat_luminance_alpha_float16;
-       case GL_LUMINANCE_ALPHA32F_ARB:
-               return &_mesa_texformat_luminance_alpha_float32;
-       case GL_INTENSITY16F_ARB:
-               return &_mesa_texformat_intensity_float16;
-       case GL_INTENSITY32F_ARB:
-               return &_mesa_texformat_intensity_float32;
-       case GL_RGB16F_ARB:
-               return &_mesa_texformat_rgba_float16;
-       case GL_RGB32F_ARB:
-               return &_mesa_texformat_rgba_float32;
-       case GL_RGBA16F_ARB:
-               return &_mesa_texformat_rgba_float16;
-       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",
-                             (int)internalFormat);
-               return NULL;
-       }
-
-       return NULL;            /* never get here */
-}
-
-static GLboolean
-r300ValidateClientStorage(GLcontext * ctx, GLenum target,
-                         GLint internalFormat,
-                         GLint srcWidth, GLint srcHeight,
-                         GLenum format, GLenum type, const void *pixels,
-                         const struct gl_pixelstore_attrib *packing,
-                         struct gl_texture_object *texObj,
-                         struct gl_texture_image *texImage)
-{
-       r300ContextPtr rmesa = R300_CONTEXT(ctx);
-
-       if (RADEON_DEBUG & DEBUG_TEXTURE)
-               fprintf(stderr, "intformat %s format %s type %s\n",
-                       _mesa_lookup_enum_by_nr(internalFormat),
-                       _mesa_lookup_enum_by_nr(format),
-                       _mesa_lookup_enum_by_nr(type));
-
-       if (!ctx->Unpack.ClientStorage)
-               return 0;
-
-       if (ctx->_ImageTransferState ||
-           texImage->IsCompressed || texObj->GenerateMipmap)
-               return 0;
-
-       /* This list is incomplete, may be different on ppc???
-        */
-       switch (internalFormat) {
-       case GL_RGBA:
-               if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV) {
-                       texImage->TexFormat = _dri_texformat_argb8888;
-               } else
-                       return 0;
-               break;
-
-       case GL_RGB:
-               if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) {
-                       texImage->TexFormat = _dri_texformat_rgb565;
-               } else
-                       return 0;
-               break;
-
-       case GL_YCBCR_MESA:
-               if (format == GL_YCBCR_MESA &&
-                   type == GL_UNSIGNED_SHORT_8_8_REV_APPLE) {
-                       texImage->TexFormat = &_mesa_texformat_ycbcr_rev;
-               } else if (format == GL_YCBCR_MESA &&
-                          (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
-                           type == GL_UNSIGNED_BYTE)) {
-                       texImage->TexFormat = &_mesa_texformat_ycbcr;
-               } else
-                       return 0;
-               break;
-
-       default:
-               return 0;
-       }
-
-       /* Could deal with these packing issues, but currently don't:
-        */
-       if (packing->SkipPixels ||
-           packing->SkipRows || packing->SwapBytes || packing->LsbFirst) {
-               return 0;
-       }
-
-       GLint srcRowStride = _mesa_image_row_stride(packing, srcWidth,
-                                                   format, type);
-
-       if (RADEON_DEBUG & DEBUG_TEXTURE)
-               fprintf(stderr, "%s: srcRowStride %d/%x\n",
-                       __FUNCTION__, srcRowStride, srcRowStride);
-
-       /* Could check this later in upload, pitch restrictions could be
-        * relaxed, but would need to store the image pitch somewhere,
-        * as packing details might change before image is uploaded:
-        */
-       if (!r300IsGartMemory(rmesa, pixels, srcHeight * srcRowStride)
-           || (srcRowStride & 63))
-               return 0;
-
-       /* Have validated that _mesa_transfer_teximage would be a straight
-        * memcpy at this point.  NOTE: future calls to TexSubImage will
-        * overwrite the client data.  This is explicitly mentioned in the
-        * extension spec.
-        */
-       texImage->Data = (void *)pixels;
-       texImage->IsClientData = GL_TRUE;
-       texImage->RowStride = srcRowStride / texImage->TexFormat->TexelBytes;
-
-       return 1;
-}
-
-static void r300TexImage1D(GLcontext * ctx, GLenum target, GLint level,
-                          GLint internalFormat,
-                          GLint width, GLint border,
-                          GLenum format, GLenum type, const GLvoid * pixels,
-                          const struct gl_pixelstore_attrib *packing,
-                          struct gl_texture_object *texObj,
-                          struct gl_texture_image *texImage)
-{
-       driTextureObject *t = (driTextureObject *) texObj->DriverData;
-
-       if (t) {
-               driSwapOutTextureObject(t);
-       } else {
-               t = (driTextureObject *) r300AllocTexObj(texObj);
-               if (!t) {
-                       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
-                       return;
-               }
-       }
-
-       /* Note, this will call ChooseTextureFormat */
-       _mesa_store_teximage1d(ctx, target, level, internalFormat,
-                              width, border, format, type, pixels,
-                              &ctx->Unpack, texObj, texImage);
-
-       t->dirty_images[0] |= (1 << level);
-}
-
-static void r300TexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
-                             GLint xoffset,
-                             GLsizei width,
-                             GLenum format, GLenum type,
-                             const GLvoid * pixels,
-                             const struct gl_pixelstore_attrib *packing,
-                             struct gl_texture_object *texObj,
-                             struct gl_texture_image *texImage)
-{
-       driTextureObject *t = (driTextureObject *) texObj->DriverData;
-
-       assert(t);              /* this _should_ be true */
-       if (t) {
-               driSwapOutTextureObject(t);
-       } else {
-               t = (driTextureObject *) r300AllocTexObj(texObj);
-               if (!t) {
-                       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
-                       return;
-               }
-       }
-
-       _mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
-                                 format, type, pixels, packing, texObj,
-                                 texImage);
-
-       t->dirty_images[0] |= (1 << level);
-}
-
-static void r300TexImage2D(GLcontext * ctx, GLenum target, GLint level,
-                          GLint internalFormat,
-                          GLint width, GLint height, GLint border,
-                          GLenum format, GLenum type, const GLvoid * pixels,
-                          const struct gl_pixelstore_attrib *packing,
-                          struct gl_texture_object *texObj,
-                          struct gl_texture_image *texImage)
-{
-       driTextureObject *t = (driTextureObject *) texObj->DriverData;
-       GLuint face;
-
-       /* which cube face or ordinary 2D image */
-       switch (target) {
-       case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
-       case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
-       case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
-       case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
-       case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
-       case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
-               face =
-                   (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
-               ASSERT(face < 6);
-               break;
-       default:
-               face = 0;
-       }
-
-       if (t != NULL) {
-               driSwapOutTextureObject(t);
-       } else {
-               t = (driTextureObject *) r300AllocTexObj(texObj);
-               if (!t) {
-                       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
-                       return;
-               }
-       }
-
-       texImage->IsClientData = GL_FALSE;
-
-       if (r300ValidateClientStorage(ctx, target,
-                                     internalFormat,
-                                     width, height,
-                                     format, type, pixels,
-                                     packing, texObj, texImage)) {
-               if (RADEON_DEBUG & DEBUG_TEXTURE)
-                       fprintf(stderr, "%s: Using client storage\n",
-                               __FUNCTION__);
-       } else {
-               if (RADEON_DEBUG & DEBUG_TEXTURE)
-                       fprintf(stderr, "%s: Using normal storage\n",
-                               __FUNCTION__);
-
-               /* Normal path: copy (to cached memory) and eventually upload
-                * via another copy to GART memory and then a blit...  Could
-                * eliminate one copy by going straight to (permanent) GART.
-                *
-                * Note, this will call r300ChooseTextureFormat.
-                */
-               _mesa_store_teximage2d(ctx, target, level, internalFormat,
-                                      width, height, border, format, type,
-                                      pixels, &ctx->Unpack, texObj, texImage);
-
-               t->dirty_images[face] |= (1 << level);
-       }
-}
-
-static void r300TexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
-                             GLint xoffset, GLint yoffset,
-                             GLsizei width, GLsizei height,
-                             GLenum format, GLenum type,
-                             const GLvoid * pixels,
-                             const struct gl_pixelstore_attrib *packing,
-                             struct gl_texture_object *texObj,
-                             struct gl_texture_image *texImage)
-{
-       driTextureObject *t = (driTextureObject *) texObj->DriverData;
-       GLuint face;
-
-       /* which cube face or ordinary 2D image */
-       switch (target) {
-       case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
-       case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
-       case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
-       case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
-       case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
-       case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
-               face =
-                   (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
-               ASSERT(face < 6);
-               break;
-       default:
-               face = 0;
-       }
-
-       assert(t);              /* this _should_ be true */
-       if (t) {
-               driSwapOutTextureObject(t);
-       } else {
-               t = (driTextureObject *) r300AllocTexObj(texObj);
-               if (!t) {
-                       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
-                       return;
-               }
-       }
-
-       _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
-                                 height, format, type, pixels, packing, texObj,
-                                 texImage);
-
-       t->dirty_images[face] |= (1 << level);
-}
-
-static void r300CompressedTexImage2D(GLcontext * ctx, GLenum target,
-                                    GLint level, GLint internalFormat,
-                                    GLint width, GLint height, GLint border,
-                                    GLsizei imageSize, const GLvoid * data,
-                                    struct gl_texture_object *texObj,
-                                    struct gl_texture_image *texImage)
-{
-       driTextureObject *t = (driTextureObject *) texObj->DriverData;
-       GLuint face;
-
-       /* which cube face or ordinary 2D image */
-       switch (target) {
-       case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
-       case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
-       case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
-       case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
-       case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
-       case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
-               face =
-                   (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
-               ASSERT(face < 6);
-               break;
-       default:
-               face = 0;
-       }
-
-       if (t != NULL) {
-               driSwapOutTextureObject(t);
-       } else {
-               t = (driTextureObject *) r300AllocTexObj(texObj);
-               if (!t) {
-                       _mesa_error(ctx, GL_OUT_OF_MEMORY,
-                                   "glCompressedTexImage2D");
-                       return;
-               }
-       }
-
-       texImage->IsClientData = GL_FALSE;
-
-       /* can't call this, different parameters. Would never evaluate to true anyway currently */
-#if 0
-       if (r300ValidateClientStorage(ctx, target,
-                                     internalFormat,
-                                     width, height,
-                                     format, type, pixels,
-                                     packing, texObj, texImage)) {
-               if (RADEON_DEBUG & DEBUG_TEXTURE)
-                       fprintf(stderr, "%s: Using client storage\n",
-                               __FUNCTION__);
-       } else
-#endif
-       {
-               if (RADEON_DEBUG & DEBUG_TEXTURE)
-                       fprintf(stderr, "%s: Using normal storage\n",
-                               __FUNCTION__);
-
-               /* Normal path: copy (to cached memory) and eventually upload
-                * via another copy to GART memory and then a blit...  Could
-                * eliminate one copy by going straight to (permanent) GART.
-                *
-                * Note, this will call r300ChooseTextureFormat.
-                */
-               _mesa_store_compressed_teximage2d(ctx, target, level,
-                                                 internalFormat, width, height,
-                                                 border, imageSize, data,
-                                                 texObj, texImage);
-
-               t->dirty_images[face] |= (1 << level);
-       }
-}
-
-static void r300CompressedTexSubImage2D(GLcontext * ctx, GLenum target,
-                                       GLint level, GLint xoffset,
-                                       GLint yoffset, GLsizei width,
-                                       GLsizei height, GLenum format,
-                                       GLsizei imageSize, const GLvoid * data,
-                                       struct gl_texture_object *texObj,
-                                       struct gl_texture_image *texImage)
-{
-       driTextureObject *t = (driTextureObject *) texObj->DriverData;
-       GLuint face;
-
-       /* which cube face or ordinary 2D image */
-       switch (target) {
-       case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
-       case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
-       case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
-       case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
-       case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
-       case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
-               face =
-                   (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
-               ASSERT(face < 6);
-               break;
-       default:
-               face = 0;
-       }
-
-       assert(t);              /* this _should_ be true */
-       if (t) {
-               driSwapOutTextureObject(t);
-       } else {
-               t = (driTextureObject *) r300AllocTexObj(texObj);
-               if (!t) {
-                       _mesa_error(ctx, GL_OUT_OF_MEMORY,
-                                   "glCompressedTexSubImage3D");
-                       return;
-               }
-       }
-
-       _mesa_store_compressed_texsubimage2d(ctx, target, level, xoffset,
-                                            yoffset, width, height, format,
-                                            imageSize, data, texObj, texImage);
-
-       t->dirty_images[face] |= (1 << level);
-}
-
-static void r300TexImage3D(GLcontext * ctx, GLenum target, GLint level,
-                          GLint internalFormat,
-                          GLint width, GLint height, GLint depth,
-                          GLint border,
-                          GLenum format, GLenum type, const GLvoid * pixels,
-                          const struct gl_pixelstore_attrib *packing,
-                          struct gl_texture_object *texObj,
-                          struct gl_texture_image *texImage)
-{
-       driTextureObject *t = (driTextureObject *) texObj->DriverData;
-
-       if (t) {
-               driSwapOutTextureObject(t);
-       } else {
-               t = (driTextureObject *) r300AllocTexObj(texObj);
-               if (!t) {
-                       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
-                       return;
-               }
-       }
-
-       texImage->IsClientData = GL_FALSE;
-
-#if 0
-       if (r300ValidateClientStorage(ctx, target,
-                                     internalFormat,
-                                     width, height,
-                                     format, type, pixels,
-                                     packing, texObj, texImage)) {
-               if (RADEON_DEBUG & DEBUG_TEXTURE)
-                       fprintf(stderr, "%s: Using client storage\n",
-                               __FUNCTION__);
-       } else
-#endif
-       {
-               if (RADEON_DEBUG & DEBUG_TEXTURE)
-                       fprintf(stderr, "%s: Using normal storage\n",
-                               __FUNCTION__);
-
-               /* Normal path: copy (to cached memory) and eventually upload
-                * via another copy to GART memory and then a blit...  Could
-                * eliminate one copy by going straight to (permanent) GART.
-                *
-                * Note, this will call r300ChooseTextureFormat.
-                */
-               _mesa_store_teximage3d(ctx, target, level, internalFormat,
-                                      width, height, depth, border,
-                                      format, type, pixels,
-                                      &ctx->Unpack, texObj, texImage);
-
-               t->dirty_images[0] |= (1 << level);
-       }
-}
-
-static void
-r300TexSubImage3D(GLcontext * ctx, GLenum target, GLint level,
-                 GLint xoffset, GLint yoffset, GLint zoffset,
-                 GLsizei width, GLsizei height, GLsizei depth,
-                 GLenum format, GLenum type,
-                 const GLvoid * pixels,
-                 const struct gl_pixelstore_attrib *packing,
-                 struct gl_texture_object *texObj,
-                 struct gl_texture_image *texImage)
-{
-       driTextureObject *t = (driTextureObject *) texObj->DriverData;
-
-/*     fprintf(stderr, "%s\n", __FUNCTION__); */
-
-       assert(t);              /* this _should_ be true */
-       if (t) {
-               driSwapOutTextureObject(t);
-       } else {
-               t = (driTextureObject *) r300AllocTexObj(texObj);
-               if (!t) {
-                       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage3D");
-                       return;
-               }
-               texObj->DriverData = t;
-       }
-
-       _mesa_store_texsubimage3d(ctx, target, level, xoffset, yoffset, zoffset,
-                                 width, height, depth,
-                                 format, type, pixels, packing, texObj,
-                                 texImage);
-
-       t->dirty_images[0] |= (1 << level);
-}
-
 /**
  * Changes variables and flags for a state update, which will happen at the
  * next UpdateTextureState
@@ -913,7 +195,7 @@ static void r300TexParameter(GLcontext * ctx, GLenum target,
                             struct gl_texture_object *texObj,
                             GLenum pname, const GLfloat * params)
 {
-       r300TexObjPtr t = (r300TexObjPtr) texObj->DriverData;
+       radeonTexObj* t = radeon_tex_obj(texObj);
 
        if (RADEON_DEBUG & (DEBUG_STATE | DEBUG_TEXTURE)) {
                fprintf(stderr, "%s( %s )\n", __FUNCTION__,
@@ -946,7 +228,11 @@ static void r300TexParameter(GLcontext * ctx, GLenum target,
                 * we just have to rely on loading the right subset of mipmap levels
                 * to simulate a clamped LOD.
                 */
-               driSwapOutTextureObject((driTextureObject *) t);
+               if (t->mt) {
+                       radeon_miptree_unreference(t->mt);
+                       t->mt = 0;
+                       t->validated = GL_FALSE;
+               }
                break;
 
        case GL_DEPTH_TEXTURE_MODE:
@@ -969,27 +255,10 @@ static void r300TexParameter(GLcontext * ctx, GLenum target,
        }
 }
 
-static void r300BindTexture(GLcontext * ctx, GLenum target,
-                           struct gl_texture_object *texObj)
-{
-       if (RADEON_DEBUG & (DEBUG_STATE | DEBUG_TEXTURE)) {
-               fprintf(stderr, "%s( %p ) unit=%d\n", __FUNCTION__,
-                       (void *)texObj, ctx->Texture.CurrentUnit);
-       }
-
-       if ((target == GL_TEXTURE_1D)
-           || (target == GL_TEXTURE_2D)
-           || (target == GL_TEXTURE_3D)
-           || (target == GL_TEXTURE_CUBE_MAP)
-           || (target == GL_TEXTURE_RECTANGLE_NV)) {
-               assert(texObj->DriverData != NULL);
-       }
-}
-
 static void r300DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       driTextureObject *t = (driTextureObject *) texObj->DriverData;
+       radeonTexObj* t = radeon_tex_obj(texObj);
 
        if (RADEON_DEBUG & (DEBUG_STATE | DEBUG_TEXTURE)) {
                fprintf(stderr, "%s( %p (target = %s) )\n", __FUNCTION__,
@@ -997,14 +266,24 @@ static void r300DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
                        _mesa_lookup_enum_by_nr(texObj->Target));
        }
 
-       if (t != NULL) {
-               if (rmesa) {
-                       R300_FIREVERTICES(rmesa);
-               }
+       if (rmesa) {
+               int i;
+               radeon_firevertices(&rmesa->radeon);
+
+               for(i = 0; i < R300_MAX_TEXTURE_UNITS; ++i)
+                       if (rmesa->hw.textures[i] == t)
+                               rmesa->hw.textures[i] = 0;
+       }
 
-               driDestroyTextureObject(t);
+       if (t->bo) {
+               radeon_bo_unref(t->bo);
+               t->bo = NULL;
+       }
+
+       if (t->mt) {
+               radeon_miptree_unreference(t->mt);
+               t->mt = 0;
        }
-       /* Free mipmap images and the texture object itself */
        _mesa_delete_texture_object(ctx, texObj);
 }
 
@@ -1013,8 +292,6 @@ static void r300DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
  * Called via ctx->Driver.NewTextureObject.
  * Note: this function will be called during context creation to
  * allocate the default texture objects.
- * Note: we could use containment here to 'derive' the driver-specific
- * texture object from the core mesa gl_texture_object.  Not done at this time.
  * Fixup MaxAnisotropy according to user preference.
  */
 static struct gl_texture_object *r300NewTextureObject(GLcontext * ctx,
@@ -1022,14 +299,23 @@ static struct gl_texture_object *r300NewTextureObject(GLcontext * ctx,
                                                      GLenum target)
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       struct gl_texture_object *obj;
-       obj = _mesa_new_texture_object(ctx, name, target);
-       if (!obj)
-               return NULL;
-       obj->MaxAnisotropy = rmesa->initialMaxAnisotropy;
+       radeonTexObj* t = CALLOC_STRUCT(radeon_tex_obj);
+
 
-       r300AllocTexObj(obj);
-       return obj;
+       if (RADEON_DEBUG & (DEBUG_STATE | DEBUG_TEXTURE)) {
+               fprintf(stderr, "%s( %p (target = %s) )\n", __FUNCTION__,
+                       t, _mesa_lookup_enum_by_nr(target));
+       }
+
+       _mesa_initialize_texture_object(&t->base, name, target);
+       t->base.MaxAnisotropy = rmesa->radeon.initialMaxAnisotropy;
+
+       /* Initialize hardware state */
+       r300UpdateTexWrap(t);
+       r300SetTexFilter(t, t->base.MinFilter, t->base.MagFilter, t->base.MaxAnisotropy);
+       r300SetTexBorderColor(t, t->base.BorderColor);
+
+       return &t->base;
 }
 
 void r300InitTextureFuncs(struct dd_function_table *functions)
@@ -1037,22 +323,30 @@ void r300InitTextureFuncs(struct dd_function_table *functions)
        /* Note: we only plug in the functions we implement in the driver
         * since _mesa_init_driver_functions() was already called.
         */
-       functions->ChooseTextureFormat = r300ChooseTextureFormat;
-       functions->TexImage1D = r300TexImage1D;
-       functions->TexImage2D = r300TexImage2D;
-       functions->TexImage3D = r300TexImage3D;
-       functions->TexSubImage1D = r300TexSubImage1D;
-       functions->TexSubImage2D = r300TexSubImage2D;
-       functions->TexSubImage3D = r300TexSubImage3D;
+       functions->NewTextureImage = radeonNewTextureImage;
+       functions->FreeTexImageData = radeonFreeTexImageData;
+       functions->MapTexture = radeonMapTexture;
+       functions->UnmapTexture = radeonUnmapTexture;
+
+       functions->ChooseTextureFormat = radeonChooseTextureFormat_mesa;
+       functions->TexImage1D = radeonTexImage1D;
+       functions->TexImage2D = radeonTexImage2D;
+       functions->TexImage3D = radeonTexImage3D;
+       functions->TexSubImage1D = radeonTexSubImage1D;
+       functions->TexSubImage2D = radeonTexSubImage2D;
+       functions->TexSubImage3D = radeonTexSubImage3D;
+       functions->GetTexImage = radeonGetTexImage;
+       functions->GetCompressedTexImage = radeonGetCompressedTexImage;
        functions->NewTextureObject = r300NewTextureObject;
-       functions->BindTexture = r300BindTexture;
        functions->DeleteTexture = r300DeleteTexture;
        functions->IsTextureResident = driIsTextureResident;
 
        functions->TexParameter = r300TexParameter;
 
-       functions->CompressedTexImage2D = r300CompressedTexImage2D;
-       functions->CompressedTexSubImage2D = r300CompressedTexSubImage2D;
+       functions->CompressedTexImage2D = radeonCompressedTexImage2D;
+       functions->CompressedTexSubImage2D = radeonCompressedTexSubImage2D;
+
+       functions->GenerateMipmap = radeonGenerateMipmap;
 
        driInitTextureFormats();
 }
index b86d45bfe050269a1e73ff98ed55bd13f2de7a4a..8a653ea2d11b0b186e384056141f63f9e751562a 100644 (file)
@@ -37,16 +37,17 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 extern void r300SetDepthTexMode(struct gl_texture_object *tObj);
 
+extern void r300SetTexBuffer(__DRIcontext *pDRICtx, GLint target,
+                            __DRIdrawable *dPriv);
+
+extern void r300SetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
+                             GLint format, __DRIdrawable *dPriv);
+
 extern void r300SetTexOffset(__DRIcontext *pDRICtx, GLint texname,
                             unsigned long long offset, GLint depth,
                             GLuint pitch);
 
-extern void r300UpdateTextureState(GLcontext * ctx);
-
-extern int r300UploadTexImages(r300ContextPtr rmesa, r300TexObjPtr t,
-                              GLuint face);
-
-extern void r300DestroyTexObj(r300ContextPtr rmesa, r300TexObjPtr t);
+extern GLboolean r300ValidateBuffers(GLcontext * ctx);
 
 extern void r300InitTextureFuncs(struct dd_function_table *functions);
 
diff --git a/src/mesa/drivers/dri/r300/r300_texmem.c b/src/mesa/drivers/dri/r300/r300_texmem.c
deleted file mode 100644 (file)
index a89ab83..0000000
+++ /dev/null
@@ -1,568 +0,0 @@
-/**************************************************************************
-
-Copyright (C) Tungsten Graphics 2002.  All Rights Reserved.
-The Weather Channel, Inc. funded Tungsten Graphics to develop the
-initial release of the Radeon 8500 driver under the XFree86
-license. This notice must be preserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation on the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR THEIR
-SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-
-**************************************************************************/
-
-/**
- * \file
- *
- * \author Gareth Hughes <gareth@valinux.com>
- *
- * \author Kevin E. Martin <martin@valinux.com>
- */
-
-#include <errno.h>
-
-#include "main/glheader.h"
-#include "main/imports.h"
-#include "main/context.h"
-#include "main/colormac.h"
-#include "main/macros.h"
-#include "main/simple_list.h"
-#include "main/texobj.h"
-#include "radeon_reg.h"                /* gets definition for usleep */
-#include "r300_context.h"
-#include "r300_state.h"
-#include "r300_cmdbuf.h"
-#include "radeon_ioctl.h"
-#include "r300_tex.h"
-#include "r300_ioctl.h"
-#include <unistd.h>            /* for usleep() */
-
-#ifdef USER_BUFFERS
-#include "r300_mem.h"
-#endif
-
-/**
- * Destroy any device-dependent state associated with the texture.  This may
- * include NULLing out hardware state that points to the texture.
- */
-void r300DestroyTexObj(r300ContextPtr rmesa, r300TexObjPtr t)
-{
-       int i;
-
-       if (RADEON_DEBUG & DEBUG_TEXTURE) {
-               fprintf(stderr, "%s( %p, %p )\n", __FUNCTION__,
-                       (void *)t, (void *)t->base.tObj);
-       }
-
-       for (i = 0; i < rmesa->radeon.glCtx->Const.MaxTextureUnits; i++) {
-               if (rmesa->state.texture.unit[i].texobj == t->base.tObj) {
-                       _mesa_reference_texobj(&rmesa->state.texture.unit[i].texobj, NULL);
-               }
-       }
-}
-
-/* ------------------------------------------------------------
- * Texture image conversions
- */
-
-static void r300UploadGARTClientSubImage(r300ContextPtr rmesa,
-                                        r300TexObjPtr t,
-                                        struct gl_texture_image *texImage,
-                                        GLint hwlevel,
-                                        GLint x, GLint y,
-                                        GLint width, GLint height)
-{
-       const struct gl_texture_format *texFormat = texImage->TexFormat;
-       GLuint srcPitch, dstPitch;
-       int blit_format;
-       int srcOffset;
-
-       /*
-        * XXX it appears that we always upload the full image, not a subimage.
-        * I.e. x==0, y==0, width=texWidth, height=texWidth.  If this is ever
-        * changed, the src pitch will have to change.
-        */
-       switch (texFormat->TexelBytes) {
-       case 1:
-               blit_format = R300_CP_COLOR_FORMAT_CI8;
-               srcPitch = t->image[0][0].width * texFormat->TexelBytes;
-               dstPitch = t->image[0][0].width * texFormat->TexelBytes;
-               break;
-       case 2:
-               blit_format = R300_CP_COLOR_FORMAT_RGB565;
-               srcPitch = t->image[0][0].width * texFormat->TexelBytes;
-               dstPitch = t->image[0][0].width * texFormat->TexelBytes;
-               break;
-       case 4:
-               blit_format = R300_CP_COLOR_FORMAT_ARGB8888;
-               srcPitch = t->image[0][0].width * texFormat->TexelBytes;
-               dstPitch = t->image[0][0].width * texFormat->TexelBytes;
-               break;
-       case 8:
-       case 16:
-               blit_format = R300_CP_COLOR_FORMAT_CI8;
-               srcPitch = t->image[0][0].width * texFormat->TexelBytes;
-               dstPitch = t->image[0][0].width * texFormat->TexelBytes;
-               break;
-       default:
-               return;
-       }
-
-       t->image[0][hwlevel].data = texImage->Data;
-       srcOffset = r300GartOffsetFromVirtual(rmesa, texImage->Data);
-
-       assert(srcOffset != ~0);
-
-       /* Don't currently need to cope with small pitches?
-        */
-       width = texImage->Width;
-       height = texImage->Height;
-
-       if (texFormat->TexelBytes > 4) {
-               width *= texFormat->TexelBytes;
-       }
-
-       r300EmitWait(rmesa, R300_WAIT_3D);
-
-       r300EmitBlit(rmesa, blit_format,
-                    srcPitch,
-                    srcOffset,
-                    dstPitch,
-                    t->bufAddr,
-                    x,
-                    y,
-                    t->image[0][hwlevel].x + x,
-                    t->image[0][hwlevel].y + y, width, height);
-
-       r300EmitWait(rmesa, R300_WAIT_2D);
-}
-
-static void r300UploadRectSubImage(r300ContextPtr rmesa,
-                                  r300TexObjPtr t,
-                                  struct gl_texture_image *texImage,
-                                  GLint x, GLint y, GLint width, GLint height)
-{
-       const struct gl_texture_format *texFormat = texImage->TexFormat;
-       int blit_format, dstPitch, done;
-
-       switch (texFormat->TexelBytes) {
-       case 1:
-               blit_format = R300_CP_COLOR_FORMAT_CI8;
-               break;
-       case 2:
-               blit_format = R300_CP_COLOR_FORMAT_RGB565;
-               break;
-       case 4:
-               blit_format = R300_CP_COLOR_FORMAT_ARGB8888;
-               break;
-       case 8:
-       case 16:
-               blit_format = R300_CP_COLOR_FORMAT_CI8;
-               break;
-       default:
-               return;
-       }
-
-       t->image[0][0].data = texImage->Data;
-
-       /* Currently don't need to cope with small pitches.
-        */
-       width = texImage->Width;
-       height = texImage->Height;
-       dstPitch = t->pitch;
-
-       if (texFormat->TexelBytes > 4) {
-               width *= texFormat->TexelBytes;
-       }
-
-       if (rmesa->prefer_gart_client_texturing && texImage->IsClientData) {
-               /* In this case, could also use GART texturing.  This is
-                * currently disabled, but has been tested & works.
-                */
-               t->offset = r300GartOffsetFromVirtual(rmesa, texImage->Data);
-               t->pitch = texImage->RowStride * texFormat->TexelBytes - 32;
-
-               if (RADEON_DEBUG & DEBUG_TEXTURE)
-                       fprintf(stderr,
-                               "Using GART texturing for rectangular client texture\n");
-
-               /* Release FB memory allocated for this image:
-                */
-               /* FIXME This may not be correct as driSwapOutTextureObject sets
-                * FIXME dirty_images.  It may be fine, though.
-                */
-               if (t->base.memBlock) {
-                       driSwapOutTextureObject((driTextureObject *) t);
-               }
-       } else if (texImage->IsClientData) {
-               /* Data already in GART memory, with usable pitch.
-                */
-               GLuint srcPitch;
-               srcPitch = texImage->RowStride * texFormat->TexelBytes;
-               r300EmitBlit(rmesa,
-                            blit_format,
-                            srcPitch,
-                            r300GartOffsetFromVirtual(rmesa, texImage->Data),
-                            dstPitch, t->bufAddr, 0, 0, 0, 0, width, height);
-       } else {
-               /* Data not in GART memory, or bad pitch.
-                */
-               for (done = 0; done < height;) {
-                       struct r300_dma_region region;
-                       int lines =
-                           MIN2(height - done, RADEON_BUFFER_SIZE / dstPitch);
-                       int src_pitch;
-                       char *tex;
-
-                       src_pitch = texImage->RowStride * texFormat->TexelBytes;
-
-                       tex = (char *)texImage->Data + done * src_pitch;
-
-                       memset(&region, 0, sizeof(region));
-                       r300AllocDmaRegion(rmesa, &region, lines * dstPitch,
-                                          1024);
-
-                       /* Copy texdata to dma:
-                        */
-                       if (RADEON_DEBUG & DEBUG_TEXTURE)
-                               fprintf(stderr,
-                                       "%s: src_pitch %d dst_pitch %d\n",
-                                       __FUNCTION__, src_pitch, dstPitch);
-
-                       if (src_pitch == dstPitch) {
-                               memcpy(region.address + region.start, tex,
-                                      lines * src_pitch);
-                       } else {
-                               char *buf = region.address + region.start;
-                               int i;
-                               for (i = 0; i < lines; i++) {
-                                       memcpy(buf, tex, src_pitch);
-                                       buf += dstPitch;
-                                       tex += src_pitch;
-                               }
-                       }
-
-                       r300EmitWait(rmesa, R300_WAIT_3D);
-
-                       /* Blit to framebuffer
-                        */
-                       r300EmitBlit(rmesa,
-                                    blit_format,
-                                    dstPitch, GET_START(&region),
-                                    dstPitch | (t->tile_bits >> 16),
-                                    t->bufAddr, 0, 0, 0, done, width, lines);
-
-                       r300EmitWait(rmesa, R300_WAIT_2D);
-#ifdef USER_BUFFERS
-                       r300_mem_use(rmesa, region.buf->id);
-#endif
-
-                       r300ReleaseDmaRegion(rmesa, &region, __FUNCTION__);
-                       done += lines;
-               }
-       }
-}
-
-/**
- * Upload the texture image associated with texture \a t at the specified
- * level at the address relative to \a start.
- */
-static void r300UploadSubImage(r300ContextPtr rmesa, r300TexObjPtr t,
-                              GLint hwlevel,
-                              GLint x, GLint y, GLint width, GLint height,
-                              GLuint face)
-{
-       struct gl_texture_image *texImage = NULL;
-       GLuint offset;
-       GLint imageWidth, imageHeight;
-       GLint ret;
-       drm_radeon_texture_t tex;
-       drm_radeon_tex_image_t tmp;
-       const int level = hwlevel + t->base.firstLevel;
-
-       if (RADEON_DEBUG & DEBUG_TEXTURE) {
-               fprintf(stderr,
-                       "%s( %p, %p ) level/width/height/face = %d/%d/%d/%u\n",
-                       __FUNCTION__, (void *)t, (void *)t->base.tObj, level,
-                       width, height, face);
-       }
-
-       ASSERT(face < 6);
-
-       /* Ensure we have a valid texture to upload */
-       if ((hwlevel < 0) || (hwlevel >= R300_MAX_TEXTURE_LEVELS)) {
-               _mesa_problem(NULL, "bad texture level in %s", __FUNCTION__);
-               return;
-       }
-
-       texImage = t->base.tObj->Image[face][level];
-
-       if (!texImage) {
-               if (RADEON_DEBUG & DEBUG_TEXTURE)
-                       fprintf(stderr, "%s: texImage %d is NULL!\n",
-                               __FUNCTION__, level);
-               return;
-       }
-       if (!texImage->Data) {
-               if (RADEON_DEBUG & DEBUG_TEXTURE)
-                       fprintf(stderr, "%s: image data is NULL!\n",
-                               __FUNCTION__);
-               return;
-       }
-
-       if (t->base.tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
-               assert(level == 0);
-               assert(hwlevel == 0);
-               if (RADEON_DEBUG & DEBUG_TEXTURE)
-                       fprintf(stderr, "%s: image data is rectangular\n",
-                               __FUNCTION__);
-               r300UploadRectSubImage(rmesa, t, texImage, x, y, width, height);
-               return;
-       } else if (texImage->IsClientData) {
-               if (RADEON_DEBUG & DEBUG_TEXTURE)
-                       fprintf(stderr,
-                               "%s: image data is in GART client storage\n",
-                               __FUNCTION__);
-               r300UploadGARTClientSubImage(rmesa, t, texImage, hwlevel, x, y,
-                                            width, height);
-               return;
-       } else if (RADEON_DEBUG & DEBUG_TEXTURE)
-               fprintf(stderr, "%s: image data is in normal memory\n",
-                       __FUNCTION__);
-
-       imageWidth = texImage->Width;
-       imageHeight = texImage->Height;
-
-       offset = t->bufAddr;
-
-       if (RADEON_DEBUG & (DEBUG_TEXTURE | DEBUG_IOCTL)) {
-               GLint imageX = 0;
-               GLint imageY = 0;
-               GLint blitX = t->image[face][hwlevel].x;
-               GLint blitY = t->image[face][hwlevel].y;
-               GLint blitWidth = t->image[face][hwlevel].width;
-               GLint blitHeight = t->image[face][hwlevel].height;
-               fprintf(stderr, "   upload image: %d,%d at %d,%d\n",
-                       imageWidth, imageHeight, imageX, imageY);
-               fprintf(stderr, "   upload  blit: %d,%d at %d,%d\n",
-                       blitWidth, blitHeight, blitX, blitY);
-               fprintf(stderr, "       blit ofs: 0x%07x level: %d/%d\n",
-                       (GLuint) offset, hwlevel, level);
-       }
-
-       t->image[face][hwlevel].data = texImage->Data;
-
-       /* Init the DRM_RADEON_TEXTURE command / drm_radeon_texture_t struct.
-        * NOTE: we're always use a 1KB-wide blit and I8 texture format.
-        * We used to use 1, 2 and 4-byte texels and used to use the texture
-        * width to dictate the blit width - but that won't work for compressed
-        * textures. (Brian)
-        * NOTE: can't do that with texture tiling. (sroland)
-        */
-       tex.offset = offset;
-       tex.image = &tmp;
-       /* copy (x,y,width,height,data) */
-       memcpy(&tmp, &t->image[face][hwlevel], sizeof(tmp));
-
-       if (texImage->TexFormat->TexelBytes > 4) {
-               const int log2TexelBytes =
-                   (3 + (texImage->TexFormat->TexelBytes >> 4));
-               tex.format = RADEON_TXFORMAT_I8;        /* any 1-byte texel format */
-               tex.pitch =
-                   MAX2((texImage->Width * texImage->TexFormat->TexelBytes) /
-                        64, 1);
-               tex.height = imageHeight;
-               tex.width = imageWidth << log2TexelBytes;
-               tex.offset += (tmp.x << log2TexelBytes) & ~1023;
-               tmp.x = tmp.x % (1024 >> log2TexelBytes);
-               tmp.width = tmp.width << log2TexelBytes;
-       } else if (texImage->TexFormat->TexelBytes) {
-               /* use multi-byte upload scheme */
-               tex.height = imageHeight;
-               tex.width = imageWidth;
-               switch (texImage->TexFormat->TexelBytes) {
-               case 1:
-                       tex.format = RADEON_TXFORMAT_I8;
-                       break;
-               case 2:
-                       tex.format = RADEON_TXFORMAT_AI88;
-                       break;
-               case 4:
-                       tex.format = RADEON_TXFORMAT_ARGB8888;
-                       break;
-               }
-               tex.pitch =
-                   MAX2((texImage->Width * texImage->TexFormat->TexelBytes) /
-                        64, 1);
-               tex.offset += tmp.x & ~1023;
-               tmp.x = tmp.x % 1024;
-
-               if (t->tile_bits & R300_TXO_MICRO_TILE) {
-                       /* need something like "tiled coordinates" ? */
-                       tmp.y = tmp.x / (tex.pitch * 128) * 2;
-                       tmp.x =
-                           tmp.x % (tex.pitch * 128) / 2 /
-                           texImage->TexFormat->TexelBytes;
-                       tex.pitch |= RADEON_DST_TILE_MICRO >> 22;
-               } else {
-                       tmp.x = tmp.x >> (texImage->TexFormat->TexelBytes >> 1);
-               }
-#if 1
-               if ((t->tile_bits & R300_TXO_MACRO_TILE) &&
-                   (texImage->Width * texImage->TexFormat->TexelBytes >= 256)
-                   && ((!(t->tile_bits & R300_TXO_MICRO_TILE)
-                        && (texImage->Height >= 8))
-                       || (texImage->Height >= 16))) {
-                       /* weird: R200 disables macro tiling if mip width is smaller than 256 bytes,
-                          OR if height is smaller than 8 automatically, but if micro tiling is active
-                          the limit is height 16 instead ? */
-                       tex.pitch |= RADEON_DST_TILE_MACRO >> 22;
-               }
-#endif
-       } else {
-               /* In case of for instance 8x8 texture (2x2 dxt blocks),
-                  padding after the first two blocks is needed (only
-                  with dxt1 since 2 dxt3/dxt5 blocks already use 32 Byte). */
-               /* set tex.height to 1/4 since 1 "macropixel" (dxt-block)
-                  has 4 real pixels. Needed so the kernel module reads
-                  the right amount of data. */
-               tex.format = RADEON_TXFORMAT_I8;        /* any 1-byte texel format */
-               tex.pitch = (R300_BLIT_WIDTH_BYTES / 64);
-               tex.height = (imageHeight + 3) / 4;
-               tex.width = (imageWidth + 3) / 4;
-               if ((t->format & R300_TX_FORMAT_DXT1) == R300_TX_FORMAT_DXT1) {
-                       tex.width *= 8;
-               } else {
-                       tex.width *= 16;
-               }
-       }
-
-       LOCK_HARDWARE(&rmesa->radeon);
-       do {
-               ret =
-                   drmCommandWriteRead(rmesa->radeon.dri.fd,
-                                       DRM_RADEON_TEXTURE, &tex,
-                                       sizeof(drm_radeon_texture_t));
-               if (ret) {
-                       if (RADEON_DEBUG & DEBUG_IOCTL)
-                               fprintf(stderr,
-                                       "DRM_RADEON_TEXTURE:  again!\n");
-                       usleep(1);
-               }
-       } while (ret == -EAGAIN);
-
-       UNLOCK_HARDWARE(&rmesa->radeon);
-
-       if (ret) {
-               fprintf(stderr, "DRM_RADEON_TEXTURE: return = %d\n", ret);
-               fprintf(stderr, "   offset=0x%08x\n", offset);
-               fprintf(stderr, "   image width=%d height=%d\n",
-                       imageWidth, imageHeight);
-               fprintf(stderr, "    blit width=%d height=%d data=%p\n",
-                       t->image[face][hwlevel].width,
-                       t->image[face][hwlevel].height,
-                       t->image[face][hwlevel].data);
-               _mesa_exit(-1);
-       }
-}
-
-/**
- * Upload the texture images associated with texture \a t.  This might
- * require the allocation of texture memory.
- *
- * \param rmesa Context pointer
- * \param t Texture to be uploaded
- * \param face Cube map face to be uploaded.  Zero for non-cube maps.
- */
-
-int r300UploadTexImages(r300ContextPtr rmesa, r300TexObjPtr t, GLuint face)
-{
-       const int numLevels = t->base.lastLevel - t->base.firstLevel + 1;
-
-       if (t->image_override)
-               return 0;
-
-       if (RADEON_DEBUG & (DEBUG_TEXTURE | DEBUG_IOCTL)) {
-               fprintf(stderr, "%s( %p, %p ) sz=%d lvls=%d-%d\n", __FUNCTION__,
-                       (void *)rmesa->radeon.glCtx, (void *)t->base.tObj,
-                       t->base.totalSize, t->base.firstLevel,
-                       t->base.lastLevel);
-       }
-
-       if (t->base.totalSize == 0)
-               return 0;
-
-       if (RADEON_DEBUG & DEBUG_SYNC) {
-               fprintf(stderr, "%s: Syncing\n", __FUNCTION__);
-               radeonFinish(rmesa->radeon.glCtx);
-       }
-
-       LOCK_HARDWARE(&rmesa->radeon);
-
-       if (t->base.memBlock == NULL) {
-               int heap;
-
-               heap = driAllocateTexture(rmesa->texture_heaps, rmesa->nr_heaps,
-                                         (driTextureObject *) t);
-               if (heap == -1) {
-                       UNLOCK_HARDWARE(&rmesa->radeon);
-                       return -1;
-               }
-
-               /* Set the base offset of the texture image */
-               t->bufAddr = rmesa->radeon.radeonScreen->texOffset[heap]
-                   + t->base.memBlock->ofs;
-               t->offset = t->bufAddr;
-
-               if (!(t->base.tObj->Image[0][0]->IsClientData)) {
-                       /* hope it's safe to add that here... */
-                       t->offset |= t->tile_bits;
-               }
-       }
-
-       /* Let the world know we've used this memory recently.
-        */
-       driUpdateTextureLRU((driTextureObject *) t);
-       UNLOCK_HARDWARE(&rmesa->radeon);
-
-       /* Upload any images that are new */
-       if (t->base.dirty_images[face]) {
-               int i;
-               for (i = 0; i < numLevels; i++) {
-                       if ((t->base.
-                            dirty_images[face] & (1 <<
-                                                  (i + t->base.firstLevel))) !=
-                           0) {
-                               r300UploadSubImage(rmesa, t, i, 0, 0,
-                                                  t->image[face][i].width,
-                                                  t->image[face][i].height,
-                                                  face);
-                       }
-               }
-               t->base.dirty_images[face] = 0;
-       }
-
-       if (RADEON_DEBUG & DEBUG_SYNC) {
-               fprintf(stderr, "%s: Syncing\n", __FUNCTION__);
-               radeonFinish(rmesa->radeon.glCtx);
-       }
-
-       return 0;
-}
index f6ae4b675b860f3fc474a30b63f10d7d07dbfb3e..6e47321246ab50452aaae8c80c5c11c08ec1e170 100644 (file)
@@ -47,7 +47,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r300_context.h"
 #include "r300_state.h"
 #include "r300_ioctl.h"
-#include "radeon_ioctl.h"
+#include "radeon_mipmap_tree.h"
 #include "r300_tex.h"
 #include "r300_reg.h"
 
@@ -117,7 +117,12 @@ static const struct tx_table {
        _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(S8_Z24, R300_EASY_TX_FORMAT(Y, Y, Y, Y, X24_Y8)),
        _ASSIGN(Z32, R300_EASY_TX_FORMAT(X, X, X, X, X32)),
+       /* EXT_texture_sRGB */
+       _ASSIGN(SRGBA8, R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8) | R300_TX_FORMAT_GAMMA),
+       _ASSIGN(SLA8, R300_EASY_TX_FORMAT(X, X, X, Y, Y8X8) | R300_TX_FORMAT_GAMMA),
+       _ASSIGN(SL8, R300_EASY_TX_FORMAT(X, X, X, ONE, X8) | R300_TX_FORMAT_GAMMA),
        /* *INDENT-ON* */
 };
 
@@ -143,13 +148,12 @@ void r300SetDepthTexMode(struct gl_texture_object *tObj)
                },
        };
        const GLuint *format;
-       r300TexObjPtr t;
+       radeonTexObjPtr t;
 
        if (!tObj)
                return;
 
-       t = (r300TexObjPtr) tObj->DriverData;
-
+       t = radeon_tex_obj(tObj);
 
        switch (tObj->Image[0][tObj->BaseLevel]->TexFormat->MesaFormat) {
        case MESA_FORMAT_Z16:
@@ -171,13 +175,13 @@ void r300SetDepthTexMode(struct gl_texture_object *tObj)
 
        switch (tObj->DepthMode) {
        case GL_LUMINANCE:
-               t->format = format[0];
+               t->pp_txformat = format[0];
                break;
        case GL_INTENSITY:
-               t->format = format[1];
+               t->pp_txformat = format[1];
                break;
        case GL_ALPHA:
-               t->format = format[2];
+               t->pp_txformat = format[2];
                break;
        default:
                /* Error...which should have already been caught by higher
@@ -190,406 +194,134 @@ void r300SetDepthTexMode(struct gl_texture_object *tObj)
 
 
 /**
- * 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).
- * The \c image[face][level].x/y/width/height parameters for upload/blitting
- * are computed here.  \c filter, \c format, etc. will be set here
- * too.
+ * Compute the cached hardware register values for the given texture object.
  *
  * \param rmesa Context pointer
- * \param tObj GL texture object whose images are to be posted to
- *                 hardware state.
+ * \param t the r300 texture object
  */
-static void r300SetTexImages(r300ContextPtr rmesa,
-                            struct gl_texture_object *tObj)
+static void setup_hardware_state(r300ContextPtr rmesa, radeonTexObj *t)
 {
-       r300TexObjPtr t = (r300TexObjPtr) tObj->DriverData;
-       const struct gl_texture_image *baseImage =
-           tObj->Image[0][tObj->BaseLevel];
-       GLint curOffset;
-       GLint i, texelBytes;
-       GLint numLevels;
-       GLint log2Width, log2Height, log2Depth;
-
-       /* Set the hardware texture format
-        */
+       const struct gl_texture_image *firstImage;
+       int firstlevel = t->mt ? t->mt->firstLevel : 0;
+           
+       firstImage = t->base.Image[0][firstlevel];
+
        if (!t->image_override
-           && VALID_FORMAT(baseImage->TexFormat->MesaFormat)) {
-               if (baseImage->TexFormat->BaseFormat == GL_DEPTH_COMPONENT) {
-                       r300SetDepthTexMode(tObj);
+           && VALID_FORMAT(firstImage->TexFormat->MesaFormat)) {
+               if (firstImage->TexFormat->BaseFormat == GL_DEPTH_COMPONENT) {
+                       r300SetDepthTexMode(&t->base);
                } else {
-                       t->format = tx_table[baseImage->TexFormat->MesaFormat].format;
+                       t->pp_txformat = tx_table[firstImage->TexFormat->MesaFormat].format;
                }
 
-               t->filter |= tx_table[baseImage->TexFormat->MesaFormat].filter;
+               t->pp_txfilter |= tx_table[firstImage->TexFormat->MesaFormat].filter;
        } else if (!t->image_override) {
                _mesa_problem(NULL, "unexpected texture format in %s",
                              __FUNCTION__);
                return;
        }
 
-       texelBytes = baseImage->TexFormat->TexelBytes;
-
-       /* Compute which mipmap levels we really want to send to the hardware.
-        */
-       driCalculateTextureFirstLastLevel((driTextureObject *) t);
-       log2Width = tObj->Image[0][t->base.firstLevel]->WidthLog2;
-       log2Height = tObj->Image[0][t->base.firstLevel]->HeightLog2;
-       log2Depth = tObj->Image[0][t->base.firstLevel]->DepthLog2;
-
-       numLevels = t->base.lastLevel - t->base.firstLevel + 1;
+       if (t->image_override && t->bo)
+               return;
 
-       assert(numLevels <= R300_MAX_TEXTURE_LEVELS);
+       t->pp_txsize = (((firstImage->Width - 1) << R300_TX_WIDTHMASK_SHIFT)
+                       | ((firstImage->Height - 1) << R300_TX_HEIGHTMASK_SHIFT)
+                       | ((firstImage->DepthLog2) << R300_TX_DEPTHMASK_SHIFT)
+                       | ((t->mt->lastLevel - t->mt->firstLevel) << R300_TX_MAX_MIP_LEVEL_SHIFT));
 
-       /* Calculate mipmap offsets and dimensions for blitting (uploading)
-        * The idea is that we lay out the mipmap levels within a block of
-        * memory organized as a rectangle of width BLIT_WIDTH_BYTES.
-        */
        t->tile_bits = 0;
 
-       /* figure out if this texture is suitable for tiling. */
-#if 0                          /* Disabled for now */
-       if (texelBytes) {
-               if ((tObj->Target != GL_TEXTURE_RECTANGLE_NV) &&
-                   /* texrect might be able to use micro tiling too in theory? */
-                   (baseImage->Height > 1)) {
-
-                       /* allow 32 (bytes) x 1 mip (which will use two times the space
-                          the non-tiled version would use) max if base texture is large enough */
-                       if ((numLevels == 1) ||
-                           (((baseImage->Width * texelBytes /
-                              baseImage->Height) <= 32)
-                            && (baseImage->Width * texelBytes > 64))
-                           ||
-                           ((baseImage->Width * texelBytes /
-                             baseImage->Height) <= 16)) {
-                               t->tile_bits |= R300_TXO_MICRO_TILE;
-                       }
-               }
-
-               if (tObj->Target != GL_TEXTURE_RECTANGLE_NV) {
-                       /* we can set macro tiling even for small textures, they will be untiled anyway */
-                       t->tile_bits |= R300_TXO_MACRO_TILE;
-               }
-       }
-#endif
-
-       curOffset = 0;
+       if (t->base.Target == GL_TEXTURE_CUBE_MAP)
+               t->pp_txformat |= R300_TX_FORMAT_CUBIC_MAP;
+       if (t->base.Target == GL_TEXTURE_3D)
+               t->pp_txformat |= R300_TX_FORMAT_3D;
 
-       if (tObj->Target == GL_TEXTURE_CUBE_MAP) {
-               ASSERT(log2Width == log2Height);
-               t->format |= R300_TX_FORMAT_CUBIC_MAP;
 
-               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;
-
-               for (i = 0; i < numLevels; i++)
-                       compute_tex_image_offset(tObj, 0, i, &curOffset);
-       }
-
-       /* Align the total size of texture memory block.
-        */
-       t->base.totalSize =
-           (curOffset + RADEON_OFFSET_MASK) & ~RADEON_OFFSET_MASK;
-
-       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)
-            | ((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 |=
-                   (tObj->Image[0][t->base.firstLevel]->Width + 63) & ~(63);
-       } else if (tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
-               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->base.Target == GL_TEXTURE_RECTANGLE_NV) {
+               unsigned int align = (64 / t->mt->bpp) - 1;
+               t->pp_txsize |= R300_TX_SIZE_TXPITCH_EN;
                if (!t->image_override)
-                       t->pitch_reg =
-                           (((tObj->Image[0][t->base.firstLevel]->Width) +
-                             align) & ~align) - 1;
-       } else {
-               t->pitch |=
-                   ((tObj->Image[0][t->base.firstLevel]->Width *
-                     texelBytes) + 63) & ~(63);
+                       t->pp_txpitch = ((firstImage->Width + align) & ~align) - 1;
        }
 
        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;
+           if (firstImage->Width > 2048)
+               t->pp_txpitch |= R500_TXWIDTH_BIT11;
+           if (firstImage->Height > 2048)
+               t->pp_txpitch |= R500_TXHEIGHT_BIT11;
        }
 }
 
-/* ================================================================
- * Texture unit state management
+/**
+ * Ensure the given texture is ready for rendering.
+ *
+ * Mostly this means populating the texture object's mipmap tree.
  */
-
-static GLboolean r300EnableTexture2D(GLcontext * ctx, int unit)
-{
-       r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-       struct gl_texture_object *tObj = texUnit->_Current;
-       r300TexObjPtr t = (r300TexObjPtr) tObj->DriverData;
-
-       ASSERT(tObj->Target == GL_TEXTURE_2D || tObj->Target == GL_TEXTURE_1D);
-
-       if (t->base.dirty_images[0]) {
-               R300_FIREVERTICES(rmesa);
-
-               r300SetTexImages(rmesa, tObj);
-               r300UploadTexImages(rmesa, (r300TexObjPtr) tObj->DriverData, 0);
-               if (!t->base.memBlock && !t->image_override)
-                       return GL_FALSE;
-       }
-
-       return GL_TRUE;
-}
-
-static GLboolean r300EnableTexture3D(GLcontext * ctx, int unit)
+static GLboolean r300_validate_texture(GLcontext * ctx, struct gl_texture_object *texObj)
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-       struct gl_texture_object *tObj = texUnit->_Current;
-       r300TexObjPtr t = (r300TexObjPtr) tObj->DriverData;
+       radeonTexObj *t = radeon_tex_obj(texObj);
 
-       ASSERT(tObj->Target == GL_TEXTURE_3D);
-
-       /* r300 does not support mipmaps for 3D textures. */
-       if ((tObj->MinFilter != GL_NEAREST) && (tObj->MinFilter != GL_LINEAR)) {
+       if (!radeon_validate_texture_miptree(ctx, texObj))
                return GL_FALSE;
-       }
 
-       if (t->base.dirty_images[0]) {
-               R300_FIREVERTICES(rmesa);
-               r300SetTexImages(rmesa, tObj);
-               r300UploadTexImages(rmesa, (r300TexObjPtr) tObj->DriverData, 0);
-               if (!t->base.memBlock)
-                       return GL_FALSE;
-       }
+       /* Configure the hardware registers (more precisely, the cached version
+        * of the hardware registers). */
+       setup_hardware_state(rmesa, t);
 
+       t->validated = GL_TRUE;
        return GL_TRUE;
 }
 
-static GLboolean r300EnableTextureCube(GLcontext * ctx, int unit)
-{
-       r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-       struct gl_texture_object *tObj = texUnit->_Current;
-       r300TexObjPtr t = (r300TexObjPtr) tObj->DriverData;
-       GLuint face;
-
-       ASSERT(tObj->Target == GL_TEXTURE_CUBE_MAP);
-
-       if (t->base.dirty_images[0] || t->base.dirty_images[1] ||
-           t->base.dirty_images[2] || t->base.dirty_images[3] ||
-           t->base.dirty_images[4] || t->base.dirty_images[5]) {
-               /* flush */
-               R300_FIREVERTICES(rmesa);
-               /* layout memory space, once for all faces */
-               r300SetTexImages(rmesa, tObj);
-       }
-
-       /* upload (per face) */
-       for (face = 0; face < 6; face++) {
-               if (t->base.dirty_images[face]) {
-                       r300UploadTexImages(rmesa,
-                                           (r300TexObjPtr) tObj->DriverData,
-                                           face);
-               }
-       }
-
-       if (!t->base.memBlock) {
-               /* texmem alloc failed, use s/w fallback */
-               return GL_FALSE;
-       }
-
-       return GL_TRUE;
-}
-
-static GLboolean r300EnableTextureRect(GLcontext * ctx, int unit)
+/**
+ * Ensure all enabled and complete textures are uploaded along with any buffers being used.
+ */
+GLboolean r300ValidateBuffers(GLcontext * ctx)
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-       struct gl_texture_object *tObj = texUnit->_Current;
-       r300TexObjPtr t = (r300TexObjPtr) tObj->DriverData;
-
-       ASSERT(tObj->Target == GL_TEXTURE_RECTANGLE_NV);
+       struct radeon_renderbuffer *rrb;
+       int i;
 
-       if (t->base.dirty_images[0]) {
-               R300_FIREVERTICES(rmesa);
+       radeon_validate_reset_bos(&rmesa->radeon);
 
-               r300SetTexImages(rmesa, tObj);
-               r300UploadTexImages(rmesa, (r300TexObjPtr) tObj->DriverData, 0);
-               if (!t->base.memBlock && !t->image_override &&
-                   !rmesa->prefer_gart_client_texturing)
-                       return GL_FALSE;
+       rrb = radeon_get_colorbuffer(&rmesa->radeon);
+       /* color buffer */
+       if (rrb && rrb->bo) {
+               radeon_validate_bo(&rmesa->radeon, rrb->bo,
+                                  0, RADEON_GEM_DOMAIN_VRAM);
        }
 
-       return GL_TRUE;
-}
-
-static GLboolean r300UpdateTexture(GLcontext * ctx, int unit)
-{
-       r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-       struct gl_texture_object *tObj = texUnit->_ReallyEnabled ?
-               texUnit->_Current : NULL;
-       r300TexObjPtr t = tObj ? (r300TexObjPtr) tObj->DriverData : NULL;
-
-       /* Fallback if there's a texture border */
-       if (tObj && tObj->Image[0][tObj->BaseLevel]->Border > 0) {
-               tObj = NULL;
-               t = NULL;
+       /* depth buffer */
+       rrb = radeon_get_depthbuffer(&rmesa->radeon);
+       if (rrb && rrb->bo) {
+               radeon_validate_bo(&rmesa->radeon, rrb->bo,
+                                  0, RADEON_GEM_DOMAIN_VRAM);
        }
+       
+       for (i = 0; i < ctx->Const.MaxTextureImageUnits; ++i) {
+               radeonTexObj *t;
 
-       /* Update state if this is a different texture object to last
-        * time.
-        */
-       if (rmesa->state.texture.unit[unit].texobj != tObj) {
-               if (rmesa->state.texture.unit[unit].texobj != NULL) {
-                       r300TexObjPtr t_old = (r300TexObjPtr) rmesa->state.texture.unit[unit].texobj->DriverData;
-
-                       /* The old texture is no longer bound to this texture unit.
-                        * Mark it as such.
-                        */
-
-                       t_old->base.bound &= ~(1 << unit);
-               }
-
-               _mesa_reference_texobj(&rmesa->state.texture.unit[unit].texobj, tObj);
+               if (!ctx->Texture.Unit[i]._ReallyEnabled)
+                       continue;
 
-               if (t) {
-                       t->base.bound |= (1 << unit);
-                       driUpdateTextureLRU(&t->base);  /* XXX: should be locked! */
+               if (!r300_validate_texture(ctx, ctx->Texture.Unit[i]._Current)) {
+                       _mesa_warning(ctx,
+                                     "failed to validate texture for unit %d.\n",
+                                     i);
                }
+               t = radeon_tex_obj(ctx->Texture.Unit[i]._Current);
+               if (t->image_override && t->bo)
+                       radeon_validate_bo(&rmesa->radeon, t->bo,
+                                          RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
+
+               else if (t->mt->bo)
+                       radeon_validate_bo(&rmesa->radeon, t->mt->bo,
+                                          RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
        }
+       if (rmesa->radeon.dma.current)
+               radeon_validate_bo(&rmesa->radeon, rmesa->radeon.dma.current, RADEON_GEM_DOMAIN_GTT, 0);
 
-       return !t || !t->border_fallback;
+       return radeon_revalidate_bos(ctx);
 }
 
 void r300SetTexOffset(__DRIcontext * pDRICtx, GLint texname,
@@ -598,78 +330,166 @@ void r300SetTexOffset(__DRIcontext * pDRICtx, GLint texname,
        r300ContextPtr rmesa = pDRICtx->driverPrivate;
        struct gl_texture_object *tObj =
            _mesa_lookup_texture(rmesa->radeon.glCtx, texname);
-       r300TexObjPtr t;
+       radeonTexObjPtr t = radeon_tex_obj(tObj);
        uint32_t pitch_val;
 
        if (!tObj)
                return;
 
-       t = (r300TexObjPtr) tObj->DriverData;
-
        t->image_override = GL_TRUE;
 
        if (!offset)
                return;
 
-       t->offset = offset;
-       t->pitch_reg &= (1 << 13) -1;
+       t->bo = NULL;
+       t->override_offset = offset;
+       t->pp_txpitch &= (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->pp_txformat = R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8);
+               t->pp_txfilter |= tx_table[2].filter;
                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->pp_txformat = R300_EASY_TX_FORMAT(X, Y, Z, ONE, W8Z8Y8X8);
+               t->pp_txfilter |= tx_table[4].filter;
                pitch_val /= 4;
                break;
        case 16:
-               t->format = R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5);
-               t->filter |= tx_table[5].filter;
+               t->pp_txformat = R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5);
+               t->pp_txfilter |= tx_table[5].filter;
                pitch_val /= 2;
                break;
        }
        pitch_val--;
 
-       t->pitch_reg |= pitch_val;
+       t->pp_txpitch |= pitch_val;
 }
 
-static GLboolean r300UpdateTextureUnit(GLcontext * ctx, int unit)
+void r300SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_format, __DRIdrawable *dPriv)
 {
-       struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-
-       if (texUnit->_ReallyEnabled & (TEXTURE_RECT_BIT)) {
-               return (r300EnableTextureRect(ctx, unit) &&
-                       r300UpdateTexture(ctx, unit));
-       } else if (texUnit->_ReallyEnabled & (TEXTURE_1D_BIT | TEXTURE_2D_BIT)) {
-               return (r300EnableTexture2D(ctx, unit) &&
-                       r300UpdateTexture(ctx, unit));
-       } else if (texUnit->_ReallyEnabled & (TEXTURE_3D_BIT)) {
-               return (r300EnableTexture3D(ctx, unit) &&
-                       r300UpdateTexture(ctx, unit));
-       } else if (texUnit->_ReallyEnabled & (TEXTURE_CUBE_BIT)) {
-               return (r300EnableTextureCube(ctx, unit) &&
-                       r300UpdateTexture(ctx, unit));
-       } else if (texUnit->_ReallyEnabled) {
-               return GL_FALSE;
-       } else {
-               return r300UpdateTexture(ctx, unit);
+       struct gl_texture_unit *texUnit;
+       struct gl_texture_object *texObj;
+       struct gl_texture_image *texImage;
+       struct radeon_renderbuffer *rb;
+       radeon_texture_image *rImage;
+       radeonContextPtr radeon;
+       r300ContextPtr rmesa;
+       struct radeon_framebuffer *rfb;
+       radeonTexObjPtr t;
+       uint32_t pitch_val;
+       uint32_t internalFormat, type, format;
+
+       type = GL_BGRA;
+       format = GL_UNSIGNED_BYTE;
+       internalFormat = (glx_texture_format == GLX_TEXTURE_FORMAT_RGB_EXT ? 3 : 4);
+
+       radeon = pDRICtx->driverPrivate;
+       rmesa = pDRICtx->driverPrivate;
+
+       rfb = dPriv->driverPrivate;
+        texUnit = &radeon->glCtx->Texture.Unit[radeon->glCtx->Texture.CurrentUnit];
+       texObj = _mesa_select_tex_object(radeon->glCtx, texUnit, target);
+        texImage = _mesa_get_tex_image(radeon->glCtx, texObj, target, 0);
+
+       rImage = get_radeon_texture_image(texImage);
+       t = radeon_tex_obj(texObj);
+        if (t == NULL) {
+           return;
+       }
+
+       radeon_update_renderbuffers(pDRICtx, dPriv);
+       /* back & depth buffer are useless free them right away */
+       rb = (void*)rfb->base.Attachment[BUFFER_DEPTH].Renderbuffer;
+       if (rb && rb->bo) {
+               radeon_bo_unref(rb->bo);
+        rb->bo = NULL;
+       }
+       rb = (void*)rfb->base.Attachment[BUFFER_BACK_LEFT].Renderbuffer;
+       if (rb && rb->bo) {
+               radeon_bo_unref(rb->bo);
+               rb->bo = NULL;
        }
+       rb = rfb->color_rb[0];
+       if (rb->bo == NULL) {
+               /* Failed to BO for the buffer */
+               return;
+       }
+       
+       _mesa_lock_texture(radeon->glCtx, texObj);
+       if (t->bo) {
+               radeon_bo_unref(t->bo);
+               t->bo = NULL;
+       }
+       if (rImage->bo) {
+               radeon_bo_unref(rImage->bo);
+               rImage->bo = NULL;
+       }
+       if (t->mt) {
+               radeon_miptree_unreference(t->mt);
+               t->mt = NULL;
+       }
+       if (rImage->mt) {
+               radeon_miptree_unreference(rImage->mt);
+               rImage->mt = NULL;
+       }
+       _mesa_init_teximage_fields(radeon->glCtx, target, texImage,
+                                  rb->width, rb->height, 1, 0, rb->cpp);
+       texImage->RowStride = rb->pitch / rb->cpp;
+       texImage->TexFormat = radeonChooseTextureFormat(radeon->glCtx,
+                                                       internalFormat,
+                                                       type, format, 0);
+       rImage->bo = rb->bo;
+       radeon_bo_ref(rImage->bo);
+       t->bo = rb->bo;
+       radeon_bo_ref(t->bo);
+       t->tile_bits = 0;
+       t->image_override = GL_TRUE;
+       t->override_offset = 0;
+       t->pp_txpitch &= (1 << 13) -1;
+       pitch_val = rb->pitch;
+       switch (rb->cpp) {
+       case 4:
+               if (glx_texture_format == GLX_TEXTURE_FORMAT_RGB_EXT)
+                       t->pp_txformat = R300_EASY_TX_FORMAT(X, Y, Z, ONE, W8Z8Y8X8);
+               else
+                       t->pp_txformat = R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8);
+               t->pp_txfilter |= tx_table[2].filter;
+               pitch_val /= 4;
+               break;
+       case 3:
+       default:
+               t->pp_txformat = R300_EASY_TX_FORMAT(X, Y, Z, ONE, W8Z8Y8X8);
+               t->pp_txfilter |= tx_table[4].filter;
+               pitch_val /= 4;
+               break;
+       case 2:
+               t->pp_txformat = R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5);
+               t->pp_txfilter |= tx_table[5].filter;
+               pitch_val /= 2;
+               break;
+       }
+       pitch_val--;
+       t->pp_txsize = ((rb->width - 1) << R300_TX_WIDTHMASK_SHIFT) |
+              ((rb->height - 1) << R300_TX_HEIGHTMASK_SHIFT);
+       t->pp_txsize |= R300_TX_SIZE_TXPITCH_EN;
+       t->pp_txpitch |= pitch_val;
+
+       if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) {
+           if (rb->width > 2048)
+               t->pp_txpitch |= R500_TXWIDTH_BIT11;
+           if (rb->height > 2048)
+               t->pp_txpitch |= R500_TXHEIGHT_BIT11;
+       }
+       t->validated = GL_TRUE;
+       _mesa_unlock_texture(radeon->glCtx, texObj);
+       return;
 }
 
-void r300UpdateTextureState(GLcontext * ctx)
+void r300SetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
 {
-       int i;
-
-       for (i = 0; i < 8; i++) {
-               if (!r300UpdateTextureUnit(ctx, i)) {
-                       _mesa_warning(ctx,
-                                     "failed to update texture state for unit %d.\n",
-                                     i);
-               }
-       }
+        r300SetTexBuffer2(pDRICtx, target, GLX_TEXTURE_FORMAT_RGBA_EXT, dPriv);
 }
index 146daa367cd62b226c6663ad221048370870379e..c41a8fdd621a373f3288febfea349268982ad8de 100644 (file)
@@ -34,10 +34,12 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "shader/program.h"
 #include "shader/prog_instruction.h"
 #include "shader/prog_parameter.h"
+#include "shader/prog_print.h"
 #include "shader/prog_statevars.h"
 #include "tnl/tnl.h"
 
 #include "r300_context.h"
+#include "r300_state.h"
 
 /* TODO: Get rid of t_src_class call */
 #define CMP_SRCS(a, b) ((a.RelAddr != b.RelAddr) || (a.Index != b.Index && \
@@ -64,7 +66,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
                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; \
+                       vp->error = GL_TRUE; \
                } \
                u_temp_i=VSF_MAX_FRAGMENT_TEMPS-1; \
        } while (0)
@@ -214,21 +216,8 @@ static void vp_dump_inputs(struct r300_vertex_program *vp, char *caller)
 static unsigned long t_src_index(struct r300_vertex_program *vp,
                                 struct prog_src_register *src)
 {
-       int i;
-       int max_reg = -1;
-
        if (src->File == PROGRAM_INPUT) {
-               if (vp->inputs[src->Index] != -1)
-                       return vp->inputs[src->Index];
-
-               for (i = 0; i < VERT_ATTRIB_MAX; i++)
-                       if (vp->inputs[i] > max_reg)
-                               max_reg = vp->inputs[i];
-
-               vp->inputs[src->Index] = max_reg + 1;
-
-               //vp_dump_inputs(vp, __FUNCTION__);
-
+               assert(vp->inputs[src->Index] != -1);
                return vp->inputs[src->Index];
        } else {
                if (src->Index < 0) {
@@ -943,11 +932,17 @@ static GLuint *r300TranslateOpcodeXPD(struct r300_vertex_program *vp,
 static void t_inputs_outputs(struct r300_vertex_program *vp)
 {
        int i;
-       int cur_reg = 0;
+       int cur_reg;
 
-       for (i = 0; i < VERT_ATTRIB_MAX; i++)
-               vp->inputs[i] = -1;
+       cur_reg = -1;
+       for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+               if (vp->key.InputsRead & (1 << i))
+                       vp->inputs[i] = ++cur_reg;
+               else
+                       vp->inputs[i] = -1;
+       }
 
+       cur_reg = 0;
        for (i = 0; i < VERT_RESULT_MAX; i++)
                vp->outputs[i] = -1;
 
@@ -961,26 +956,36 @@ static void t_inputs_outputs(struct r300_vertex_program *vp)
                vp->outputs[VERT_RESULT_PSIZ] = cur_reg++;
        }
 
+       /* If we're writing back facing colors we need to send
+        * four colors to make front/back face colors selection work.
+        * If the vertex program doesn't write all 4 colors, lets
+        * pretend it does by skipping output index reg so the colors
+        * get written into appropriate output vectors.
+        */
        if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL0)) {
                vp->outputs[VERT_RESULT_COL0] = cur_reg++;
+       } else if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC0) ||
+               vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1)) {
+               cur_reg++;
        }
 
        if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL1)) {
-               vp->outputs[VERT_RESULT_COL1] =
-                   vp->outputs[VERT_RESULT_COL0] + 1;
-               cur_reg = vp->outputs[VERT_RESULT_COL1] + 1;
+               vp->outputs[VERT_RESULT_COL1] = cur_reg++;
+       } else if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC0) ||
+               vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1)) {
+               cur_reg++;
        }
 
        if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC0)) {
-               vp->outputs[VERT_RESULT_BFC0] =
-                   vp->outputs[VERT_RESULT_COL0] + 2;
-               cur_reg = vp->outputs[VERT_RESULT_BFC0] + 2;
+               vp->outputs[VERT_RESULT_BFC0] = cur_reg++;
+       } else if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1)) {
+               cur_reg++;
        }
 
        if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1)) {
-               vp->outputs[VERT_RESULT_BFC1] =
-                   vp->outputs[VERT_RESULT_COL0] + 3;
-               cur_reg = vp->outputs[VERT_RESULT_BFC1] + 1;
+               vp->outputs[VERT_RESULT_BFC1] = cur_reg++;
+       } else if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC0)) {
+               cur_reg++;
        }
 
        for (i = VERT_RESULT_TEX0; i <= VERT_RESULT_TEX7; i++) {
@@ -1007,14 +1012,13 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp,
        struct prog_src_register src[3];
 
        vp->pos_end = 0;        /* Not supported yet */
-       vp->program.length = 0;
-       /*vp->num_temporaries=mesa_vp->Base.NumTemporaries; */
+       vp->hw_code.length = 0;
        vp->translated = GL_TRUE;
-       vp->native = GL_TRUE;
+       vp->error = GL_FALSE;
 
        t_inputs_outputs(vp);
 
-       for (inst = vp->program.body.i; vpi->Opcode != OPCODE_END;
+       for (inst = vp->hw_code.body.d; vpi->Opcode != OPCODE_END;
             vpi++, inst += 4) {
 
                FREE_TEMPS();
@@ -1176,38 +1180,15 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp,
                                                      &u_temp_i);
                        break;
                default:
-                       assert(0);
+                       vp->error = GL_TRUE;
                        break;
                }
        }
 
-       /* 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->hw_code.length = (inst - vp->hw_code.body.d);
+       if (vp->hw_code.length >= VSF_MAX_FRAGMENT_LENGTH) {
+               vp->error = GL_TRUE;
        }
-
-       vp->program.length = (inst - vp->program.body.i);
-       if (vp->program.length >= VSF_MAX_FRAGMENT_LENGTH) {
-               vp->program.length = 0;
-               vp->native = GL_FALSE;
-       }
-#if 0
-       fprintf(stderr, "hw program:\n");
-       for (i = 0; i < vp->program.length; i++)
-               fprintf(stderr, "%08x\n", vp->program.body.d[i]);
-#endif
 }
 
 /* DP4 version seems to trigger some hw peculiarity */
@@ -1386,6 +1367,49 @@ static struct r300_vertex_program *build_program(struct r300_vertex_program_key
                pos_as_texcoord(vp, &mesa_vp->Base);
        }
 
+       if (RADEON_DEBUG & DEBUG_VERTS) {
+               fprintf(stderr, "Vertex program after native rewrite:\n");
+               _mesa_print_program(&mesa_vp->Base);
+               fflush(stdout);
+       }
+
+       /* Some outputs may be artificially added, to match the inputs of the fragment program.
+        * Issue 16 of vertex program spec says that all vertex attributes that are unwritten by
+        * vertex program are undefined, so just use MOV [vertex_result], CONST[0]
+        */
+       {
+               int i, count = 0;
+               for (i = 0; i < VERT_RESULT_MAX; ++i) {
+                       if (vp->key.OutputsAdded & (1 << i)) {
+                               ++count;
+                       }
+               }
+
+               if (count > 0) {
+                       struct prog_instruction *inst;
+
+                       _mesa_insert_instructions(&mesa_vp->Base, mesa_vp->Base.NumInstructions - 1, count);
+                       inst = &mesa_vp->Base.Instructions[mesa_vp->Base.NumInstructions - 1 - count];
+
+                       for (i = 0; i < VERT_RESULT_MAX; ++i) {
+                               if (vp->key.OutputsAdded & (1 << i)) {
+                                       inst->Opcode = OPCODE_MOV;
+
+                                       inst->DstReg.File = PROGRAM_OUTPUT;
+                                       inst->DstReg.Index = i;
+                                       inst->DstReg.WriteMask = WRITEMASK_XYZW;
+                                       inst->DstReg.CondMask = COND_TR;
+
+                                       inst->SrcReg[0].File = PROGRAM_CONSTANT;
+                                       inst->SrcReg[0].Index = 0;
+                                       inst->SrcReg[0].Swizzle = SWIZZLE_XYZW;
+
+                                       ++inst;
+                               }
+                       }
+               }
+       }
+
        assert(mesa_vp->Base.NumInstructions);
        vp->num_temporaries = mesa_vp->Base.NumTemporaries;
        r300TranslateVertexShader(vp, mesa_vp->Base.Instructions);
@@ -1432,7 +1456,12 @@ void r300SelectVertexShader(r300ContextPtr r300)
                wpos_idx = i;
        }
 
-       add_outputs(&wanted_key, VERT_RESULT_HPOS);
+       if (vpc->mesa_program.IsPositionInvariant) {
+               wanted_key.InputsRead |= (1 << VERT_ATTRIB_POS);
+               wanted_key.OutputsWritten |= (1 << VERT_RESULT_HPOS);
+       } else {
+               add_outputs(&wanted_key, VERT_RESULT_HPOS);
+       }
 
        if (InputsRead & FRAG_BIT_COL0) {
                add_outputs(&wanted_key, VERT_RESULT_COL0);
@@ -1442,27 +1471,103 @@ void r300SelectVertexShader(r300ContextPtr r300)
                add_outputs(&wanted_key, VERT_RESULT_COL1);
        }
 
+       if (InputsRead & FRAG_BIT_FOGC) {
+               add_outputs(&wanted_key, VERT_RESULT_FOGC);
+       }
+
        for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
                if (InputsRead & (FRAG_BIT_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);
-       }
-
        for (vp = vpc->progs; vp; vp = vp->next)
                if (_mesa_memcmp(&vp->key, &wanted_key, sizeof(wanted_key))
                    == 0) {
                        r300->selected_vp = vp;
                        return;
                }
-       //_mesa_print_program(&vpc->mesa_program.Base);
+
+       if (RADEON_DEBUG & DEBUG_VERTS) {
+               fprintf(stderr, "Initial vertex program:\n");
+               _mesa_print_program(&vpc->mesa_program.Base);
+               fflush(stdout);
+       }
 
        vp = build_program(&wanted_key, &vpc->mesa_program, wpos_idx);
        vp->next = vpc->progs;
        vpc->progs = vp;
        r300->selected_vp = vp;
 }
+
+#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; \
+               assert(_nc < 256); \
+               if(_nc>_p->vpu.count)_p->vpu.count=_nc; \
+       } while(0)
+
+static void r300EmitVertexProgram(r300ContextPtr r300, int dest, struct r300_vertex_shader_hw_code *code)
+{
+       int i;
+
+       assert((code->length > 0) && (code->length % 4 == 0));
+
+       switch ((dest >> 8) & 0xf) {
+               case 0:
+                       R300_STATECHANGE(r300, vpi);
+                       for (i = 0; i < code->length; i++)
+                               r300->hw.vpi.cmd[R300_VPI_INSTR_0 + i + 4 * (dest & 0xff)] = (code->body.d[i]);
+                       bump_vpu_count(r300->hw.vpi.cmd, code->length + 4 * (dest & 0xff));
+                       break;
+               case 2:
+                       R300_STATECHANGE(r300, vpp);
+                       for (i = 0; i < code->length; i++)
+                               r300->hw.vpp.cmd[R300_VPP_PARAM_0 + i + 4 * (dest & 0xff)] = (code->body.d[i]);
+                       bump_vpu_count(r300->hw.vpp.cmd, code->length + 4 * (dest & 0xff));
+                       break;
+               case 4:
+                       R300_STATECHANGE(r300, vps);
+                       for (i = 0; i < code->length; i++)
+                               r300->hw.vps.cmd[1 + i + 4 * (dest & 0xff)] = (code->body.d[i]);
+                       bump_vpu_count(r300->hw.vps.cmd, code->length + 4 * (dest & 0xff));
+                       break;
+               default:
+                       fprintf(stderr, "%s:%s don't know how to handle dest %04x\n", __FILE__, __FUNCTION__, dest);
+                       _mesa_exit(-1);
+       }
+}
+
+void r300SetupVertexProgram(r300ContextPtr rmesa)
+{
+       GLcontext *ctx = rmesa->radeon.glCtx;
+       struct r300_vertex_program *prog = rmesa->selected_vp;
+       int inst_count = 0;
+       int param_count = 0;
+       
+       /* Reset state, in case we don't use something */
+       ((drm_r300_cmd_header_t *) rmesa->hw.vpp.cmd)->vpu.count = 0;
+       ((drm_r300_cmd_header_t *) rmesa->hw.vpi.cmd)->vpu.count = 0;
+       ((drm_r300_cmd_header_t *) rmesa->hw.vps.cmd)->vpu.count = 0;
+       
+       R300_STATECHANGE(rmesa, vpp);
+       param_count = r300VertexProgUpdateParams(ctx,
+                                                               (struct r300_vertex_program_cont *)
+                                                               ctx->VertexProgram._Current,
+                                                               (float *)&rmesa->hw.vpp.cmd[R300_VPP_PARAM_0]);
+       bump_vpu_count(rmesa->hw.vpp.cmd, param_count);
+       param_count /= 4;
+
+       r300EmitVertexProgram(rmesa, R300_PVS_CODE_START, &(prog->hw_code));
+       inst_count = (prog->hw_code.length / 4) - 1;
+
+       r300VapCntl(rmesa, _mesa_bitcount(prog->key.InputsRead),
+                                _mesa_bitcount(prog->key.OutputsWritten), prog->num_temporaries);
+
+       R300_STATECHANGE(rmesa, pvs);
+       rmesa->hw.pvs.cmd[R300_PVS_CNTL_1] = (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_CONST_BASE_OFFSET_SHIFT) | (param_count << R300_PVS_MAX_CONST_ADDR_SHIFT);
+       rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] = (inst_count << R300_PVS_LAST_VTX_SRC_INST_SHIFT);
+}
index 2f35f02bc848fa42863363c824c2aa500ea9a9dc..b552e3fb1bda138e02e6f04f7eb874e55f1ae3b4 100644 (file)
@@ -32,4 +32,6 @@
 
 #endif
 
+void r300SetupVertexProgram(r300ContextPtr rmesa);
+
 #endif
index 292573de893e4282d12c702ca390c5b4598d797d..4d58cf216228e5d69e94c8a2e0d9b20b9e3f5af4 100644 (file)
 
 #include "r500_fragprog.h"
 
-#include "radeon_nqssadce.h"
-#include "radeon_program_alu.h"
-
-
 static void reset_srcreg(struct prog_src_register* reg)
 {
        _mesa_bzero(reg, sizeof(*reg));
@@ -58,12 +54,12 @@ static struct prog_src_register shadow_ambient(struct gl_program *program, int t
  *  - introduce a temporary register when write masks are needed
  *
  */
-static GLboolean transform_TEX(
+GLboolean r500_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 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;
@@ -188,121 +184,7 @@ static GLboolean transform_TEX(
        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_COLOR].Sourced = WRITEMASK_XYZW;
-       s->Outputs[FRAG_RESULT_DEPTH].Sourced = WRITEMASK_W;
-}
-
-static GLboolean is_native_swizzle(GLuint opcode, struct prog_src_register reg)
+GLboolean r500FPIsNativeSwizzle(GLuint opcode, struct prog_src_register reg)
 {
        GLuint relevant;
        int i;
@@ -314,22 +196,20 @@ static GLboolean is_native_swizzle(GLuint opcode, struct prog_src_register reg)
                if (reg.Abs)
                        return GL_FALSE;
 
+               if (opcode == OPCODE_KIL && (reg.Swizzle != SWIZZLE_NOOP || reg.Negate != NEGATE_NONE))
+                       return GL_FALSE;
+
                if (reg.Negate)
                        reg.Negate ^= NEGATE_XYZW;
 
-               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.Negate &= ~(1 << i);
-                                       continue;
-                               }
-                               if (swz >= 4)
-                                       return GL_FALSE;
+               for(i = 0; i < 4; ++i) {
+                       GLuint swz = GET_SWZ(reg.Swizzle, i);
+                       if (swz == SWIZZLE_NIL) {
+                               reg.Negate &= ~(1 << i);
+                               continue;
                        }
+                       if (swz >= 4)
+                               return GL_FALSE;
                }
 
                if (reg.Negate)
@@ -367,8 +247,7 @@ static GLboolean is_native_swizzle(GLuint opcode, struct prog_src_register reg)
  * 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)
+void r500FPBuildSwizzle(struct nqssadce_state *s, struct prog_dst_register dst, struct prog_src_register src)
 {
        struct prog_instruction *inst;
        GLuint negatebase[2] = { 0, 0 };
@@ -392,129 +271,12 @@ static void nqssadce_build_swizzle(struct nqssadce_state *s,
                inst->DstReg = dst;
                inst->DstReg.WriteMask = negatebase[i];
                inst->SrcReg[0] = src;
+               inst->SrcReg[0].Negate = (i == 0) ? NEGATE_NONE : NEGATE_XYZW;
                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) {
@@ -613,9 +375,9 @@ static char *to_texop(int val)
   return NULL;
 }
 
-static void dump_program(struct r500_fragment_program_code *code)
+void r500FragmentProgramDump(union rX00_fragment_program_code *c)
 {
-
+  struct r500_fragment_program_code *code = &c->r500;
   fprintf(stderr, "R500 Fragment Program:\n--------\n");
 
   int n;
index 1e45538f80792731766cdea50a6ee7988c798f31..1179bf660738443f2e8f076eda9cba6acc6009e2 100644 (file)
 #ifndef __R500_FRAGPROG_H_
 #define __R500_FRAGPROG_H_
 
-#include "main/glheader.h"
-#include "main/macros.h"
-#include "main/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"
+#include "radeon_nqssadce.h"
 
-struct r500_fragment_program;
+extern GLboolean r500BuildFragmentProgramHwCode(struct r300_fragment_program_compiler *compiler);
 
-extern void r500TranslateFragmentShader(r300ContextPtr r300,
-                                       struct r500_fragment_program *fp);
+extern void r500FragmentProgramDump(union rX00_fragment_program_code *c);
 
-struct r500_fragment_program_compiler {
-       r300ContextPtr r300;
-       struct r500_fragment_program *fp;
-       struct r500_fragment_program_code *code;
-       struct gl_program *program;
-};
+extern GLboolean r500FPIsNativeSwizzle(GLuint opcode, struct prog_src_register reg);
 
-extern GLboolean r500FragmentProgramEmit(struct r500_fragment_program_compiler *compiler);
+extern void r500FPBuildSwizzle(struct nqssadce_state *s, struct prog_dst_register dst, struct prog_src_register src);
+
+extern GLboolean r500_transform_TEX(struct radeon_transform_context *t, struct prog_instruction* orig_inst, void* data);
 
 #endif
index 4631235f0d3eae07d3ddecf79edfcbeb39c7a1f4..30f4514897eaece9df2a2bdb5080f1544d6135bd 100644 (file)
@@ -49,8 +49,8 @@
 
 
 #define PROG_CODE \
-       struct r500_fragment_program_compiler *c = (struct r500_fragment_program_compiler*)data; \
-       struct r500_fragment_program_code *code = c->code
+       struct r300_fragment_program_compiler *c = (struct r300_fragment_program_compiler*)data; \
+       struct r500_fragment_program_code *code = &c->code->r500
 
 #define error(fmt, args...) do {                       \
                fprintf(stderr, "%s::%s(): " fmt "\n",  \
@@ -72,7 +72,7 @@ static GLboolean emit_const(void *data, GLuint file, GLuint idx, GLuint *hwindex
        }
 
        if (*hwindex >= code->const_nr) {
-               if (*hwindex >= PFS_NUM_CONST_REGS) {
+               if (*hwindex >= R500_PFS_NUM_CONST_REGS) {
                        error("Out of hw constants!\n");
                        return GL_FALSE;
                }
@@ -299,9 +299,9 @@ static const struct radeon_pair_handler pair_handler = {
        .MaxHwTemps = 128
 };
 
-GLboolean r500FragmentProgramEmit(struct r500_fragment_program_compiler *compiler)
+GLboolean r500BuildFragmentProgramHwCode(struct r300_fragment_program_compiler *compiler)
 {
-       struct r500_fragment_program_code *code = compiler->code;
+       struct r500_fragment_program_code *code = &compiler->code->r500;
 
        _mesa_bzero(code, sizeof(*code));
        code->max_temp_idx = 1;
diff --git a/src/mesa/drivers/dri/r300/radeon_context.c b/src/mesa/drivers/dri/r300/radeon_context.c
deleted file mode 100644 (file)
index 5267fe9..0000000
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
-Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
-
-The Weather Channel (TM) funded Tungsten Graphics to develop the
-initial release of the Radeon 8500 driver under the XFree86 license.
-This notice must be preserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/**
- * \file radeon_context.c
- * Common context initialization.
- *
- * \author Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include <dlfcn.h>
-
-#include "main/glheader.h"
-#include "main/imports.h"
-#include "main/context.h"
-#include "main/state.h"
-#include "main/matrix.h"
-#include "main/framebuffer.h"
-
-#include "drivers/common/driverfuncs.h"
-#include "swrast/swrast.h"
-
-#include "radeon_screen.h"
-#include "radeon_ioctl.h"
-#include "radeon_macros.h"
-#include "radeon_reg.h"
-
-#include "radeon_state.h"
-#include "r300_state.h"
-
-#include "utils.h"
-#include "vblank.h"
-#include "xmlpool.h"           /* for symbolic values of enum-type options */
-
-#define DRIVER_DATE "20060815"
-
-
-/* Return various strings for glGetString().
- */
-static const GLubyte *radeonGetString(GLcontext * ctx, GLenum name)
-{
-       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
-       static char buffer[128];
-
-       switch (name) {
-       case GL_VENDOR:
-               if (IS_R300_CLASS(radeon->radeonScreen))
-                       return (GLubyte *) "DRI R300 Project";
-               else
-                       return (GLubyte *) "Tungsten Graphics, Inc.";
-
-       case GL_RENDERER:
-       {
-               unsigned offset;
-               GLuint agp_mode = (radeon->radeonScreen->card_type==RADEON_CARD_PCI) ? 0 :
-                       radeon->radeonScreen->AGPMode;
-               const char* chipname;
-
-               if (IS_R300_CLASS(radeon->radeonScreen))
-                       chipname = "R300";
-               else
-                       chipname = "R200";
-
-               offset = driGetRendererString(buffer, chipname, DRIVER_DATE,
-                                             agp_mode);
-
-               if (IS_R300_CLASS(radeon->radeonScreen)) {
-               sprintf(&buffer[offset], " %sTCL",
-                       (radeon->radeonScreen->chip_flags & RADEON_CHIPSET_TCL)
-                       ? "" : "NO-");
-               } else {
-                       sprintf(&buffer[offset], " %sTCL",
-                       !(radeon->TclFallback & RADEON_TCL_FALLBACK_TCL_DISABLE)
-                       ? "" : "NO-");
-               }
-
-               return (GLubyte *) buffer;
-       }
-
-       default:
-               return NULL;
-       }
-}
-
-/* Initialize the driver's misc functions.
- */
-static void radeonInitDriverFuncs(struct dd_function_table *functions)
-{
-       functions->GetString = radeonGetString;
-}
-
-
-/**
- * Create and initialize all common fields of the context,
- * including the Mesa context itself.
- */
-GLboolean radeonInitContext(radeonContextPtr radeon,
-                           struct dd_function_table* functions,
-                           const __GLcontextModes * glVisual,
-                           __DRIcontextPrivate * driContextPriv,
-                           void *sharedContextPrivate)
-{
-       __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
-       radeonScreenPtr screen = (radeonScreenPtr) (sPriv->private);
-       GLcontext* ctx;
-       GLcontext* shareCtx;
-       int fthrottle_mode;
-
-       /* Fill in additional standard functions. */
-       radeonInitDriverFuncs(functions);
-
-       radeon->radeonScreen = screen;
-       /* Allocate and initialize the Mesa context */
-       if (sharedContextPrivate)
-               shareCtx = ((radeonContextPtr)sharedContextPrivate)->glCtx;
-       else
-               shareCtx = NULL;
-       radeon->glCtx = _mesa_create_context(glVisual, shareCtx,
-                                           functions, (void *)radeon);
-       if (!radeon->glCtx)
-               return GL_FALSE;
-
-       ctx = radeon->glCtx;
-       driContextPriv->driverPrivate = radeon;
-
-       /* DRI fields */
-       radeon->dri.context = driContextPriv;
-       radeon->dri.screen = sPriv;
-       radeon->dri.drawable = NULL;
-       radeon->dri.readable = NULL;
-       radeon->dri.hwContext = driContextPriv->hHWContext;
-       radeon->dri.hwLock = &sPriv->pSAREA->lock;
-       radeon->dri.fd = sPriv->fd;
-       radeon->dri.drmMinor = sPriv->drm_version.minor;
-
-       radeon->sarea = (drm_radeon_sarea_t *) ((GLubyte *) sPriv->pSAREA +
-                                              screen->sarea_priv_offset);
-
-       /* Setup IRQs */
-       fthrottle_mode = driQueryOptioni(&radeon->optionCache, "fthrottle_mode");
-       radeon->iw.irq_seq = -1;
-       radeon->irqsEmitted = 0;
-       radeon->do_irqs = (fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS &&
-                         radeon->radeonScreen->irq);
-
-       radeon->do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS);
-
-       if (!radeon->do_irqs)
-               fprintf(stderr,
-                       "IRQ's not enabled, falling back to %s: %d %d\n",
-                       radeon->do_usleeps ? "usleeps" : "busy waits",
-                       fthrottle_mode, radeon->radeonScreen->irq);
-
-       (*sPriv->systemTime->getUST) (&radeon->swap_ust);
-
-       return GL_TRUE;
-}
-
-
-/**
- * Cleanup common context fields.
- * Called by r200DestroyContext/r300DestroyContext
- */
-void radeonCleanupContext(radeonContextPtr radeon)
-{
-       /* _mesa_destroy_context() might result in calls to functions that
-        * depend on the DriverCtx, so don't set it to NULL before.
-        *
-        * radeon->glCtx->DriverCtx = NULL;
-        */
-
-       /* free the Mesa context */
-       _mesa_destroy_context(radeon->glCtx);
-
-       if (radeon->state.scissor.pClipRects) {
-               FREE(radeon->state.scissor.pClipRects);
-               radeon->state.scissor.pClipRects = 0;
-       }
-}
-
-
-/**
- * Swap front and back buffer.
- */
-void radeonSwapBuffers(__DRIdrawablePrivate * dPriv)
-{
-       if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
-               radeonContextPtr radeon;
-               GLcontext *ctx;
-
-               radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
-               ctx = radeon->glCtx;
-
-               if (ctx->Visual.doubleBufferMode) {
-                       _mesa_notifySwapBuffers(ctx);   /* flush pending rendering comands */
-                       if (radeon->doPageFlip) {
-                               radeonPageFlip(dPriv);
-                       } else {
-                           radeonCopyBuffer(dPriv, NULL);
-                       }
-               }
-       } else {
-               /* XXX this shouldn't be an error but we can't handle it for now */
-               _mesa_problem(NULL, "%s: drawable has no context!",
-                             __FUNCTION__);
-       }
-}
-
-void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
-                        int x, int y, int w, int h )
-{
-    if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
-       radeonContextPtr radeon;
-       GLcontext *ctx;
-
-       radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
-       ctx = radeon->glCtx;
-
-       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 */
-           radeonCopyBuffer(dPriv, &rect);
-       }
-    } else {
-       /* XXX this shouldn't be an error but we can't handle it for now */
-       _mesa_problem(NULL, "%s: drawable has no context!",
-                     __FUNCTION__);
-    }
-}
-
-/* Force the context `c' to be the current context and associate with it
- * buffer `b'.
- */
-GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
-                           __DRIdrawablePrivate * driDrawPriv,
-                           __DRIdrawablePrivate * driReadPriv)
-{
-       if (driContextPriv) {
-               radeonContextPtr radeon =
-                       (radeonContextPtr) driContextPriv->driverPrivate;
-
-               if (RADEON_DEBUG & DEBUG_DRI)
-                       fprintf(stderr, "%s ctx %p\n", __FUNCTION__,
-                               radeon->glCtx);
-
-               if (radeon->dri.drawable != driDrawPriv) {
-                       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;
-
-               if (radeon->dri.drawable != driDrawPriv ||
-                   radeon->lastStamp != driDrawPriv->lastStamp) {
-                       radeon->dri.drawable = driDrawPriv;
-
-                       radeonSetCliprects(radeon);
-                       r300UpdateViewportOffset(radeon->glCtx);
-               }
-
-               _mesa_make_current(radeon->glCtx,
-                                   (GLframebuffer *) driDrawPriv->
-                                   driverPrivate,
-                                   (GLframebuffer *) driReadPriv->
-                                   driverPrivate);
-
-               _mesa_update_state(radeon->glCtx);              
-
-               radeonUpdatePageFlipping(radeon);
-       } else {
-               if (RADEON_DEBUG & DEBUG_DRI)
-                       fprintf(stderr, "%s ctx is null\n", __FUNCTION__);
-               _mesa_make_current(0, 0, 0);
-       }
-
-       if (RADEON_DEBUG & DEBUG_DRI)
-               fprintf(stderr, "End %s\n", __FUNCTION__);
-       return GL_TRUE;
-}
-
-/* Force the context `c' to be unbound from its buffer.
- */
-GLboolean radeonUnbindContext(__DRIcontextPrivate * driContextPriv)
-{
-       radeonContextPtr radeon = (radeonContextPtr) driContextPriv->driverPrivate;
-
-       if (RADEON_DEBUG & DEBUG_DRI)
-               fprintf(stderr, "%s ctx %p\n", __FUNCTION__,
-                       radeon->glCtx);
-
-       return GL_TRUE;
-}
-
index 47cbc22a72596ff64eca6e483ee6ff07591e6fd2..250570f6b89e8f1445b365b1dbdc842652a6695b 100644 (file)
@@ -49,20 +49,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "drm.h"
 #include "dri_util.h"
 
-struct radeon_context;
-typedef struct radeon_context radeonContextRec;
-typedef struct radeon_context *radeonContextPtr;
-
-/* Rasterizing fallbacks */
-/* See correponding strings in r200_swtcl.c */
-#define RADEON_FALLBACK_TEXTURE                0x0001
-#define RADEON_FALLBACK_DRAW_BUFFER    0x0002
-#define RADEON_FALLBACK_STENCIL                0x0004
-#define RADEON_FALLBACK_RENDER_MODE    0x0008
-#define RADEON_FALLBACK_BLEND_EQ       0x0010
-#define RADEON_FALLBACK_BLEND_FUNC     0x0020
-#define RADEON_FALLBACK_DISABLE                0x0040
-#define RADEON_FALLBACK_BORDER_MODE    0x0080
+#include "radeon_screen.h"
 
 #if R200_MERGED
 extern void radeonFallback(GLcontext * ctx, GLuint bit, GLboolean mode);
@@ -79,155 +66,11 @@ extern void radeonFallback(GLcontext * ctx, GLuint bit, GLboolean mode);
 /* TCL fallbacks */
 extern void radeonTclFallback(GLcontext * ctx, GLuint bit, GLboolean mode);
 
-#define RADEON_TCL_FALLBACK_RASTER             0x0001  /* rasterization */
-#define RADEON_TCL_FALLBACK_UNFILLED           0x0002  /* unfilled tris */
-#define RADEON_TCL_FALLBACK_LIGHT_TWOSIDE      0x0004  /* twoside tris */
-#define RADEON_TCL_FALLBACK_MATERIAL           0x0008  /* material in vb */
-#define RADEON_TCL_FALLBACK_TEXGEN_0           0x0010  /* texgen, unit 0 */
-#define RADEON_TCL_FALLBACK_TEXGEN_1           0x0020  /* texgen, unit 1 */
-#define RADEON_TCL_FALLBACK_TEXGEN_2           0x0040  /* texgen, unit 2 */
-#define RADEON_TCL_FALLBACK_TEXGEN_3           0x0080  /* texgen, unit 3 */
-#define RADEON_TCL_FALLBACK_TEXGEN_4           0x0100  /* texgen, unit 4 */
-#define RADEON_TCL_FALLBACK_TEXGEN_5           0x0200  /* texgen, unit 5 */
-#define RADEON_TCL_FALLBACK_TCL_DISABLE                0x0400  /* user disable */
-#define RADEON_TCL_FALLBACK_BITMAP             0x0800  /* draw bitmap with points */
-#define RADEON_TCL_FALLBACK_VERTEX_PROGRAM     0x1000  /* vertex program active */
-
 #if R200_MERGED
 #define TCL_FALLBACK( ctx, bit, mode ) radeonTclFallback( ctx, bit, mode )
 #else
 #define TCL_FALLBACK( ctx, bit, mode ) ;
 #endif
 
-struct radeon_dri_mirror {
-       __DRIcontextPrivate *context;   /* DRI context */
-       __DRIscreenPrivate *screen;     /* DRI screen */
-       /**
-        * DRI drawable bound to this context for drawing.
-        */
-       __DRIdrawablePrivate *drawable;
-
-       /**
-        * DRI drawable bound to this context for reading.
-        */
-       __DRIdrawablePrivate *readable;
-
-       drm_context_t hwContext;
-       drm_hw_lock_t *hwLock;
-       int fd;
-       int drmMinor;
-};
-
-/**
- * Derived state for internal purposes.
- */
-struct radeon_scissor_state {
-       drm_clip_rect_t rect;
-       GLboolean enabled;
-
-       GLuint numClipRects;    /* Cliprects active */
-       GLuint numAllocedClipRects;     /* Cliprects available */
-       drm_clip_rect_t *pClipRects;
-};
-
-struct radeon_colorbuffer_state {
-       GLuint clear;
-       GLint drawOffset, drawPitch;
-};
-
-struct radeon_state {
-       struct radeon_colorbuffer_state color;
-       struct radeon_scissor_state scissor;
-};
-
-/**
- * Common per-context variables shared by R200 and R300.
- * R200- and R300-specific code "derive" their own context from this
- * structure.
- */
-struct radeon_context {
-       GLcontext *glCtx;       /* Mesa context */
-       radeonScreenPtr radeonScreen;   /* Screen private DRI data */
-
-       /* Fallback state */
-       GLuint Fallback;
-       GLuint TclFallback;
-
-       /* Page flipping */
-       GLuint doPageFlip;
-
-       /* Drawable, cliprect and scissor information */
-       GLuint numClipRects;    /* Cliprects for the draw buffer */
-       drm_clip_rect_t *pClipRects;
-       unsigned int lastStamp;
-       GLboolean lost_context;
-       drm_radeon_sarea_t *sarea;      /* Private SAREA data */
-
-       /* Mirrors of some DRI state */
-       struct radeon_dri_mirror dri;
-
-       /* Busy waiting */
-       GLuint do_usleeps;
-       GLuint do_irqs;
-       GLuint irqsEmitted;
-       drm_radeon_irq_wait_t iw;
-
-       /* buffer swap */
-       int64_t swap_ust;
-       int64_t swap_missed_ust;
-
-       GLuint swap_count;
-       GLuint swap_missed_count;
-
-       /* Derived state */
-       struct radeon_state state;
-
-       /* Configuration cache
-        */
-       driOptionCache optionCache;
-};
-
-#define RADEON_CONTEXT(glctx) ((radeonContextPtr)(ctx->DriverCtx))
-
-extern void radeonSwapBuffers(__DRIdrawablePrivate * dPriv);
-extern void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
-                               int x, int y, int w, int h);
-extern GLboolean radeonInitContext(radeonContextPtr radeon,
-                                  struct dd_function_table *functions,
-                                  const __GLcontextModes * glVisual,
-                                  __DRIcontextPrivate * driContextPriv,
-                                  void *sharedContextPrivate);
-extern void radeonCleanupContext(radeonContextPtr radeon);
-extern GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
-                                  __DRIdrawablePrivate * driDrawPriv,
-                                  __DRIdrawablePrivate * driReadPriv);
-extern GLboolean radeonUnbindContext(__DRIcontextPrivate * driContextPriv);
-
-/* ================================================================
- * Debugging:
- */
-#define DO_DEBUG               1
-
-#if DO_DEBUG
-extern int RADEON_DEBUG;
-#else
-#define RADEON_DEBUG           0
-#endif
-
-#define DEBUG_TEXTURE  0x0001
-#define DEBUG_STATE    0x0002
-#define DEBUG_IOCTL    0x0004
-#define DEBUG_PRIMS    0x0008
-#define DEBUG_VERTS    0x0010
-#define DEBUG_FALLBACKS        0x0020
-#define DEBUG_VFMT     0x0040
-#define DEBUG_CODEGEN  0x0080
-#define DEBUG_VERBOSE  0x0100
-#define DEBUG_DRI       0x0200
-#define DEBUG_DMA       0x0400
-#define DEBUG_SANITY    0x0800
-#define DEBUG_SYNC      0x1000
-#define DEBUG_PIXEL     0x2000
-#define DEBUG_MEMORY    0x4000
 
 #endif                         /* __RADEON_CONTEXT_H__ */
diff --git a/src/mesa/drivers/dri/r300/radeon_ioctl.c b/src/mesa/drivers/dri/r300/radeon_ioctl.c
deleted file mode 100644 (file)
index f042a7b..0000000
+++ /dev/null
@@ -1,396 +0,0 @@
-/*
-Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
-
-The Weather Channel (TM) funded Tungsten Graphics to develop the
-initial release of the Radeon 8500 driver under the XFree86 license.
-This notice must be preserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include <sched.h>
-#include <errno.h>
-
-#include "main/glheader.h"
-#include "main/imports.h"
-#include "main/macros.h"
-#include "main/context.h"
-#include "swrast/swrast.h"
-#include "r300_context.h"
-#include "radeon_ioctl.h"
-#include "r300_ioctl.h"
-#include "r300_state.h"
-#include "radeon_reg.h"
-
-#include "drirenderbuffer.h"
-#include "vblank.h"
-
-static void radeonWaitForIdle(radeonContextPtr radeon);
-
-/* ================================================================
- * SwapBuffers with client-side throttling
- */
-
-static uint32_t radeonGetLastFrame(radeonContextPtr radeon)
-{
-       drm_radeon_getparam_t gp;
-       int ret;
-       uint32_t frame = 0;
-
-       gp.param = RADEON_PARAM_LAST_FRAME;
-       gp.value = (int *)&frame;
-       ret = drmCommandWriteRead(radeon->dri.fd, DRM_RADEON_GETPARAM,
-                                 &gp, sizeof(gp));
-       if (ret) {
-               fprintf(stderr, "%s: drmRadeonGetParam: %d\n", __FUNCTION__,
-                       ret);
-               exit(1);
-       }
-
-       return frame;
-}
-
-uint32_t radeonGetAge(radeonContextPtr radeon)
-{
-       drm_radeon_getparam_t gp;
-       int ret;
-       uint32_t age = 0;
-
-       gp.param = RADEON_PARAM_LAST_CLEAR;
-       gp.value = (int *)&age;
-       ret = drmCommandWriteRead(radeon->dri.fd, DRM_RADEON_GETPARAM,
-                                 &gp, sizeof(gp));
-       if (ret) {
-               fprintf(stderr, "%s: drmRadeonGetParam: %d\n", __FUNCTION__,
-                       ret);
-               exit(1);
-       }
-
-       return age;
-}
-
-static void radeonEmitIrqLocked(radeonContextPtr radeon)
-{
-       drm_radeon_irq_emit_t ie;
-       int ret;
-
-       ie.irq_seq = &radeon->iw.irq_seq;
-       ret = drmCommandWriteRead(radeon->dri.fd, DRM_RADEON_IRQ_EMIT,
-                                 &ie, sizeof(ie));
-       if (ret) {
-               fprintf(stderr, "%s: drmRadeonIrqEmit: %d\n", __FUNCTION__,
-                       ret);
-               exit(1);
-       }
-}
-
-static void radeonWaitIrq(radeonContextPtr radeon)
-{
-       int ret;
-
-       do {
-               ret = drmCommandWrite(radeon->dri.fd, DRM_RADEON_IRQ_WAIT,
-                                     &radeon->iw, sizeof(radeon->iw));
-       } while (ret && (errno == EINTR || errno == EBUSY));
-
-       if (ret) {
-               fprintf(stderr, "%s: drmRadeonIrqWait: %d\n", __FUNCTION__,
-                       ret);
-               exit(1);
-       }
-}
-
-static void radeonWaitForFrameCompletion(radeonContextPtr radeon)
-{
-       drm_radeon_sarea_t *sarea = radeon->sarea;
-
-       if (radeon->do_irqs) {
-               if (radeonGetLastFrame(radeon) < sarea->last_frame) {
-                       if (!radeon->irqsEmitted) {
-                               while (radeonGetLastFrame(radeon) <
-                                      sarea->last_frame) ;
-                       } else {
-                               UNLOCK_HARDWARE(radeon);
-                               radeonWaitIrq(radeon);
-                               LOCK_HARDWARE(radeon);
-                       }
-                       radeon->irqsEmitted = 10;
-               }
-
-               if (radeon->irqsEmitted) {
-                       radeonEmitIrqLocked(radeon);
-                       radeon->irqsEmitted--;
-               }
-       } else {
-               while (radeonGetLastFrame(radeon) < sarea->last_frame) {
-                       UNLOCK_HARDWARE(radeon);
-                       if (radeon->do_usleeps)
-                               DO_USLEEP(1);
-                       LOCK_HARDWARE(radeon);
-               }
-       }
-}
-
-/* Copy the back color buffer to the front color buffer.
- */
-void radeonCopyBuffer(__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);
-       assert(dPriv->driContextPriv->driverPrivate);
-
-       radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
-
-       if (RADEON_DEBUG & DEBUG_IOCTL) {
-               fprintf(stderr, "\n%s( %p )\n\n", __FUNCTION__,
-                       (void *)radeon->glCtx);
-       }
-
-       r300Flush(radeon->glCtx);
-
-       LOCK_HARDWARE(radeon);
-
-       /* Throttle the frame rate -- only allow one pending swap buffers
-        * request at a time.
-        */
-       radeonWaitForFrameCompletion(radeon);
-       if (!rect)
-       {
-           UNLOCK_HARDWARE(radeon);
-           driWaitForVBlank(dPriv, &missed_target);
-           LOCK_HARDWARE(radeon);
-       }
-
-       nbox = dPriv->numClipRects;     /* must be in locked region */
-
-       for (i = 0; i < nbox;) {
-               GLint nr = MIN2(i + RADEON_NR_SAREA_CLIPRECTS, nbox);
-               drm_clip_rect_t *box = dPriv->pClipRects;
-               drm_clip_rect_t *b = radeon->sarea->boxes;
-               GLint n = 0;
-
-               for ( ; i < nr ; i++ ) {
-
-                   *b = box[i];
-
-                   if (rect)
-                   {
-                       if (rect->x1 > b->x1)
-                           b->x1 = rect->x1;
-                       if (rect->y1 > b->y1)
-                           b->y1 = rect->y1;
-                       if (rect->x2 < b->x2)
-                           b->x2 = rect->x2;
-                       if (rect->y2 < b->y2)
-                           b->y2 = rect->y2;
-
-                       if (b->x1 >= b->x2 || b->y1 >= b->y2)
-                           continue;
-                   }
-
-                   b++;
-                   n++;
-               }
-               radeon->sarea->nbox = n;
-
-               if (!n)
-                  continue;
-
-               ret = drmCommandNone(radeon->dri.fd, DRM_RADEON_SWAP);
-
-               if (ret) {
-                       fprintf(stderr, "DRM_RADEON_SWAP: return = %d\n",
-                               ret);
-                       UNLOCK_HARDWARE(radeon);
-                       exit(1);
-               }
-       }
-
-       UNLOCK_HARDWARE(radeon);
-       if (!rect)
-       {
-           ((r300ContextPtr)radeon)->hw.all_dirty = GL_TRUE;
-
-           radeon->swap_count++;
-           (*psp->systemTime->getUST) (&ust);
-           if (missed_target) {
-               radeon->swap_missed_count++;
-               radeon->swap_missed_ust = ust - radeon->swap_ust;
-           }
-
-           radeon->swap_ust = ust;
-
-           sched_yield();
-       }
-}
-
-void radeonPageFlip(__DRIdrawablePrivate * dPriv)
-{
-       radeonContextPtr radeon;
-       GLint ret;
-       GLboolean missed_target;
-       __DRIscreenPrivate *psp = dPriv->driScreenPriv;
-
-       assert(dPriv);
-       assert(dPriv->driContextPriv);
-       assert(dPriv->driContextPriv->driverPrivate);
-
-       radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
-
-       if (RADEON_DEBUG & DEBUG_IOCTL) {
-               fprintf(stderr, "%s: pfCurrentPage: %d\n", __FUNCTION__,
-                       radeon->sarea->pfCurrentPage);
-       }
-
-       r300Flush(radeon->glCtx);
-       LOCK_HARDWARE(radeon);
-
-       if (!dPriv->numClipRects) {
-               UNLOCK_HARDWARE(radeon);
-               usleep(10000);  /* throttle invisible client 10ms */
-               return;
-       }
-
-       /* Need to do this for the perf box placement:
-        */
-       {
-               drm_clip_rect_t *box = dPriv->pClipRects;
-               drm_clip_rect_t *b = radeon->sarea->boxes;
-               b[0] = box[0];
-               radeon->sarea->nbox = 1;
-       }
-
-       /* Throttle the frame rate -- only allow a few pending swap buffers
-        * request at a time.
-        */
-       radeonWaitForFrameCompletion(radeon);
-       UNLOCK_HARDWARE(radeon);
-       driWaitForVBlank(dPriv, &missed_target);
-       if (missed_target) {
-               radeon->swap_missed_count++;
-               (void)(*psp->systemTime->getUST) (&radeon->swap_missed_ust);
-       }
-       LOCK_HARDWARE(radeon);
-
-       ret = drmCommandNone(radeon->dri.fd, DRM_RADEON_FLIP);
-
-       UNLOCK_HARDWARE(radeon);
-
-       if (ret) {
-               fprintf(stderr, "DRM_RADEON_FLIP: return = %d\n", ret);
-               exit(1);
-       }
-
-       radeon->swap_count++;
-       (void)(*psp->systemTime->getUST) (&radeon->swap_ust);
-
-        driFlipRenderbuffers(radeon->glCtx->WinSysDrawBuffer, 
-                             radeon->sarea->pfCurrentPage);
-
-       if (radeon->sarea->pfCurrentPage == 1) {
-               radeon->state.color.drawOffset = radeon->radeonScreen->frontOffset;
-               radeon->state.color.drawPitch = radeon->radeonScreen->frontPitch;
-       } else {
-               radeon->state.color.drawOffset = radeon->radeonScreen->backOffset;
-               radeon->state.color.drawPitch = radeon->radeonScreen->backPitch;
-       }
-
-       if (IS_R300_CLASS(radeon->radeonScreen)) {
-               r300ContextPtr r300 = (r300ContextPtr)radeon;
-               R300_STATECHANGE(r300, cb);
-               r300->hw.cb.cmd[R300_CB_OFFSET] = r300->radeon.state.color.drawOffset + 
-                                               r300->radeon.radeonScreen->fbLocation;
-               r300->hw.cb.cmd[R300_CB_PITCH] = r300->radeon.state.color.drawPitch;
-               
-               if (r300->radeon.radeonScreen->cpp == 4)
-                       r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_FORMAT_ARGB8888;
-               else
-                       r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_FORMAT_RGB565;
-       
-               if (r300->radeon.sarea->tiling_enabled)
-                       r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_TILE_ENABLE;
-       }
-}
-
-void radeonWaitForIdleLocked(radeonContextPtr radeon)
-{
-       int ret;
-       int i = 0;
-
-       do {
-               ret = drmCommandNone(radeon->dri.fd, DRM_RADEON_CP_IDLE);
-               if (ret)
-                       DO_USLEEP(1);
-       } while (ret && ++i < 100);
-
-       if (ret < 0) {
-               UNLOCK_HARDWARE(radeon);
-               fprintf(stderr, "Error: R300 timed out... exiting\n");
-               exit(-1);
-       }
-}
-
-static void radeonWaitForIdle(radeonContextPtr radeon)
-{
-       LOCK_HARDWARE(radeon);
-       radeonWaitForIdleLocked(radeon);
-       UNLOCK_HARDWARE(radeon);
-}
-
-void radeonFlush(GLcontext * ctx)
-{
-       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
-
-       if (IS_R300_CLASS(radeon->radeonScreen))
-               r300Flush(ctx);
-}
-
-
-/* Make sure all commands have been sent to the hardware and have
- * completed processing.
- */
-void radeonFinish(GLcontext * ctx)
-{
-       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
-
-       radeonFlush(ctx);
-
-       if (radeon->do_irqs) {
-               LOCK_HARDWARE(radeon);
-               radeonEmitIrqLocked(radeon);
-               UNLOCK_HARDWARE(radeon);
-               radeonWaitIrq(radeon);
-       } else
-               radeonWaitForIdle(radeon);
-}
diff --git a/src/mesa/drivers/dri/r300/radeon_ioctl.h b/src/mesa/drivers/dri/r300/radeon_ioctl.h
deleted file mode 100644 (file)
index 3add775..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
-
-The Weather Channel (TM) funded Tungsten Graphics to develop the
-initial release of the Radeon 8500 driver under the XFree86 license.
-This notice must be preserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#ifndef __RADEON_IOCTL_H__
-#define __RADEON_IOCTL_H__
-
-#include "main/simple_list.h"
-#include "radeon_dri.h"
-#include "radeon_lock.h"
-
-#include "xf86drm.h"
-#include "drm.h"
-#if 0
-#include "r200context.h"
-#endif
-#include "radeon_drm.h"
-
-extern void radeonCopyBuffer(__DRIdrawablePrivate * drawable,
-                            const drm_clip_rect_t      * rect);
-extern void radeonPageFlip(__DRIdrawablePrivate * drawable);
-extern void radeonFlush(GLcontext * ctx);
-extern void radeonFinish(GLcontext * ctx);
-extern void radeonWaitForIdleLocked(radeonContextPtr radeon);
-extern uint32_t radeonGetAge(radeonContextPtr radeon);
-
-#endif                         /* __RADEON_IOCTL_H__ */
diff --git a/src/mesa/drivers/dri/r300/radeon_lock.c b/src/mesa/drivers/dri/r300/radeon_lock.c
deleted file mode 100644 (file)
index 4f47afd..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/**************************************************************************
-
-Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
-                     VA Linux Systems Inc., Fremont, California.
-Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
-
-The Weather Channel (TM) funded Tungsten Graphics to develop the
-initial release of the Radeon 8500 driver under the XFree86 license.
-This notice must be preserved.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Gareth Hughes <gareth@valinux.com>
- *   Keith Whitwell <keith@tungstengraphics.com>
- *   Kevin E. Martin <martin@valinux.com>
- */
-
-#include "radeon_lock.h"
-#include "radeon_ioctl.h"
-#include "radeon_state.h"
-#include "r300_context.h"
-#include "r300_state.h"
-
-#include "main/framebuffer.h"
-
-#include "drirenderbuffer.h"
-
-#if DEBUG_LOCKING
-char *prevLockFile = NULL;
-int prevLockLine = 0;
-#endif
-
-/* Turn on/off page flipping according to the flags in the sarea:
- */
-void radeonUpdatePageFlipping(radeonContextPtr rmesa)
-{
-       int use_back;
-
-       rmesa->doPageFlip = rmesa->sarea->pfState;
-       if (rmesa->glCtx->WinSysDrawBuffer) {
-               driFlipRenderbuffers(rmesa->glCtx->WinSysDrawBuffer,
-                                    rmesa->sarea->pfCurrentPage);
-               r300UpdateDrawBuffer(rmesa->glCtx);
-       }
-
-       use_back = rmesa->glCtx->DrawBuffer ?
-           (rmesa->glCtx->DrawBuffer->_ColorDrawBufferIndexes[0] ==
-            BUFFER_BACK_LEFT) : 1;
-       use_back ^= (rmesa->sarea->pfCurrentPage == 1);
-
-       if (use_back) {
-               rmesa->state.color.drawOffset =
-                   rmesa->radeonScreen->backOffset;
-               rmesa->state.color.drawPitch = rmesa->radeonScreen->backPitch;
-       } else {
-               rmesa->state.color.drawOffset =
-                   rmesa->radeonScreen->frontOffset;
-               rmesa->state.color.drawPitch =
-                   rmesa->radeonScreen->frontPitch;
-       }
-}
-
-/* Update the hardware state.  This is called if another context has
- * grabbed the hardware lock, which includes the X server.  This
- * function also updates the driver's window state after the X server
- * moves, resizes or restacks a window -- the change will be reflected
- * in the drawable position and clip rects.  Since the X server grabs
- * the hardware lock when it changes the window state, this routine will
- * automatically be called after such a change.
- */
-void radeonGetLock(radeonContextPtr rmesa, GLuint flags)
-{
-       __DRIdrawablePrivate *const drawable = rmesa->dri.drawable;
-       __DRIdrawablePrivate *const readable = rmesa->dri.readable;
-       __DRIscreenPrivate *sPriv = rmesa->dri.screen;
-       drm_radeon_sarea_t *sarea = rmesa->sarea;
-       r300ContextPtr r300 = (r300ContextPtr) rmesa;
-
-       assert(drawable != NULL);
-
-       drmGetLock(rmesa->dri.fd, rmesa->dri.hwContext, flags);
-
-       /* The window might have moved, so we might need to get new clip
-        * rects.
-        *
-        * NOTE: This releases and regrabs the hw lock to allow the X server
-        * to respond to the DRI protocol request for new drawable info.
-        * Since the hardware state depends on having the latest drawable
-        * clip rects, all state checking must be done _after_ this call.
-        */
-       DRI_VALIDATE_DRAWABLE_INFO(sPriv, drawable);
-       if (drawable != readable) {
-               DRI_VALIDATE_DRAWABLE_INFO(sPriv, readable);
-       }
-
-       if (rmesa->lastStamp != drawable->lastStamp) {
-               radeonUpdatePageFlipping(rmesa);
-               radeonSetCliprects(rmesa);
-               r300UpdateViewportOffset(rmesa->glCtx);
-               driUpdateFramebufferSize(rmesa->glCtx, drawable);
-       }
-
-       if (sarea->ctx_owner != rmesa->dri.hwContext) {
-               int i;
-
-               sarea->ctx_owner = rmesa->dri.hwContext;
-               for (i = 0; i < r300->nr_heaps; i++) {
-                       DRI_AGE_TEXTURES(r300->texture_heaps[i]);
-               }
-       }
-
-       rmesa->lost_context = GL_TRUE;
-}
diff --git a/src/mesa/drivers/dri/r300/radeon_lock.h b/src/mesa/drivers/dri/r300/radeon_lock.h
deleted file mode 100644 (file)
index a344837..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/**************************************************************************
-
-Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
-                     VA Linux Systems Inc., Fremont, California.
-Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
-
-The Weather Channel (TM) funded Tungsten Graphics to develop the
-initial release of the Radeon 8500 driver under the XFree86 license.
-This notice must be preserved.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Gareth Hughes <gareth@valinux.com>
- *   Keith Whitwell <keith@tungstengraphics.com>
- *   Kevin E. Martin <martin@valinux.com>
- */
-
-#ifndef __RADEON_LOCK_H__
-#define __RADEON_LOCK_H__
-
-#include "radeon_context.h"
-
-extern void radeonGetLock(radeonContextPtr rmesa, GLuint flags);
-extern void radeonUpdatePageFlipping(radeonContextPtr rmesa);
-
-/* Turn DEBUG_LOCKING on to find locking conflicts.
- */
-#define DEBUG_LOCKING  0
-
-#if DEBUG_LOCKING
-extern char *prevLockFile;
-extern int prevLockLine;
-
-#define DEBUG_LOCK()                                                   \
-   do {                                                                        \
-      prevLockFile = (__FILE__);                                       \
-      prevLockLine = (__LINE__);                                       \
-   } while (0)
-
-#define DEBUG_RESET()                                                  \
-   do {                                                                        \
-      prevLockFile = 0;                                                        \
-      prevLockLine = 0;                                                        \
-   } while (0)
-
-#define DEBUG_CHECK_LOCK()                                             \
-   do {                                                                        \
-      if (prevLockFile) {                                              \
-        fprintf(stderr,                                                \
-                 "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n",    \
-                 prevLockFile, prevLockLine, __FILE__, __LINE__);      \
-        exit(1);                                                       \
-      }                                                                        \
-   } while (0)
-
-#else
-
-#define DEBUG_LOCK()
-#define DEBUG_RESET()
-#define DEBUG_CHECK_LOCK()
-
-#endif
-
-/*
- * !!! We may want to separate locks from locks with validation.  This
- * could be used to improve performance for those things commands that
- * do not do any drawing !!!
- */
-
-/* Lock the hardware and validate our state.
- */
-#define LOCK_HARDWARE( rmesa )                                         \
-       do {                                                            \
-               char __ret = 0;                                         \
-               DEBUG_CHECK_LOCK();                                     \
-               DRM_CAS((rmesa)->dri.hwLock, (rmesa)->dri.hwContext,    \
-                       (DRM_LOCK_HELD | (rmesa)->dri.hwContext), __ret); \
-               if (__ret)                                              \
-                       radeonGetLock((rmesa), 0);                      \
-               DEBUG_LOCK();                                           \
-       } while (0)
-
-#define UNLOCK_HARDWARE( rmesa )                                       \
-       do {                                                            \
-               DRM_UNLOCK((rmesa)->dri.fd,                             \
-                       (rmesa)->dri.hwLock,                            \
-                       (rmesa)->dri.hwContext);                        \
-               DEBUG_RESET();                                          \
-       } while (0)
-
-#endif                         /* __RADEON_LOCK_H__ */
index 2e21f7bf666e64a0d0d4ce1282898988f601e5be..906d36e522614deb35718420f32b0fad7dcb0010 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "radeon_program_pair.h"
 
-#include "radeon_context.h"
+#include "radeon_common.h"
 
 #include "shader/prog_print.h"
 
@@ -47,7 +47,6 @@
 
 struct pair_state_instruction {
        GLuint IsTex:1; /**< Is a texture instruction */
-       GLuint IsOutput:1; /**< Is output instruction */
        GLuint NeedRGB:1; /**< Needs the RGB ALU */
        GLuint NeedAlpha:1; /**< Needs the Alpha ALU */
        GLuint IsTranscendent:1; /**< Is a special transcendent instruction */
@@ -124,7 +123,6 @@ struct pair_state {
        GLboolean Debug;
        GLboolean Verbose;
        void *UserData;
-       GLubyte NumKillInsts;
 
        /**
         * Translate Mesa registers to hardware registers
@@ -150,11 +148,6 @@ struct pair_state {
        struct pair_state_instruction *ReadyAlpha;
        struct pair_state_instruction *ReadyTEX;
 
-       /**
-        * Linked list of deferred instructions
-        */
-       struct pair_state_instruction *DeferredInsts;
-
        /**
         * Pool of @ref reg_value structures for fast allocation.
         */
@@ -238,9 +231,7 @@ static void instruction_ready(struct pair_state *s, int ip)
        if (s->Verbose)
                _mesa_printf("instruction_ready(%i)\n", ip);
 
-       if (s->NumKillInsts > 0 && pairinst->IsOutput)
-               add_pairinst_to_list(&s->DeferredInsts, pairinst);
-       else if (pairinst->IsTex)
+       if (pairinst->IsTex)
                add_pairinst_to_list(&s->ReadyTEX, pairinst);
        else if (!pairinst->NeedAlpha)
                add_pairinst_to_list(&s->ReadyRGB, pairinst);
@@ -348,8 +339,6 @@ static void classify_instruction(struct pair_state *s,
                error("Unknown opcode %d\n", inst->Opcode);
                break;
        }
-
-       pairinst->IsOutput = (inst->DstReg.File == PROGRAM_OUTPUT);
 }
 
 
@@ -613,16 +602,14 @@ static void emit_all_tex(struct pair_state *s)
                struct prog_instruction *inst = s->Program->Instructions + ip;
                commit_instruction(s, ip);
 
-               if (inst->Opcode == OPCODE_KIL)
-                       --s->NumKillInsts;
-               else
+               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);
+                       fflush(stdout);
                }
                s->Error = s->Error || !s->Handler->EmitTex(s->UserData, inst);
        }
@@ -875,17 +862,6 @@ static void emit_alu(struct pair_state *s)
        s->Error = s->Error || !s->Handler->EmitPaired(s->UserData, &pair);
 }
 
-static GLubyte countKillInsts(struct gl_program *prog)
-{
-       GLubyte i, count = 0;
-
-       for (i = 0; i < prog->NumInstructions; ++i) {
-               if (prog->Instructions[i].Opcode == OPCODE_KIL)
-                       ++count;
-       }
-
-       return count;
-}
 
 GLboolean radeonPairProgram(GLcontext *ctx, struct gl_program *program,
        const struct radeon_pair_handler* handler, void *userdata)
@@ -899,7 +875,6 @@ GLboolean radeonPairProgram(GLcontext *ctx, struct gl_program *program,
        s.UserData = userdata;
        s.Debug = (RADEON_DEBUG & DEBUG_PIXEL) ? GL_TRUE : GL_FALSE;
        s.Verbose = GL_FALSE && s.Debug;
-       s.NumKillInsts = countKillInsts(program);
 
        s.Instructions = (struct pair_state_instruction*)_mesa_calloc(
                sizeof(struct pair_state_instruction)*s.Program->NumInstructions);
@@ -918,21 +893,6 @@ GLboolean radeonPairProgram(GLcontext *ctx, struct gl_program *program,
                if (s.ReadyTEX)
                        emit_all_tex(&s);
 
-               if (!s.NumKillInsts) {
-                       struct pair_state_instruction *pairinst = s.DeferredInsts;
-                       while (pairinst) {
-                               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);
-
-                               pairinst = pairinst->NextReady;
-                       }
-                       s.DeferredInsts = NULL;
-               }
-
                while(s.ReadyFullALU || s.ReadyRGB || s.ReadyAlpha)
                        emit_alu(&s);
        }
diff --git a/src/mesa/drivers/dri/r300/radeon_span.c b/src/mesa/drivers/dri/r300/radeon_span.c
deleted file mode 100644 (file)
index 16f9fb9..0000000
+++ /dev/null
@@ -1,349 +0,0 @@
-/**************************************************************************
-
-Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
-Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
-                     VA Linux Systems Inc., Fremont, California.
-
-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.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <martin@valinux.com>
- *   Gareth Hughes <gareth@valinux.com>
- *   Keith Whitwell <keith@tungstengraphics.com>
- *
- */
-
-#include "main/glheader.h"
-#include "swrast/swrast.h"
-
-#include "r300_state.h"
-#include "radeon_ioctl.h"
-#include "r300_ioctl.h"
-#include "radeon_span.h"
-
-#include "drirenderbuffer.h"
-
-#define DBG 0
-
-/*
- * Note that all information needed to access pixels in a renderbuffer
- * should be obtained through the gl_renderbuffer parameter, not per-context
- * information.
- */
-#define LOCAL_VARS                                             \
-   driRenderbuffer *drb = (driRenderbuffer *) rb;              \
-   const __DRIdrawablePrivate *dPriv = drb->dPriv;             \
-   const GLuint bottom = dPriv->h - 1;                         \
-   GLubyte *buf = (GLubyte *) drb->flippedData                 \
-      + (dPriv->y * drb->flippedPitch + dPriv->x) * drb->cpp;  \
-   GLuint p;                                                   \
-   (void) p;
-
-#define LOCAL_DEPTH_VARS                               \
-   driRenderbuffer *drb = (driRenderbuffer *) rb;      \
-   const __DRIdrawablePrivate *dPriv = drb->dPriv;     \
-   const GLuint bottom = dPriv->h - 1;                 \
-   GLuint xo = dPriv->x;                               \
-   GLuint yo = dPriv->y;                               \
-   GLubyte *buf = (GLubyte *) drb->Base.Data;
-
-#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
-
-#define Y_FLIP(Y) (bottom - (Y))
-
-#define HW_LOCK()
-
-#define HW_UNLOCK()
-
-/* ================================================================
- * Color buffer
- */
-
-/* 16 bit, RGB565 color spanline and pixel functions
- */
-#define SPANTMP_PIXEL_FMT GL_RGB
-#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
-
-#define TAG(x)    radeon##x##_RGB565
-#define TAG2(x,y) radeon##x##_RGB565##y
-#define GET_PTR(X,Y) (buf + ((Y) * drb->flippedPitch + (X)) * 2)
-#include "spantmp2.h"
-
-/* 32 bit, ARGB8888 color spanline and pixel functions
- */
-#define SPANTMP_PIXEL_FMT GL_BGRA
-#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
-
-#define TAG(x)    radeon##x##_ARGB8888
-#define TAG2(x,y) radeon##x##_ARGB8888##y
-#define GET_PTR(X,Y) (buf + ((Y) * drb->flippedPitch + (X)) * 4)
-#include "spantmp2.h"
-
-/* ================================================================
- * Depth buffer
- */
-
-/* The Radeon family has depth tiling on all the time, so we have to convert
- * the x,y coordinates into the memory bus address (mba) in the same
- * manner as the engine.  In each case, the linear block address (ba)
- * is calculated, and then wired with x and y to produce the final
- * memory address.
- * The chip will do address translation on its own if the surface registers
- * are set up correctly. It is not quite enough to get it working with hyperz
- * too...
- */
-
-static GLuint radeon_mba_z32(const driRenderbuffer * drb, GLint x, GLint y)
-{
-       GLuint pitch = drb->pitch;
-       if (drb->depthHasSurface) {
-               return 4 * (x + y * pitch);
-       } else {
-               GLuint ba, address = 0; /* a[0..1] = 0           */
-
-#ifdef COMPILE_R300
-               ba = (y / 8) * (pitch / 8) + (x / 8);
-#else
-               ba = (y / 16) * (pitch / 16) + (x / 16);
-#endif
-
-               address |= (x & 0x7) << 2;      /* a[2..4] = x[0..2]     */
-               address |= (y & 0x3) << 5;      /* a[5..6] = y[0..1]     */
-               address |= (((x & 0x10) >> 2) ^ (y & 0x4)) << 5;        /* a[7]    = x[4] ^ y[2] */
-               address |= (ba & 0x3) << 8;     /* a[8..9] = ba[0..1]    */
-
-               address |= (y & 0x8) << 7;      /* a[10]   = y[3]        */
-               address |= (((x & 0x8) << 1) ^ (y & 0x10)) << 7;        /* a[11]   = x[3] ^ y[4] */
-               address |= (ba & ~0x3) << 10;   /* a[12..] = ba[2..]     */
-
-               return address;
-       }
-}
-
-static INLINE GLuint
-radeon_mba_z16(const driRenderbuffer * drb, GLint x, GLint y)
-{
-       GLuint pitch = drb->pitch;
-       if (drb->depthHasSurface) {
-               return 2 * (x + y * pitch);
-       } else {
-               GLuint ba, address = 0; /* a[0]    = 0           */
-
-               ba = (y / 16) * (pitch / 32) + (x / 32);
-
-               address |= (x & 0x7) << 1;      /* a[1..3] = x[0..2]     */
-               address |= (y & 0x7) << 4;      /* a[4..6] = y[0..2]     */
-               address |= (x & 0x8) << 4;      /* a[7]    = x[3]        */
-               address |= (ba & 0x3) << 8;     /* a[8..9] = ba[0..1]    */
-               address |= (y & 0x8) << 7;      /* a[10]   = y[3]        */
-               address |= ((x & 0x10) ^ (y & 0x10)) << 7;      /* a[11]   = x[4] ^ y[4] */
-               address |= (ba & ~0x3) << 10;   /* a[12..] = ba[2..]     */
-
-               return address;
-       }
-}
-
-/* 16-bit depth buffer functions
- */
-#define VALUE_TYPE GLushort
-
-#define WRITE_DEPTH( _x, _y, d )                                       \
-   *(GLushort *)(buf + radeon_mba_z16( drb, _x + xo, _y + yo )) = d;
-
-#define READ_DEPTH( d, _x, _y )                                                \
-   d = *(GLushort *)(buf + radeon_mba_z16( drb, _x + xo, _y + yo ));
-
-#define TAG(x) radeon##x##_z16
-#include "depthtmp.h"
-
-/* 24 bit depth, 8 bit stencil depthbuffer functions
- *
- * Careful: It looks like the R300 uses ZZZS byte order while the R200
- * uses SZZZ for 24 bit depth, 8 bit stencil mode.
- */
-#define VALUE_TYPE GLuint
-
-#ifdef COMPILE_R300
-#define WRITE_DEPTH( _x, _y, d )                                       \
-do {                                                                   \
-   GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo );            \
-   GLuint tmp = *(GLuint *)(buf + offset);                             \
-   tmp &= 0x000000ff;                                                  \
-   tmp |= ((d << 8) & 0xffffff00);                                     \
-   *(GLuint *)(buf + offset) = tmp;                                    \
-} while (0)
-#else
-#define WRITE_DEPTH( _x, _y, d )                                       \
-do {                                                                   \
-   GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo );            \
-   GLuint tmp = *(GLuint *)(buf + offset);                             \
-   tmp &= 0xff000000;                                                  \
-   tmp |= ((d) & 0x00ffffff);                                          \
-   *(GLuint *)(buf + offset) = tmp;                                    \
-} while (0)
-#endif
-
-#ifdef COMPILE_R300
-#define READ_DEPTH( d, _x, _y )                                                \
-  do { \
-    d = (*(GLuint *)(buf + radeon_mba_z32( drb, _x + xo,               \
-                                        _y + yo )) & 0xffffff00) >> 8; \
-  }while(0)
-#else
-#define READ_DEPTH( d, _x, _y )                                                \
-   d = *(GLuint *)(buf + radeon_mba_z32( drb, _x + xo,                 \
-                                        _y + yo )) & 0x00ffffff;
-#endif
-
-#define TAG(x) radeon##x##_z24_s8
-#include "depthtmp.h"
-
-/* ================================================================
- * Stencil buffer
- */
-
-/* 24 bit depth, 8 bit stencil depthbuffer functions
- */
-#ifdef COMPILE_R300
-#define WRITE_STENCIL( _x, _y, d )                                     \
-do {                                                                   \
-   GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo );            \
-   GLuint tmp = *(GLuint *)(buf + offset);                             \
-   tmp &= 0xffffff00;                                                  \
-   tmp |= (d) & 0xff;                                                  \
-   *(GLuint *)(buf + offset) = tmp;                                    \
-} while (0)
-#else
-#define WRITE_STENCIL( _x, _y, d )                                     \
-do {                                                                   \
-   GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo );            \
-   GLuint tmp = *(GLuint *)(buf + offset);                             \
-   tmp &= 0x00ffffff;                                                  \
-   tmp |= (((d) & 0xff) << 24);                                                \
-   *(GLuint *)(buf + offset) = tmp;                                    \
-} while (0)
-#endif
-
-#ifdef COMPILE_R300
-#define READ_STENCIL( d, _x, _y )                                      \
-do {                                                                   \
-   GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo );            \
-   GLuint tmp = *(GLuint *)(buf + offset);                             \
-   d = tmp & 0x000000ff;                                               \
-} while (0)
-#else
-#define READ_STENCIL( d, _x, _y )                                      \
-do {                                                                   \
-   GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo );            \
-   GLuint tmp = *(GLuint *)(buf + offset);                             \
-   d = (tmp & 0xff000000) >> 24;                                       \
-} while (0)
-#endif
-
-#define TAG(x) radeon##x##_z24_s8
-#include "stenciltmp.h"
-
-/* Move locking out to get reasonable span performance (10x better
- * than doing this in HW_LOCK above).  WaitForIdle() is the main
- * culprit.
- */
-
-static void radeonSpanRenderStart(GLcontext * ctx)
-{
-       radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-#ifdef COMPILE_R300
-       r300ContextPtr r300 = (r300ContextPtr) rmesa;
-       R300_FIREVERTICES(r300);
-#else
-       RADEON_FIREVERTICES(rmesa);
-#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)
-{
-       radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-       _swrast_flush(ctx);
-       UNLOCK_HARDWARE(rmesa);
-}
-
-void radeonInitSpanFuncs(GLcontext * ctx)
-{
-       struct swrast_device_driver *swdd =
-           _swrast_GetDeviceDriverReference(ctx);
-       swdd->SpanRenderStart = radeonSpanRenderStart;
-       swdd->SpanRenderFinish = radeonSpanRenderFinish;
-}
-
-/**
- * Plug in the Get/Put routines for the given driRenderbuffer.
- */
-void radeonSetSpanFunctions(driRenderbuffer * drb, const GLvisual * vis)
-{
-       if (drb->Base.InternalFormat == GL_RGBA) {
-               if (vis->redBits == 5 && vis->greenBits == 6
-                   && vis->blueBits == 5) {
-                       radeonInitPointers_RGB565(&drb->Base);
-               } else {
-                       radeonInitPointers_ARGB8888(&drb->Base);
-               }
-       } else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
-               radeonInitDepthPointers_z16(&drb->Base);
-       } else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
-               radeonInitDepthPointers_z24_s8(&drb->Base);
-       } else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
-               radeonInitStencilPointers_z24_s8(&drb->Base);
-       }
-}
diff --git a/src/mesa/drivers/dri/r300/radeon_state.c b/src/mesa/drivers/dri/r300/radeon_state.c
deleted file mode 100644 (file)
index c401da6..0000000
+++ /dev/null
@@ -1,244 +0,0 @@
-/**************************************************************************
-
-Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
-
-The Weather Channel (TM) funded Tungsten Graphics to develop the
-initial release of the Radeon 8500 driver under the XFree86 license.
-This notice must be preserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "main/glheader.h"
-#include "main/imports.h"
-#include "main/api_arrayelt.h"
-#include "main/enums.h"
-#include "main/framebuffer.h"
-#include "main/colormac.h"
-#include "main/light.h"
-
-#include "swrast/swrast.h"
-#include "vbo/vbo.h"
-#include "tnl/tnl.h"
-#include "tnl/t_pipeline.h"
-#include "swrast_setup/swrast_setup.h"
-
-#include "radeon_ioctl.h"
-#include "radeon_state.h"
-#include "r300_ioctl.h"
-
-
-/* =============================================================
- * Scissoring
- */
-
-static GLboolean intersect_rect(drm_clip_rect_t * out,
-                               drm_clip_rect_t * a, drm_clip_rect_t * b)
-{
-       *out = *a;
-       if (b->x1 > out->x1)
-               out->x1 = b->x1;
-       if (b->y1 > out->y1)
-               out->y1 = b->y1;
-       if (b->x2 < out->x2)
-               out->x2 = b->x2;
-       if (b->y2 < out->y2)
-               out->y2 = b->y2;
-       if (out->x1 >= out->x2)
-               return GL_FALSE;
-       if (out->y1 >= out->y2)
-               return GL_FALSE;
-       return GL_TRUE;
-}
-
-void radeonRecalcScissorRects(radeonContextPtr radeon)
-{
-       drm_clip_rect_t *out;
-       int i;
-
-       /* Grow cliprect store?
-        */
-       if (radeon->state.scissor.numAllocedClipRects < radeon->numClipRects) {
-               while (radeon->state.scissor.numAllocedClipRects <
-                      radeon->numClipRects) {
-                       radeon->state.scissor.numAllocedClipRects += 1; /* zero case */
-                       radeon->state.scissor.numAllocedClipRects *= 2;
-               }
-
-               if (radeon->state.scissor.pClipRects)
-                       FREE(radeon->state.scissor.pClipRects);
-
-               radeon->state.scissor.pClipRects =
-                   MALLOC(radeon->state.scissor.numAllocedClipRects *
-                          sizeof(drm_clip_rect_t));
-
-               if (radeon->state.scissor.pClipRects == NULL) {
-                       radeon->state.scissor.numAllocedClipRects = 0;
-                       return;
-               }
-       }
-
-       out = radeon->state.scissor.pClipRects;
-       radeon->state.scissor.numClipRects = 0;
-
-       for (i = 0; i < radeon->numClipRects; i++) {
-               if (intersect_rect(out,
-                                  &radeon->pClipRects[i],
-                                  &radeon->state.scissor.rect)) {
-                       radeon->state.scissor.numClipRects++;
-                       out++;
-               }
-       }
-}
-
-void radeonUpdateScissor(GLcontext* ctx)
-{
-       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
-
-       if (radeon->dri.drawable) {
-               __DRIdrawablePrivate *dPriv = radeon->dri.drawable;
-               int x1 = dPriv->x + ctx->Scissor.X;
-               int y1 = dPriv->y + dPriv->h - (ctx->Scissor.Y + ctx->Scissor.Height);
-
-               radeon->state.scissor.rect.x1 = x1;
-               radeon->state.scissor.rect.y1 = y1;
-               radeon->state.scissor.rect.x2 = x1 + ctx->Scissor.Width;
-               radeon->state.scissor.rect.y2 = y1 + ctx->Scissor.Height;
-
-               radeonRecalcScissorRects(radeon);
-       }
-}
-
-static void radeonScissor(GLcontext* ctx, GLint x, GLint y, GLsizei w, GLsizei h)
-{
-       if (ctx->Scissor.Enabled) {
-               /* We don't pipeline cliprect changes */
-               r300Flush(ctx);
-               radeonUpdateScissor(ctx);
-       }
-}
-
-
-/**
- * Update cliprects and scissors.
- */
-void radeonSetCliprects(radeonContextPtr radeon)
-{
-       __DRIdrawablePrivate *const drawable = radeon->dri.drawable;
-       __DRIdrawablePrivate *const readable = radeon->dri.readable;
-       GLframebuffer *const draw_fb = (GLframebuffer*)drawable->driverPrivate;
-       GLframebuffer *const read_fb = (GLframebuffer*)readable->driverPrivate;
-
-       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) {
-                       radeon->numClipRects = drawable->numClipRects;
-                       radeon->pClipRects = drawable->pClipRects;
-               } else {
-                       radeon->numClipRects = drawable->numBackClipRects;
-                       radeon->pClipRects = drawable->pBackClipRects;
-               }
-       } else {
-               /* front buffer (or none, or multiple buffers */
-               radeon->numClipRects = drawable->numClipRects;
-               radeon->pClipRects = drawable->pClipRects;
-       }
-
-       if ((draw_fb->Width != drawable->w) ||
-           (draw_fb->Height != drawable->h)) {
-               _mesa_resize_framebuffer(radeon->glCtx, draw_fb,
-                                        drawable->w, drawable->h);
-               draw_fb->Initialized = GL_TRUE;
-       }
-
-       if (drawable != readable) {
-               if ((read_fb->Width != readable->w) ||
-                   (read_fb->Height != readable->h)) {
-                       _mesa_resize_framebuffer(radeon->glCtx, read_fb,
-                                                readable->w, readable->h);
-                       read_fb->Initialized = GL_TRUE;
-               }
-       }
-
-       if (radeon->state.scissor.enabled)
-               radeonRecalcScissorRects(radeon);
-
-       radeon->lastStamp = drawable->lastStamp;
-}
-
-
-/**
- * Handle common enable bits.
- * Called as a fallback by r200Enable/r300Enable.
- */
-void radeonEnable(GLcontext* ctx, GLenum cap, GLboolean state)
-{
-       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
-
-       switch(cap) {
-       case GL_SCISSOR_TEST:
-               /* We don't pipeline cliprect & scissor changes */
-               r300Flush(ctx);
-
-               radeon->state.scissor.enabled = state;
-               radeonUpdateScissor(ctx);
-               break;
-
-       default:
-               return;
-       }
-}
-
-
-/**
- * Initialize default state.
- * This function is called once at context init time from
- * r200InitState/r300InitState
- */
-void radeonInitState(radeonContextPtr radeon)
-{
-       radeon->Fallback = 0;
-
-       if (radeon->glCtx->Visual.doubleBufferMode && radeon->sarea->pfCurrentPage == 0) {
-               radeon->state.color.drawOffset = radeon->radeonScreen->backOffset;
-               radeon->state.color.drawPitch = radeon->radeonScreen->backPitch;
-       } else {
-               radeon->state.color.drawOffset = radeon->radeonScreen->frontOffset;
-               radeon->state.color.drawPitch = radeon->radeonScreen->frontPitch;
-       }
-}
-
-
-/**
- * Initialize common state functions.
- * Called by r200InitStateFuncs/r300InitStateFuncs
- */
-void radeonInitStateFuncs(struct dd_function_table *functions)
-{
-       functions->Scissor = radeonScissor;
-}
diff --git a/src/mesa/drivers/dri/r300/radeon_state.h b/src/mesa/drivers/dri/r300/radeon_state.h
deleted file mode 100644 (file)
index 821cb40..0000000
+++ /dev/null
@@ -1,43 +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 __RADEON_STATE_H__
-#define __RADEON_STATE_H__
-
-extern void radeonRecalcScissorRects(radeonContextPtr radeon);
-extern void radeonSetCliprects(radeonContextPtr radeon);
-extern void radeonUpdateScissor(GLcontext* ctx);
-
-extern void radeonEnable(GLcontext* ctx, GLenum cap, GLboolean state);
-
-extern void radeonInitState(radeonContextPtr radeon);
-extern void radeonInitStateFuncs(struct dd_function_table* functions);
-
-#endif
index f223b2d922882d1b6860d3bcad310b76231d12e4..ba409ba8130d45bddf699444616f8b85b6b5c19d 100644 (file)
@@ -4,25 +4,37 @@
 TOP = ../../../../..
 include $(TOP)/configs/current
 
+CFLAGS += $(RADEON_CFLAGS)
+
 LIBNAME = radeon_dri.so
 
 MINIGLX_SOURCES = server/radeon_dri.c 
 
+RADEON_COMMON_SOURCES = \
+       radeon_texture.c \
+       radeon_common_context.c \
+       radeon_common.c \
+       radeon_dma.c \
+       radeon_lock.c \
+       radeon_bo_legacy.c \
+       radeon_cs_legacy.c \
+       radeon_mipmap_tree.c \
+       radeon_span.c \
+       radeon_fbo.c
+
 DRIVER_SOURCES = \
        radeon_context.c \
        radeon_ioctl.c \
-       radeon_lock.c \
        radeon_screen.c \
        radeon_state.c \
        radeon_state_init.c \
        radeon_tex.c \
-       radeon_texmem.c \
        radeon_texstate.c \
        radeon_tcl.c \
        radeon_swtcl.c \
-       radeon_span.c \
        radeon_maos.c \
-       radeon_sanity.c 
+       radeon_sanity.c \
+       $(RADEON_COMMON_SOURCES)
 
 C_SOURCES = \
        $(COMMON_SOURCES) \
@@ -30,6 +42,8 @@ C_SOURCES = \
 
 DRIVER_DEFINES = -DRADEON_COMMON=0
 
+DRI_LIB_DEPS += $(RADEON_LDFLAGS)
+
 X86_SOURCES = 
 
 include ../Makefile.template
diff --git a/src/mesa/drivers/dri/radeon/radeon_bo_drm.h b/src/mesa/drivers/dri/radeon/radeon_bo_drm.h
new file mode 100644 (file)
index 0000000..1ed13f1
--- /dev/null
@@ -0,0 +1,182 @@
+/* 
+ * Copyright Â© 2008 Jérôme Glisse
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or 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:
+ *      Jérôme Glisse <glisse@freedesktop.org>
+ */
+#ifndef RADEON_BO_H
+#define RADEON_BO_H
+
+#include <stdio.h>
+#include <stdint.h>
+//#include "radeon_track.h"
+
+/* bo object */
+#define RADEON_BO_FLAGS_MACRO_TILE  1
+#define RADEON_BO_FLAGS_MICRO_TILE  2
+
+struct radeon_bo_manager;
+
+struct radeon_bo {
+    uint32_t                    alignment;
+    uint32_t                    handle;
+    uint32_t                    size;
+    uint32_t                    domains;
+    uint32_t                    flags;
+    unsigned                    cref;
+#ifdef RADEON_BO_TRACK
+    struct radeon_track         *track;
+#endif
+    void                        *ptr;
+    struct radeon_bo_manager    *bom;
+    uint32_t                    space_accounted;
+};
+
+/* bo functions */
+struct radeon_bo_funcs {
+    struct radeon_bo *(*bo_open)(struct radeon_bo_manager *bom,
+                                 uint32_t handle,
+                                 uint32_t size,
+                                 uint32_t alignment,
+                                 uint32_t domains,
+                                 uint32_t flags);
+    void (*bo_ref)(struct radeon_bo *bo);
+    struct radeon_bo *(*bo_unref)(struct radeon_bo *bo);
+    int (*bo_map)(struct radeon_bo *bo, int write);
+    int (*bo_unmap)(struct radeon_bo *bo);
+    int (*bo_wait)(struct radeon_bo *bo);
+};
+
+struct radeon_bo_manager {
+    struct radeon_bo_funcs  *funcs;
+    int                     fd;
+
+#ifdef RADEON_BO_TRACK
+    struct radeon_tracker   tracker;
+#endif
+};
+    
+static inline void _radeon_bo_debug(struct radeon_bo *bo,
+                                    const char *op,
+                                    const char *file,
+                                    const char *func,
+                                    int line)
+{
+    fprintf(stderr, "%s %p 0x%08X 0x%08X 0x%08X [%s %s %d]\n",
+            op, bo, bo->handle, bo->size, bo->cref, file, func, line);
+}
+
+static inline struct radeon_bo *_radeon_bo_open(struct radeon_bo_manager *bom,
+                                                uint32_t handle,
+                                                uint32_t size,
+                                                uint32_t alignment,
+                                                uint32_t domains,
+                                                uint32_t flags,
+                                                const char *file,
+                                                const char *func,
+                                                int line)
+{
+    struct radeon_bo *bo;
+
+    bo = bom->funcs->bo_open(bom, handle, size, alignment, domains, flags);
+#ifdef RADEON_BO_TRACK
+    if (bo) {
+        bo->track = radeon_tracker_add_track(&bom->tracker, bo->handle);
+        radeon_track_add_event(bo->track, file, func, "open", line);
+    }
+#endif
+    return bo;
+}
+
+static inline void _radeon_bo_ref(struct radeon_bo *bo,
+                                  const char *file,
+                                  const char *func,
+                                  int line)
+{
+    bo->cref++;
+#ifdef RADEON_BO_TRACK
+    radeon_track_add_event(bo->track, file, func, "ref", line); 
+#endif
+    bo->bom->funcs->bo_ref(bo);
+}
+
+static inline struct radeon_bo *_radeon_bo_unref(struct radeon_bo *bo,
+                                                 const char *file,
+                                                 const char *func,
+                                                 int line)
+{
+    bo->cref--;
+#ifdef RADEON_BO_TRACK
+    radeon_track_add_event(bo->track, file, func, "unref", line);
+    if (bo->cref <= 0) {
+        radeon_tracker_remove_track(&bo->bom->tracker, bo->track);
+        bo->track = NULL;
+    }
+#endif
+    return bo->bom->funcs->bo_unref(bo);
+}
+
+static inline int _radeon_bo_map(struct radeon_bo *bo,
+                                 int write,
+                                 const char *file,
+                                 const char *func,
+                                 int line)
+{
+    return bo->bom->funcs->bo_map(bo, write);
+}
+
+static inline int _radeon_bo_unmap(struct radeon_bo *bo,
+                                   const char *file,
+                                   const char *func,
+                                   int line)
+{
+    return bo->bom->funcs->bo_unmap(bo);
+}
+
+static inline int _radeon_bo_wait(struct radeon_bo *bo,
+                                  const char *file,
+                                  const char *func,
+                                  int line)
+{
+    return bo->bom->funcs->bo_wait(bo);
+}
+
+#define radeon_bo_open(bom, h, s, a, d, f)\
+    _radeon_bo_open(bom, h, s, a, d, f, __FILE__, __FUNCTION__, __LINE__)
+#define radeon_bo_ref(bo)\
+    _radeon_bo_ref(bo, __FILE__, __FUNCTION__, __LINE__)
+#define radeon_bo_unref(bo)\
+    _radeon_bo_unref(bo, __FILE__, __FUNCTION__, __LINE__)
+#define radeon_bo_map(bo, w)\
+    _radeon_bo_map(bo, w, __FILE__, __FUNCTION__, __LINE__)
+#define radeon_bo_unmap(bo)\
+    _radeon_bo_unmap(bo, __FILE__, __FUNCTION__, __LINE__)
+#define radeon_bo_debug(bo, opcode)\
+    _radeon_bo_debug(bo, opcode, __FILE__, __FUNCTION__, __LINE__)
+#define radeon_bo_wait(bo) \
+    _radeon_bo_wait(bo, __FILE__, __func__, __LINE__)
+
+#endif
diff --git a/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c b/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c
new file mode 100644 (file)
index 0000000..6a8da40
--- /dev/null
@@ -0,0 +1,830 @@
+/* 
+ * Copyright Â© 2008 Nicolai Haehnle
+ * Copyright Â© 2008 Dave Airlie
+ * Copyright Â© 2008 Jérôme Glisse
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or 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:
+ *      Aapo Tahkola <aet@rasterburn.org>
+ *      Nicolai Haehnle <prefect_@gmx.net>
+ *      Dave Airlie
+ *      Jérôme Glisse <glisse@freedesktop.org>
+ */
+#include <stdio.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include "xf86drm.h"
+#include "texmem.h"
+#include "main/simple_list.h"
+
+#include "drm.h"
+#include "radeon_drm.h"
+#include "radeon_common.h"
+#include "radeon_bocs_wrapper.h"
+#include "radeon_macros.h"
+
+/* no seriously texmem.c is this screwed up */
+struct bo_legacy_texture_object {
+    driTextureObject    base;
+    struct bo_legacy *parent;
+};
+
+struct bo_legacy {
+    struct radeon_bo    base;
+    int                 map_count;
+    uint32_t            pending;
+    int                 is_pending;
+    int                 static_bo;
+    uint32_t            offset;
+    struct bo_legacy_texture_object *tobj;
+    int                 validated;
+    int                 dirty;
+    void                *ptr;
+    struct bo_legacy    *next, *prev;
+    struct bo_legacy    *pnext, *pprev;
+};
+
+struct bo_manager_legacy {
+    struct radeon_bo_manager    base;
+    unsigned                    nhandle;
+    unsigned                    nfree_handles;
+    unsigned                    cfree_handles;
+    uint32_t                    current_age;
+    struct bo_legacy            bos;
+    struct bo_legacy            pending_bos;
+    uint32_t                    fb_location;
+    uint32_t                    texture_offset;
+    unsigned                    dma_alloc_size;
+    uint32_t                    dma_buf_count;
+    unsigned                    cpendings;
+    driTextureObject            texture_swapped;
+    driTexHeap                  *texture_heap;
+    struct radeon_screen        *screen;
+    unsigned                    *free_handles;
+};
+
+static void bo_legacy_tobj_destroy(void *data, driTextureObject *t)
+{
+    struct bo_legacy_texture_object *tobj = (struct bo_legacy_texture_object *)t;
+    
+    if (tobj->parent) {
+        tobj->parent->tobj = NULL;
+        tobj->parent->validated = 0;
+    }
+}
+
+static void inline clean_handles(struct bo_manager_legacy *bom)
+{
+  while (bom->cfree_handles > 0 &&
+        !bom->free_handles[bom->cfree_handles - 1])
+    bom->cfree_handles--;
+
+}
+static int legacy_new_handle(struct bo_manager_legacy *bom, uint32_t *handle)
+{
+    uint32_t tmp;
+
+    *handle = 0;
+    if (bom->nhandle == 0xFFFFFFFF) {
+        return -EINVAL;
+    }
+    if (bom->cfree_handles > 0) {
+        tmp = bom->free_handles[--bom->cfree_handles];
+       clean_handles(bom);
+    } else {
+        bom->cfree_handles = 0;
+        tmp = bom->nhandle++;
+    }
+    assert(tmp);
+    *handle = tmp;
+    return 0;
+}
+
+static int legacy_free_handle(struct bo_manager_legacy *bom, uint32_t handle)
+{
+    uint32_t *handles;
+
+    if (!handle) {
+        return 0;
+    }
+    if (handle == (bom->nhandle - 1)) {
+        int i;
+
+        bom->nhandle--;
+        for (i = bom->cfree_handles - 1; i >= 0; i--) {
+            if (bom->free_handles[i] == (bom->nhandle - 1)) {
+                bom->nhandle--;
+                bom->free_handles[i] = 0;
+            }
+        }
+        clean_handles(bom);
+        return 0;
+    }
+    if (bom->cfree_handles < bom->nfree_handles) {
+        bom->free_handles[bom->cfree_handles++] = handle;
+        return 0;
+    }
+    bom->nfree_handles += 0x100;
+    handles = (uint32_t*)realloc(bom->free_handles, bom->nfree_handles * 4);
+    if (handles == NULL) {
+        bom->nfree_handles -= 0x100;
+        return -ENOMEM;
+    }
+    bom->free_handles = handles;
+    bom->free_handles[bom->cfree_handles++] = handle;
+    return 0;
+}
+
+static void legacy_get_current_age(struct bo_manager_legacy *boml)
+{
+    drm_radeon_getparam_t gp;
+    unsigned char *RADEONMMIO = NULL;
+    int r;
+
+    if (IS_R300_CLASS(boml->screen)) {
+       gp.param = RADEON_PARAM_LAST_CLEAR;
+       gp.value = (int *)&boml->current_age;
+       r = drmCommandWriteRead(boml->base.fd, DRM_RADEON_GETPARAM,
+                                    &gp, sizeof(gp));
+       if (r) {
+                fprintf(stderr, "%s: drmRadeonGetParam: %d\n", __FUNCTION__, r);
+         exit(1);
+       }
+    } else {
+        RADEONMMIO = boml->screen->mmio.map;
+        boml->current_age = boml->screen->scratch[3];
+        boml->current_age = INREG(RADEON_GUI_SCRATCH_REG3);
+    }
+}
+
+static int legacy_is_pending(struct radeon_bo *bo)
+{
+    struct bo_manager_legacy *boml = (struct bo_manager_legacy *)bo->bom;
+    struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
+
+    if (bo_legacy->is_pending <= 0) {
+        bo_legacy->is_pending = 0;
+        return 0;
+    }
+    if (boml->current_age >= bo_legacy->pending) {
+        if (boml->pending_bos.pprev == bo_legacy) {
+            boml->pending_bos.pprev = bo_legacy->pprev;
+        }
+        bo_legacy->pprev->pnext = bo_legacy->pnext;
+        if (bo_legacy->pnext) {
+            bo_legacy->pnext->pprev = bo_legacy->pprev;
+        }
+       assert(bo_legacy->is_pending <= bo->cref);
+        while (bo_legacy->is_pending--) {
+           bo = radeon_bo_unref(bo);
+           if (!bo)
+             break;
+        }
+       if (bo)
+         bo_legacy->is_pending = 0;
+        boml->cpendings--;
+        return 0;
+    }
+    return 1;
+}
+
+static int legacy_wait_pending(struct radeon_bo *bo)
+{
+    struct bo_manager_legacy *boml = (struct bo_manager_legacy *)bo->bom;
+    struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
+
+    if (!bo_legacy->is_pending) {
+        return 0;
+    }
+    /* FIXME: lockup and userspace busy looping that's all the folks */
+    legacy_get_current_age(boml);
+    while (legacy_is_pending(bo)) {
+        usleep(10);
+        legacy_get_current_age(boml);
+    }
+    return 0;
+}
+
+static void legacy_track_pending(struct bo_manager_legacy *boml, int debug)
+{
+    struct bo_legacy *bo_legacy;
+    struct bo_legacy *next;
+
+    legacy_get_current_age(boml);
+    bo_legacy = boml->pending_bos.pnext;
+    while (bo_legacy) {
+        if (debug)
+         fprintf(stderr,"pending %p %d %d %d\n", bo_legacy, bo_legacy->base.size,
+                 boml->current_age, bo_legacy->pending);
+        next = bo_legacy->pnext;
+        if (legacy_is_pending(&(bo_legacy->base))) {
+        }
+        bo_legacy = next;
+    } 
+}
+
+static int legacy_wait_any_pending(struct bo_manager_legacy *boml)
+{
+    struct bo_legacy *bo_legacy;
+
+    legacy_get_current_age(boml);
+    bo_legacy = boml->pending_bos.pnext;
+    if (!bo_legacy)
+      return -1;
+    legacy_wait_pending(&bo_legacy->base);
+    return 0;
+}
+
+static void legacy_kick_all_buffers(struct bo_manager_legacy *boml)
+{
+    struct bo_legacy *legacy;
+
+    legacy = boml->bos.next;
+    while (legacy != &boml->bos) {
+       if (legacy->tobj) {
+           if (legacy->validated) {
+               driDestroyTextureObject(&legacy->tobj->base);
+               legacy->tobj = 0;
+               legacy->validated = 0;
+           }
+       }
+       legacy = legacy->next;
+    }
+}
+
+static struct bo_legacy *bo_allocate(struct bo_manager_legacy *boml,
+                                     uint32_t size,
+                                     uint32_t alignment,
+                                     uint32_t domains,
+                                     uint32_t flags)
+{
+    struct bo_legacy *bo_legacy;
+    static int pgsize;
+
+    if (pgsize == 0)
+        pgsize = getpagesize() - 1;
+
+    size = (size + pgsize) & ~pgsize;
+
+    bo_legacy = (struct bo_legacy*)calloc(1, sizeof(struct bo_legacy));
+    if (bo_legacy == NULL) {
+        return NULL;
+    }
+    bo_legacy->base.bom = (struct radeon_bo_manager*)boml;
+    bo_legacy->base.handle = 0;
+    bo_legacy->base.size = size;
+    bo_legacy->base.alignment = alignment;
+    bo_legacy->base.domains = domains;
+    bo_legacy->base.flags = flags;
+    bo_legacy->base.ptr = NULL;
+    bo_legacy->map_count = 0;
+    bo_legacy->next = NULL;
+    bo_legacy->prev = NULL;
+    bo_legacy->pnext = NULL;
+    bo_legacy->pprev = NULL;
+    bo_legacy->next = boml->bos.next;
+    bo_legacy->prev = &boml->bos;
+    boml->bos.next = bo_legacy;
+    if (bo_legacy->next) {
+        bo_legacy->next->prev = bo_legacy;
+    }
+    return bo_legacy;
+}
+
+static int bo_dma_alloc(struct radeon_bo *bo)
+{
+    struct bo_manager_legacy *boml = (struct bo_manager_legacy *)bo->bom;
+    struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
+    drm_radeon_mem_alloc_t alloc;
+    unsigned size;
+    int base_offset;
+    int r;
+
+    /* align size on 4Kb */
+    size = (((4 * 1024) - 1) + bo->size) & ~((4 * 1024) - 1);
+    alloc.region = RADEON_MEM_REGION_GART;
+    alloc.alignment = bo_legacy->base.alignment;
+    alloc.size = size;
+    alloc.region_offset = &base_offset;
+    r = drmCommandWriteRead(bo->bom->fd,
+                            DRM_RADEON_ALLOC,
+                            &alloc,
+                            sizeof(alloc));
+    if (r) {
+        /* ptr is set to NULL if dma allocation failed */
+        bo_legacy->ptr = NULL;
+        return r;
+    }
+    bo_legacy->ptr = boml->screen->gartTextures.map + base_offset;
+    bo_legacy->offset = boml->screen->gart_texture_offset + base_offset;
+    bo->size = size;
+    boml->dma_alloc_size += size;
+    boml->dma_buf_count++;
+    return 0;
+}
+
+static int bo_dma_free(struct radeon_bo *bo)
+{
+    struct bo_manager_legacy *boml = (struct bo_manager_legacy *)bo->bom;
+    struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
+    drm_radeon_mem_free_t memfree;
+    int r;
+
+    if (bo_legacy->ptr == NULL) {
+        /* ptr is set to NULL if dma allocation failed */
+        return 0;
+    }
+    legacy_get_current_age(boml);
+    memfree.region = RADEON_MEM_REGION_GART;
+    memfree.region_offset  = bo_legacy->offset;
+    memfree.region_offset -= boml->screen->gart_texture_offset;
+    r = drmCommandWrite(boml->base.fd,
+                        DRM_RADEON_FREE,
+                        &memfree,
+                        sizeof(memfree));
+    if (r) {
+        fprintf(stderr, "Failed to free bo[%p] at %08x\n",
+                &bo_legacy->base, memfree.region_offset);
+        fprintf(stderr, "ret = %s\n", strerror(-r));
+        return r;
+    }
+    boml->dma_alloc_size -= bo_legacy->base.size;
+    boml->dma_buf_count--;
+    return 0;
+}
+
+static void bo_free(struct bo_legacy *bo_legacy)
+{
+    struct bo_manager_legacy *boml;
+
+    if (bo_legacy == NULL) {
+        return;
+    }
+    boml = (struct bo_manager_legacy *)bo_legacy->base.bom;
+    bo_legacy->prev->next = bo_legacy->next;
+    if (bo_legacy->next) {
+        bo_legacy->next->prev = bo_legacy->prev;
+    }
+    if (!bo_legacy->static_bo) {
+        legacy_free_handle(boml, bo_legacy->base.handle);
+        if (bo_legacy->base.domains & RADEON_GEM_DOMAIN_GTT) {
+            /* dma buffers */
+            bo_dma_free(&bo_legacy->base);
+        } else {
+           driDestroyTextureObject(&bo_legacy->tobj->base);
+           bo_legacy->tobj = NULL;
+            /* free backing store */
+            free(bo_legacy->ptr);
+        }
+    }
+    memset(bo_legacy, 0 , sizeof(struct bo_legacy));
+    free(bo_legacy);
+}
+
+static struct radeon_bo *bo_open(struct radeon_bo_manager *bom,
+                                 uint32_t handle,
+                                 uint32_t size,
+                                 uint32_t alignment,
+                                 uint32_t domains,
+                                 uint32_t flags)
+{
+    struct bo_manager_legacy *boml = (struct bo_manager_legacy *)bom;
+    struct bo_legacy *bo_legacy;
+    int r;
+
+    if (handle) {
+        bo_legacy = boml->bos.next;
+        while (bo_legacy) {
+            if (bo_legacy->base.handle == handle) {
+                radeon_bo_ref(&(bo_legacy->base));
+                return (struct radeon_bo*)bo_legacy;
+            }
+            bo_legacy = bo_legacy->next;
+        }
+        return NULL;
+    }
+
+    bo_legacy = bo_allocate(boml, size, alignment, domains, flags);
+    bo_legacy->static_bo = 0;
+    r = legacy_new_handle(boml, &bo_legacy->base.handle);
+    if (r) {
+        bo_free(bo_legacy);
+        return NULL;
+    }
+    if (bo_legacy->base.domains & RADEON_GEM_DOMAIN_GTT) {
+    retry:
+        legacy_track_pending(boml, 0);
+        /* dma buffers */
+
+        r = bo_dma_alloc(&(bo_legacy->base));
+        if (r) {
+         if (legacy_wait_any_pending(boml) == -1) {
+            bo_free(bo_legacy);
+           return NULL;
+         }
+         goto retry;
+         return NULL;
+        }
+    } else {
+        bo_legacy->ptr = malloc(bo_legacy->base.size);
+        if (bo_legacy->ptr == NULL) {
+            bo_free(bo_legacy);
+            return NULL;
+        }
+    }
+    radeon_bo_ref(&(bo_legacy->base));
+    return (struct radeon_bo*)bo_legacy;
+}
+
+static void bo_ref(struct radeon_bo *bo)
+{
+}
+
+static struct radeon_bo *bo_unref(struct radeon_bo *bo)
+{
+    struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
+
+    if (bo->cref <= 0) {
+        bo_legacy->prev->next = bo_legacy->next;
+        if (bo_legacy->next) {
+            bo_legacy->next->prev = bo_legacy->prev;
+        }
+        if (!bo_legacy->is_pending) {
+            bo_free(bo_legacy);
+        }
+        return NULL;
+    }
+    return bo;
+}
+
+static int bo_map(struct radeon_bo *bo, int write)
+{
+    struct bo_manager_legacy *boml = (struct bo_manager_legacy *)bo->bom;
+    struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
+    
+    legacy_wait_pending(bo);
+    bo_legacy->validated = 0;
+    bo_legacy->dirty = 1;
+    bo_legacy->map_count++;
+    bo->ptr = bo_legacy->ptr;
+    /* 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
+     */
+    if (!(bo->domains & RADEON_GEM_DOMAIN_GTT)) {
+        int p;
+        volatile int *buf = (int*)boml->screen->driScreen->pFB;
+        p = *buf;
+    }
+    return 0;
+}
+
+static int bo_unmap(struct radeon_bo *bo)
+{
+    struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
+
+    if (--bo_legacy->map_count > 0) {
+        return 0;
+    }
+    bo->ptr = NULL;
+    return 0;
+}
+
+static struct radeon_bo_funcs bo_legacy_funcs = {
+    bo_open,
+    bo_ref,
+    bo_unref,
+    bo_map,
+    bo_unmap
+};
+
+static int bo_vram_validate(struct radeon_bo *bo,
+                            uint32_t *soffset,
+                            uint32_t *eoffset)
+{
+    struct bo_manager_legacy *boml = (struct bo_manager_legacy *)bo->bom;
+    struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
+    int r;
+    int retry_count = 0, pending_retry = 0;
+    
+    if (!bo_legacy->tobj) {
+       bo_legacy->tobj = CALLOC(sizeof(struct bo_legacy_texture_object));
+       bo_legacy->tobj->parent = bo_legacy;
+       make_empty_list(&bo_legacy->tobj->base);
+       bo_legacy->tobj->base.totalSize = bo->size;
+    retry:
+        r = driAllocateTexture(&boml->texture_heap, 1,
+                               &bo_legacy->tobj->base);
+        if (r) {
+               pending_retry = 0;
+               while(boml->cpendings && pending_retry++ < 10000) {
+                       legacy_track_pending(boml, 0);
+                       retry_count++;
+                       if (retry_count > 2) {
+                               free(bo_legacy->tobj);
+                               bo_legacy->tobj = NULL;
+                               fprintf(stderr, "Ouch! vram_validate failed %d\n", r);
+                               return -1;
+                       }
+                       goto retry;
+               }
+       }
+        bo_legacy->offset = boml->texture_offset +
+                            bo_legacy->tobj->base.memBlock->ofs;
+        bo_legacy->dirty = 1;
+    }
+
+    assert(bo_legacy->tobj->base.memBlock);
+
+    if (bo_legacy->tobj)
+       driUpdateTextureLRU(&bo_legacy->tobj->base);
+
+    if (bo_legacy->dirty || bo_legacy->tobj->base.dirty_images[0]) {
+        /* Copy to VRAM using a blit.
+         * All memory is 4K aligned. We're using 1024 pixels wide blits.
+         */
+        drm_radeon_texture_t tex;
+        drm_radeon_tex_image_t tmp;
+        int ret;
+
+        tex.offset = bo_legacy->offset;
+        tex.image = &tmp;
+        assert(!(tex.offset & 1023));
+
+        tmp.x = 0;
+        tmp.y = 0;
+        if (bo->size < 4096) {
+            tmp.width = (bo->size + 3) / 4;
+            tmp.height = 1;
+        } else {
+            tmp.width = 1024;
+            tmp.height = (bo->size + 4095) / 4096;
+        }
+        tmp.data = bo_legacy->ptr;
+        tex.format = RADEON_TXFORMAT_ARGB8888;
+        tex.width = tmp.width;
+        tex.height = tmp.height;
+        tex.pitch = MAX2(tmp.width / 16, 1);
+        do {
+            ret = drmCommandWriteRead(bo->bom->fd,
+                                      DRM_RADEON_TEXTURE,
+                                      &tex,
+                                      sizeof(drm_radeon_texture_t));
+            if (ret) {
+                if (RADEON_DEBUG & DEBUG_IOCTL)
+                    fprintf(stderr, "DRM_RADEON_TEXTURE:  again!\n");
+                usleep(1);
+            }
+        } while (ret == -EAGAIN);
+        bo_legacy->dirty = 0;
+       bo_legacy->tobj->base.dirty_images[0] = 0;
+    }
+    return 0;
+}
+
+/* 
+ *  radeon_bo_legacy_validate -
+ *  returns:
+ *  0 - all good
+ *  -EINVAL - mapped buffer can't be validated
+ *  -EAGAIN - restart validation we've kicked all the buffers out
+ */
+int radeon_bo_legacy_validate(struct radeon_bo *bo,
+                              uint32_t *soffset,
+                              uint32_t *eoffset)
+{
+    struct bo_manager_legacy *boml = (struct bo_manager_legacy *)bo->bom;
+    struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
+    int r;
+    int retries = 0;
+
+    if (bo_legacy->map_count) {
+        fprintf(stderr, "bo(%p, %d) is mapped (%d) can't valide it.\n",
+                bo, bo->size, bo_legacy->map_count);
+        return -EINVAL;
+    }
+    if (bo_legacy->static_bo || bo_legacy->validated) {
+        *soffset = bo_legacy->offset;
+        *eoffset = bo_legacy->offset + bo->size;
+        return 0;
+    }
+    if (!(bo->domains & RADEON_GEM_DOMAIN_GTT)) {
+
+        r = bo_vram_validate(bo, soffset, eoffset);
+        if (r) {
+           legacy_track_pending(boml, 0);
+           legacy_kick_all_buffers(boml);
+           retries++;
+           if (retries == 2) {
+               fprintf(stderr,"legacy bo: failed to get relocations into aperture\n");
+               assert(0);
+               exit(-1);
+           }
+           return -EAGAIN;
+        }
+    }
+    *soffset = bo_legacy->offset;
+    *eoffset = bo_legacy->offset + bo->size;
+    bo_legacy->validated = 1;
+    return 0;
+}
+
+void radeon_bo_legacy_pending(struct radeon_bo *bo, uint32_t pending)
+{
+    struct bo_manager_legacy *boml = (struct bo_manager_legacy *)bo->bom;
+    struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
+
+    bo_legacy->pending = pending;
+    bo_legacy->is_pending++;
+    /* add to pending list */
+    radeon_bo_ref(bo);
+    if (bo_legacy->is_pending > 1) {
+        return;    
+    }
+    bo_legacy->pprev = boml->pending_bos.pprev;
+    bo_legacy->pnext = NULL;
+    bo_legacy->pprev->pnext = bo_legacy;
+    boml->pending_bos.pprev = bo_legacy;
+    boml->cpendings++;
+}
+
+void radeon_bo_manager_legacy_dtor(struct radeon_bo_manager *bom)
+{
+    struct bo_manager_legacy *boml = (struct bo_manager_legacy *)bom;
+    struct bo_legacy *bo_legacy;
+
+    if (bom == NULL) {
+        return;
+    }
+    bo_legacy = boml->bos.next;
+    while (bo_legacy) {
+        struct bo_legacy *next;
+
+        next = bo_legacy->next;
+        bo_free(bo_legacy);
+        bo_legacy = next;
+    }
+    driDestroyTextureHeap(boml->texture_heap);
+    free(boml->free_handles);
+    free(boml);
+}
+
+static struct bo_legacy *radeon_legacy_bo_alloc_static(struct bo_manager_legacy *bom,
+                                                      int size, uint32_t offset)
+{
+    struct bo_legacy *bo;
+
+    bo = bo_allocate(bom, size, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+    if (bo == NULL)
+       return NULL;
+    bo->static_bo = 1;
+    bo->offset = offset + bom->fb_location;
+    bo->base.handle = bo->offset;
+    bo->ptr = bom->screen->driScreen->pFB + offset;
+    if (bo->base.handle > bom->nhandle) {
+        bom->nhandle = bo->base.handle + 1;
+    }
+    radeon_bo_ref(&(bo->base));
+    return bo;
+}
+
+struct radeon_bo_manager *radeon_bo_manager_legacy_ctor(struct radeon_screen *scrn)
+{
+    struct bo_manager_legacy *bom;
+    struct bo_legacy *bo;
+    unsigned size;
+
+    bom = (struct bo_manager_legacy*)
+          calloc(1, sizeof(struct bo_manager_legacy));
+    if (bom == NULL) {
+        return NULL;
+    }
+
+    make_empty_list(&bom->texture_swapped);
+
+    bom->texture_heap = driCreateTextureHeap(0,
+                                             bom,
+                                             scrn->texSize[0],
+                                             12,
+                                             RADEON_NR_TEX_REGIONS,
+                                             (drmTextureRegionPtr)scrn->sarea->tex_list[0],
+                                             &scrn->sarea->tex_age[0],
+                                             &bom->texture_swapped,
+                                             sizeof(struct bo_legacy_texture_object),
+                                             &bo_legacy_tobj_destroy);
+    bom->texture_offset = scrn->texOffset[0];
+
+    bom->base.funcs = &bo_legacy_funcs;
+    bom->base.fd = scrn->driScreen->fd;
+    bom->bos.next = NULL;
+    bom->bos.prev = NULL;
+    bom->pending_bos.pprev = &bom->pending_bos;
+    bom->pending_bos.pnext = NULL;
+    bom->screen = scrn;
+    bom->fb_location = scrn->fbLocation;
+    bom->nhandle = 1;
+    bom->cfree_handles = 0;
+    bom->nfree_handles = 0x400;
+    bom->free_handles = (uint32_t*)malloc(bom->nfree_handles * 4);
+    if (bom->free_handles == NULL) {
+        radeon_bo_manager_legacy_dtor((struct radeon_bo_manager*)bom);
+        return NULL;
+    }
+
+    /* biggest framebuffer size */
+    size = 4096*4096*4; 
+
+    /* allocate front */
+    bo = radeon_legacy_bo_alloc_static(bom, size, bom->screen->frontOffset);
+    if (!bo) {
+        radeon_bo_manager_legacy_dtor((struct radeon_bo_manager*)bom);
+        return NULL;
+    }
+    if (scrn->sarea->tiling_enabled) {
+        bo->base.flags = RADEON_BO_FLAGS_MACRO_TILE;
+    }
+
+    /* allocate back */
+    bo = radeon_legacy_bo_alloc_static(bom, size, bom->screen->backOffset);
+    if (!bo) {
+        radeon_bo_manager_legacy_dtor((struct radeon_bo_manager*)bom);
+        return NULL;
+    }
+    if (scrn->sarea->tiling_enabled) {
+        bo->base.flags = RADEON_BO_FLAGS_MACRO_TILE;
+    }
+
+    /* allocate depth */
+    bo = radeon_legacy_bo_alloc_static(bom, size, bom->screen->depthOffset);
+    if (!bo) {
+        radeon_bo_manager_legacy_dtor((struct radeon_bo_manager*)bom);
+        return NULL;
+    }
+    bo->base.flags = 0;
+    if (scrn->sarea->tiling_enabled) {
+        bo->base.flags |= RADEON_BO_FLAGS_MACRO_TILE;
+        bo->base.flags |= RADEON_BO_FLAGS_MICRO_TILE;
+    }
+    return (struct radeon_bo_manager*)bom;
+}
+
+void radeon_bo_legacy_texture_age(struct radeon_bo_manager *bom)
+{
+    struct bo_manager_legacy *boml = (struct bo_manager_legacy *)bom;
+    DRI_AGE_TEXTURES(boml->texture_heap);
+}
+
+unsigned radeon_bo_legacy_relocs_size(struct radeon_bo *bo)
+{
+    struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
+
+    if (bo_legacy->static_bo || (bo->domains & RADEON_GEM_DOMAIN_GTT)) {
+        return 0;
+    }
+    return bo->size;
+}
+
+int radeon_legacy_bo_is_static(struct radeon_bo *bo)
+{
+    struct bo_legacy *bo_legacy = (struct bo_legacy*)bo;
+    return bo_legacy->static_bo;
+}
+
diff --git a/src/mesa/drivers/dri/radeon/radeon_bo_legacy.h b/src/mesa/drivers/dri/radeon/radeon_bo_legacy.h
new file mode 100644 (file)
index 0000000..9187cd7
--- /dev/null
@@ -0,0 +1,47 @@
+/* 
+ * Copyright Â© 2008 Nicolai Haehnle
+ * Copyright Â© 2008 Jérôme Glisse
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or 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:
+ *      Aapo Tahkola <aet@rasterburn.org>
+ *      Nicolai Haehnle <prefect_@gmx.net>
+ *      Jérôme Glisse <glisse@freedesktop.org>
+ */
+#ifndef RADEON_BO_LEGACY_H
+#define RADEON_BO_LEGACY_H
+
+#include "radeon_screen.h"
+
+void radeon_bo_legacy_pending(struct radeon_bo *bo, uint32_t pending);
+int radeon_bo_legacy_validate(struct radeon_bo *bo,
+                              uint32_t *soffset,
+                              uint32_t *eoffset);
+struct radeon_bo_manager *radeon_bo_manager_legacy_ctor(struct radeon_screen *scrn);
+void radeon_bo_manager_legacy_dtor(struct radeon_bo_manager *bom);
+void radeon_bo_legacy_texture_age(struct radeon_bo_manager *bom);
+unsigned radeon_bo_legacy_relocs_size(struct radeon_bo *bo);
+
+int radeon_legacy_bo_is_static(struct radeon_bo *bo);
+#endif
diff --git a/src/mesa/drivers/dri/radeon/radeon_bocs_wrapper.h b/src/mesa/drivers/dri/radeon/radeon_bocs_wrapper.h
new file mode 100644 (file)
index 0000000..6f1a0b4
--- /dev/null
@@ -0,0 +1,85 @@
+#ifndef RADEON_CS_WRAPPER_H
+#define RADEON_CS_WRAPPER_H
+
+#ifndef RADEON_PARAM_DEVICE_ID
+#define RADEON_PARAM_DEVICE_ID 16
+#endif
+
+#ifndef RADEON_INFO_DEVICE_ID
+#define RADEON_INFO_DEVICE_ID 0
+#endif
+#ifndef RADEON_INFO_NUM_GB_PIPES
+#define RADEON_INFO_NUM_GB_PIPES 0
+#endif
+
+#ifndef DRM_RADEON_INFO
+#define DRM_RADEON_INFO 0x1
+#endif
+
+#ifdef HAVE_LIBDRM_RADEON
+
+#include "radeon_bo.h"
+#include "radeon_bo_gem.h"
+#include "radeon_cs.h"
+#include "radeon_cs_gem.h"
+
+#else
+#include <stdint.h>
+
+#define RADEON_GEM_DOMAIN_CPU 0x1   // Cached CPU domain
+#define RADEON_GEM_DOMAIN_GTT 0x2   // GTT or cache flushed
+#define RADEON_GEM_DOMAIN_VRAM 0x4  // VRAM domain
+
+/* to be used to build locally in mesa with no libdrm bits */
+#include "../radeon/radeon_bo_drm.h"
+#include "../radeon/radeon_cs_drm.h"
+
+#ifndef DRM_RADEON_GEM_INFO
+#define DRM_RADEON_GEM_INFO 0x1c
+
+struct drm_radeon_gem_info {
+        uint64_t gart_size;
+        uint64_t vram_size;
+        uint64_t vram_visible;
+};
+
+struct drm_radeon_info {
+       uint32_t request;
+       uint32_t pad;
+       uint32_t value;
+};
+#endif
+
+
+static inline uint32_t radeon_gem_name_bo(struct radeon_bo *dummy)
+{
+  return 0;
+}
+
+static inline void *radeon_bo_manager_gem_ctor(int fd)
+{
+  return NULL;
+}
+
+static inline void radeon_bo_manager_gem_dtor(void *dummy)
+{
+}
+
+static inline void *radeon_cs_manager_gem_ctor(int fd)
+{
+  return NULL;
+}
+
+static inline void radeon_cs_manager_gem_dtor(void *dummy)
+{
+}
+
+static inline void radeon_tracker_print(void *ptr, int io)
+{
+}
+#endif
+
+#include "radeon_bo_legacy.h"
+#include "radeon_cs_legacy.h"
+
+#endif
diff --git a/src/mesa/drivers/dri/radeon/radeon_cmdbuf.h b/src/mesa/drivers/dri/radeon/radeon_cmdbuf.h
new file mode 100644 (file)
index 0000000..4b5116c
--- /dev/null
@@ -0,0 +1,143 @@
+#ifndef COMMON_CMDBUF_H
+#define COMMON_CMDBUF_H
+
+#include "radeon_bocs_wrapper.h"
+
+void rcommonEnsureCmdBufSpace(radeonContextPtr rmesa, int dwords, const char *caller);
+int rcommonFlushCmdBuf(radeonContextPtr rmesa, const char *caller);
+int rcommonFlushCmdBufLocked(radeonContextPtr rmesa, const char *caller);
+void rcommonInitCmdBuf(radeonContextPtr rmesa);
+void rcommonDestroyCmdBuf(radeonContextPtr rmesa);
+
+void rcommonBeginBatch(radeonContextPtr rmesa,
+                      int n,
+                      int dostate,
+                      const char *file,
+                      const char *function,
+                      int line);
+
+#define RADEON_CP_PACKET3_NOP                       0xC0001000
+#define RADEON_CP_PACKET3_NEXT_CHAR                 0xC0001900
+#define RADEON_CP_PACKET3_PLY_NEXTSCAN              0xC0001D00
+#define RADEON_CP_PACKET3_SET_SCISSORS              0xC0001E00
+#define RADEON_CP_PACKET3_3D_RNDR_GEN_INDX_PRIM     0xC0002300
+#define RADEON_CP_PACKET3_LOAD_MICROCODE            0xC0002400
+#define RADEON_CP_PACKET3_WAIT_FOR_IDLE             0xC0002600
+#define RADEON_CP_PACKET3_3D_DRAW_VBUF              0xC0002800
+#define RADEON_CP_PACKET3_3D_DRAW_IMMD              0xC0002900
+#define RADEON_CP_PACKET3_3D_DRAW_INDX              0xC0002A00
+#define RADEON_CP_PACKET3_LOAD_PALETTE              0xC0002C00
+#define RADEON_CP_PACKET3_3D_LOAD_VBPNTR            0xC0002F00
+#define RADEON_CP_PACKET3_CNTL_PAINT                0xC0009100
+#define RADEON_CP_PACKET3_CNTL_BITBLT               0xC0009200
+#define RADEON_CP_PACKET3_CNTL_SMALLTEXT            0xC0009300
+#define RADEON_CP_PACKET3_CNTL_HOSTDATA_BLT         0xC0009400
+#define RADEON_CP_PACKET3_CNTL_POLYLINE             0xC0009500
+#define RADEON_CP_PACKET3_CNTL_POLYSCANLINES        0xC0009800
+#define RADEON_CP_PACKET3_CNTL_PAINT_MULTI          0xC0009A00
+#define RADEON_CP_PACKET3_CNTL_BITBLT_MULTI         0xC0009B00
+#define RADEON_CP_PACKET3_CNTL_TRANS_BITBLT         0xC0009C00
+
+#define CP_PACKET2  (2 << 30)
+#define CP_PACKET0(reg, n)     (RADEON_CP_PACKET0 | ((n)<<16) | ((reg)>>2))
+#define CP_PACKET0_ONE(reg, n) (RADEON_CP_PACKET0 | RADEON_CP_PACKET0_ONE_REG_WR | ((n)<<16) | ((reg)>>2))
+#define CP_PACKET3( pkt, n )                                           \
+       (RADEON_CP_PACKET3 | (pkt) | ((n) << 16))
+
+/**
+ * Every function writing to the command buffer needs to declare this
+ * to get the necessary local variables.
+ */
+#define BATCH_LOCALS(rmesa) \
+       const radeonContextPtr b_l_rmesa = rmesa
+
+/**
+ * Prepare writing n dwords to the command buffer,
+ * including producing any necessary state emits on buffer wraparound.
+ */
+#define BEGIN_BATCH(n) rcommonBeginBatch(b_l_rmesa, n, 1, __FILE__, __FUNCTION__, __LINE__)
+
+/**
+ * Same as BEGIN_BATCH, but do not cause automatic state emits.
+ */
+#define BEGIN_BATCH_NO_AUTOSTATE(n) rcommonBeginBatch(b_l_rmesa, n, 0, __FILE__, __FUNCTION__, __LINE__)
+
+/**
+ * Write one dword to the command buffer.
+ */
+#define OUT_BATCH(data) \
+       do { \
+        radeon_cs_write_dword(b_l_rmesa->cmdbuf.cs, data);\
+       } while(0)
+
+/**
+ * Write a relocated dword to the command buffer.
+ */
+#define OUT_BATCH_RELOC(data, bo, offset, rd, wd, flags)       \
+       do {                                                    \
+        if (0 && offset) {                                     \
+            fprintf(stderr, "(%s:%s:%d) offset : %d\n",                \
+            __FILE__, __FUNCTION__, __LINE__, offset);         \
+        }                                                      \
+        radeon_cs_write_dword(b_l_rmesa->cmdbuf.cs, offset);   \
+        radeon_cs_write_reloc(b_l_rmesa->cmdbuf.cs,            \
+                              bo, rd, wd, flags);              \
+       if (!b_l_rmesa->radeonScreen->kernel_mm)                \
+               b_l_rmesa->cmdbuf.cs->section_cdw += 2;         \
+       } while(0)
+
+
+/**
+ * Write n dwords from ptr to the command buffer.
+ */
+#define OUT_BATCH_TABLE(ptr,n) \
+       do { \
+               int _i; \
+        for (_i=0; _i < n; _i++) {\
+            radeon_cs_write_dword(b_l_rmesa->cmdbuf.cs, ptr[_i]);\
+        }\
+       } while(0)
+
+/**
+ * Finish writing dwords to the command buffer.
+ * The number of (direct or indirect) OUT_BATCH calls between the previous
+ * BEGIN_BATCH and END_BATCH must match the number specified at BEGIN_BATCH time.
+ */
+#define END_BATCH() \
+       do { \
+        radeon_cs_end(b_l_rmesa->cmdbuf.cs, __FILE__, __FUNCTION__, __LINE__);\
+       } while(0)
+
+/**
+ * After the last END_BATCH() of rendering, this indicates that flushing
+ * the command buffer now is okay.
+ */
+#define COMMIT_BATCH() \
+       do { \
+       } while(0)
+
+
+/** Single register write to command buffer; requires 2 dwords. */
+#define OUT_BATCH_REGVAL(reg, val) \
+       OUT_BATCH(cmdpacket0(b_l_rmesa->radeonScreen, (reg), 1)); \
+       OUT_BATCH((val))
+
+/** Continuous register range write to command buffer; requires 1 dword,
+ * expects count dwords afterwards for register contents. */
+#define OUT_BATCH_REGSEQ(reg, count) \
+       OUT_BATCH(cmdpacket0(b_l_rmesa->radeonScreen, (reg), (count)));
+
+/** Write a 32 bit float to the ring; requires 1 dword. */
+#define OUT_BATCH_FLOAT32(f) \
+       OUT_BATCH(radeonPackFloat32((f)));
+
+
+/* Fire the buffered vertices no matter what.
+ */
+static INLINE void radeon_firevertices(radeonContextPtr radeon)
+{
+   if (radeon->cmdbuf.cs->cdw || radeon->dma.flush )
+      radeonFlush(radeon->glCtx);
+}
+
+#endif
diff --git a/src/mesa/drivers/dri/radeon/radeon_common.c b/src/mesa/drivers/dri/radeon/radeon_common.c
new file mode 100644 (file)
index 0000000..466eda7
--- /dev/null
@@ -0,0 +1,1495 @@
+/**************************************************************************
+
+Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial
+portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ *   Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+/*
+   - Scissor implementation
+   - buffer swap/copy ioctls
+   - finish/flush
+   - state emission
+   - cmdbuffer management
+*/
+
+#include <errno.h>
+#include "main/glheader.h"
+#include "main/imports.h"
+#include "main/context.h"
+#include "main/api_arrayelt.h"
+#include "main/enums.h"
+#include "main/colormac.h"
+#include "main/light.h"
+#include "main/framebuffer.h"
+#include "main/simple_list.h"
+#include "main/renderbuffer.h"
+#include "swrast/swrast.h"
+#include "vbo/vbo.h"
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+#include "swrast_setup/swrast_setup.h"
+
+#include "main/blend.h"
+#include "main/bufferobj.h"
+#include "main/buffers.h"
+#include "main/depth.h"
+#include "main/polygon.h"
+#include "main/shaders.h"
+#include "main/texstate.h"
+#include "main/varray.h"
+#include "glapi/dispatch.h"
+#include "swrast/swrast.h"
+#include "main/stencil.h"
+#include "main/matrix.h"
+#include "main/attrib.h"
+#include "main/enable.h"
+#include "main/viewport.h"
+
+#include "dri_util.h"
+#include "vblank.h"
+
+#include "radeon_common.h"
+#include "radeon_bocs_wrapper.h"
+#include "radeon_lock.h"
+#include "radeon_drm.h"
+#include "radeon_mipmap_tree.h"
+
+#define DEBUG_CMDBUF         0
+
+/* =============================================================
+ * Scissoring
+ */
+
+static GLboolean intersect_rect(drm_clip_rect_t * out,
+                               drm_clip_rect_t * a, drm_clip_rect_t * b)
+{
+       *out = *a;
+       if (b->x1 > out->x1)
+               out->x1 = b->x1;
+       if (b->y1 > out->y1)
+               out->y1 = b->y1;
+       if (b->x2 < out->x2)
+               out->x2 = b->x2;
+       if (b->y2 < out->y2)
+               out->y2 = b->y2;
+       if (out->x1 >= out->x2)
+               return GL_FALSE;
+       if (out->y1 >= out->y2)
+               return GL_FALSE;
+       return GL_TRUE;
+}
+
+void radeonRecalcScissorRects(radeonContextPtr radeon)
+{
+       drm_clip_rect_t *out;
+       int i;
+
+       /* Grow cliprect store?
+        */
+       if (radeon->state.scissor.numAllocedClipRects < radeon->numClipRects) {
+               while (radeon->state.scissor.numAllocedClipRects <
+                      radeon->numClipRects) {
+                       radeon->state.scissor.numAllocedClipRects += 1; /* zero case */
+                       radeon->state.scissor.numAllocedClipRects *= 2;
+               }
+
+               if (radeon->state.scissor.pClipRects)
+                       FREE(radeon->state.scissor.pClipRects);
+
+               radeon->state.scissor.pClipRects =
+                       MALLOC(radeon->state.scissor.numAllocedClipRects *
+                              sizeof(drm_clip_rect_t));
+
+               if (radeon->state.scissor.pClipRects == NULL) {
+                       radeon->state.scissor.numAllocedClipRects = 0;
+                       return;
+               }
+       }
+
+       out = radeon->state.scissor.pClipRects;
+       radeon->state.scissor.numClipRects = 0;
+
+       for (i = 0; i < radeon->numClipRects; i++) {
+               if (intersect_rect(out,
+                                  &radeon->pClipRects[i],
+                                  &radeon->state.scissor.rect)) {
+                       radeon->state.scissor.numClipRects++;
+                       out++;
+               }
+       }
+}
+
+void radeon_get_cliprects(radeonContextPtr radeon,
+                         struct drm_clip_rect **cliprects,
+                         unsigned int *num_cliprects,
+                         int *x_off, int *y_off)
+{
+       __DRIdrawablePrivate *dPriv = radeon_get_drawable(radeon);
+       struct radeon_framebuffer *rfb = dPriv->driverPrivate;
+
+       if (radeon->constant_cliprect) {
+               radeon->fboRect.x1 = 0;
+               radeon->fboRect.y1 = 0;
+               radeon->fboRect.x2 = radeon->glCtx->DrawBuffer->Width;
+               radeon->fboRect.y2 = radeon->glCtx->DrawBuffer->Height;
+
+               *cliprects = &radeon->fboRect;
+               *num_cliprects = 1;
+               *x_off = 0;
+               *y_off = 0;
+       } else if (radeon->front_cliprects ||
+                  rfb->pf_active || dPriv->numBackClipRects == 0) {
+               *cliprects = dPriv->pClipRects;
+               *num_cliprects = dPriv->numClipRects;
+               *x_off = dPriv->x;
+               *y_off = dPriv->y;
+       } else {
+               *num_cliprects = dPriv->numBackClipRects;
+               *cliprects = dPriv->pBackClipRects;
+               *x_off = dPriv->backX;
+               *y_off = dPriv->backY;
+       }
+}
+
+/**
+ * Update cliprects and scissors.
+ */
+void radeonSetCliprects(radeonContextPtr radeon)
+{
+       __DRIdrawablePrivate *const drawable = radeon_get_drawable(radeon);
+       __DRIdrawablePrivate *const readable = radeon_get_readable(radeon);
+       struct radeon_framebuffer *const draw_rfb = drawable->driverPrivate;
+       struct radeon_framebuffer *const read_rfb = readable->driverPrivate;
+       int x_off, y_off;
+
+       radeon_get_cliprects(radeon, &radeon->pClipRects,
+                            &radeon->numClipRects, &x_off, &y_off);
+
+       if ((draw_rfb->base.Width != drawable->w) ||
+           (draw_rfb->base.Height != drawable->h)) {
+               _mesa_resize_framebuffer(radeon->glCtx, &draw_rfb->base,
+                                        drawable->w, drawable->h);
+               draw_rfb->base.Initialized = GL_TRUE;
+       }
+
+       if (drawable != readable) {
+               if ((read_rfb->base.Width != readable->w) ||
+                   (read_rfb->base.Height != readable->h)) {
+                       _mesa_resize_framebuffer(radeon->glCtx, &read_rfb->base,
+                                                readable->w, readable->h);
+                       read_rfb->base.Initialized = GL_TRUE;
+               }
+       }
+
+       if (radeon->state.scissor.enabled)
+               radeonRecalcScissorRects(radeon);
+
+}
+
+
+
+void radeonUpdateScissor( GLcontext *ctx )
+{
+       radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+       if ( radeon_get_drawable(rmesa) ) {
+               __DRIdrawablePrivate *dPriv = radeon_get_drawable(rmesa);
+
+               int x = ctx->Scissor.X;
+               int y = dPriv->h - ctx->Scissor.Y - ctx->Scissor.Height;
+               int w = ctx->Scissor.X + ctx->Scissor.Width - 1;
+               int h = dPriv->h - ctx->Scissor.Y - 1;
+
+               rmesa->state.scissor.rect.x1 = x + dPriv->x;
+               rmesa->state.scissor.rect.y1 = y + dPriv->y;
+               rmesa->state.scissor.rect.x2 = w + dPriv->x + 1;
+               rmesa->state.scissor.rect.y2 = h + dPriv->y + 1;
+
+               radeonRecalcScissorRects( rmesa );
+       }
+}
+
+/* =============================================================
+ * Scissoring
+ */
+
+void radeonScissor(GLcontext* ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+       if (ctx->Scissor.Enabled) {
+               /* We don't pipeline cliprect changes */
+               radeon_firevertices(radeon);
+               radeonUpdateScissor(ctx);
+       }
+}
+
+
+/* ================================================================
+ * SwapBuffers with client-side throttling
+ */
+
+static uint32_t radeonGetLastFrame(radeonContextPtr radeon)
+{
+       drm_radeon_getparam_t gp;
+       int ret;
+       uint32_t frame = 0;
+
+       gp.param = RADEON_PARAM_LAST_FRAME;
+       gp.value = (int *)&frame;
+       ret = drmCommandWriteRead(radeon->dri.fd, DRM_RADEON_GETPARAM,
+                                 &gp, sizeof(gp));
+       if (ret) {
+               fprintf(stderr, "%s: drmRadeonGetParam: %d\n", __FUNCTION__,
+                       ret);
+               exit(1);
+       }
+
+       return frame;
+}
+
+uint32_t radeonGetAge(radeonContextPtr radeon)
+{
+       drm_radeon_getparam_t gp;
+       int ret;
+       uint32_t age;
+
+       gp.param = RADEON_PARAM_LAST_CLEAR;
+       gp.value = (int *)&age;
+       ret = drmCommandWriteRead(radeon->dri.fd, DRM_RADEON_GETPARAM,
+                                 &gp, sizeof(gp));
+       if (ret) {
+               fprintf(stderr, "%s: drmRadeonGetParam: %d\n", __FUNCTION__,
+                       ret);
+               exit(1);
+       }
+
+       return age;
+}
+
+static void radeonEmitIrqLocked(radeonContextPtr radeon)
+{
+       drm_radeon_irq_emit_t ie;
+       int ret;
+
+       ie.irq_seq = &radeon->iw.irq_seq;
+       ret = drmCommandWriteRead(radeon->dri.fd, DRM_RADEON_IRQ_EMIT,
+                                 &ie, sizeof(ie));
+       if (ret) {
+               fprintf(stderr, "%s: drmRadeonIrqEmit: %d\n", __FUNCTION__,
+                       ret);
+               exit(1);
+       }
+}
+
+static void radeonWaitIrq(radeonContextPtr radeon)
+{
+       int ret;
+
+       do {
+               ret = drmCommandWrite(radeon->dri.fd, DRM_RADEON_IRQ_WAIT,
+                                     &radeon->iw, sizeof(radeon->iw));
+       } while (ret && (errno == EINTR || errno == EBUSY));
+
+       if (ret) {
+               fprintf(stderr, "%s: drmRadeonIrqWait: %d\n", __FUNCTION__,
+                       ret);
+               exit(1);
+       }
+}
+
+static void radeonWaitForFrameCompletion(radeonContextPtr radeon)
+{
+       drm_radeon_sarea_t *sarea = radeon->sarea;
+
+       if (radeon->do_irqs) {
+               if (radeonGetLastFrame(radeon) < sarea->last_frame) {
+                       if (!radeon->irqsEmitted) {
+                               while (radeonGetLastFrame(radeon) <
+                                      sarea->last_frame) ;
+                       } else {
+                               UNLOCK_HARDWARE(radeon);
+                               radeonWaitIrq(radeon);
+                               LOCK_HARDWARE(radeon);
+                       }
+                       radeon->irqsEmitted = 10;
+               }
+
+               if (radeon->irqsEmitted) {
+                       radeonEmitIrqLocked(radeon);
+                       radeon->irqsEmitted--;
+               }
+       } else {
+               while (radeonGetLastFrame(radeon) < sarea->last_frame) {
+                       UNLOCK_HARDWARE(radeon);
+                       if (radeon->do_usleeps)
+                               DO_USLEEP(1);
+                       LOCK_HARDWARE(radeon);
+               }
+       }
+}
+
+/* wait for idle */
+void radeonWaitForIdleLocked(radeonContextPtr radeon)
+{
+       int ret;
+       int i = 0;
+
+       do {
+               ret = drmCommandNone(radeon->dri.fd, DRM_RADEON_CP_IDLE);
+               if (ret)
+                       DO_USLEEP(1);
+       } while (ret && ++i < 100);
+
+       if (ret < 0) {
+               UNLOCK_HARDWARE(radeon);
+               fprintf(stderr, "Error: R300 timed out... exiting\n");
+               exit(-1);
+       }
+}
+
+static void radeonWaitForIdle(radeonContextPtr radeon)
+{
+       if (!radeon->radeonScreen->driScreen->dri2.enabled) {
+        LOCK_HARDWARE(radeon);
+           radeonWaitForIdleLocked(radeon);
+           UNLOCK_HARDWARE(radeon);
+    }
+}
+
+static void radeon_flip_renderbuffers(struct radeon_framebuffer *rfb)
+{
+       int current_page = rfb->pf_current_page;
+       int next_page = (current_page + 1) % rfb->pf_num_pages;
+       struct gl_renderbuffer *tmp_rb;
+
+       /* Exchange renderbuffers if necessary but make sure their
+        * reference counts are preserved.
+        */
+       if (rfb->color_rb[current_page] &&
+           rfb->base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer !=
+           &rfb->color_rb[current_page]->base) {
+               tmp_rb = NULL;
+               _mesa_reference_renderbuffer(&tmp_rb,
+                                            rfb->base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+               tmp_rb = &rfb->color_rb[current_page]->base;
+               _mesa_reference_renderbuffer(&rfb->base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer, tmp_rb);
+               _mesa_reference_renderbuffer(&tmp_rb, NULL);
+       }
+
+       if (rfb->color_rb[next_page] &&
+           rfb->base.Attachment[BUFFER_BACK_LEFT].Renderbuffer !=
+           &rfb->color_rb[next_page]->base) {
+               tmp_rb = NULL;
+               _mesa_reference_renderbuffer(&tmp_rb,
+                                            rfb->base.Attachment[BUFFER_BACK_LEFT].Renderbuffer);
+               tmp_rb = &rfb->color_rb[next_page]->base;
+               _mesa_reference_renderbuffer(&rfb->base.Attachment[BUFFER_BACK_LEFT].Renderbuffer, tmp_rb);
+               _mesa_reference_renderbuffer(&tmp_rb, NULL);
+       }
+}
+
+/* Copy the back color buffer to the front color buffer.
+ */
+void radeonCopyBuffer( __DRIdrawablePrivate *dPriv,
+                      const drm_clip_rect_t      *rect)
+{
+       radeonContextPtr rmesa;
+       struct radeon_framebuffer *rfb;
+       GLint nbox, i, ret;
+
+       assert(dPriv);
+       assert(dPriv->driContextPriv);
+       assert(dPriv->driContextPriv->driverPrivate);
+
+       rmesa = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
+
+       LOCK_HARDWARE(rmesa);
+
+       rfb = dPriv->driverPrivate;
+
+       if ( RADEON_DEBUG & DEBUG_IOCTL ) {
+               fprintf( stderr, "\n%s( %p )\n\n", __FUNCTION__, (void *) rmesa->glCtx );
+       }
+
+       nbox = dPriv->numClipRects; /* must be in locked region */
+
+       for ( i = 0 ; i < nbox ; ) {
+               GLint nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS , nbox );
+               drm_clip_rect_t *box = dPriv->pClipRects;
+               drm_clip_rect_t *b = rmesa->sarea->boxes;
+               GLint n = 0;
+
+               for ( ; i < nr ; i++ ) {
+
+                       *b = box[i];
+
+                       if (rect)
+                       {
+                               if (rect->x1 > b->x1)
+                                       b->x1 = rect->x1;
+                               if (rect->y1 > b->y1)
+                                       b->y1 = rect->y1;
+                               if (rect->x2 < b->x2)
+                                       b->x2 = rect->x2;
+                               if (rect->y2 < b->y2)
+                                       b->y2 = rect->y2;
+
+                               if (b->x1 >= b->x2 || b->y1 >= b->y2)
+                                       continue;
+                       }
+
+                       b++;
+                       n++;
+               }
+               rmesa->sarea->nbox = n;
+
+               if (!n)
+                       continue;
+
+               ret = drmCommandNone( rmesa->dri.fd, DRM_RADEON_SWAP );
+
+               if ( ret ) {
+                       fprintf( stderr, "DRM_RADEON_SWAP_BUFFERS: return = %d\n", ret );
+                       UNLOCK_HARDWARE( rmesa );
+                       exit( 1 );
+               }
+       }
+
+       UNLOCK_HARDWARE( rmesa );
+}
+
+static int radeonScheduleSwap(__DRIdrawablePrivate *dPriv, GLboolean *missed_target)
+{
+       radeonContextPtr rmesa;
+
+       rmesa = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
+       radeon_firevertices(rmesa);
+
+       LOCK_HARDWARE( rmesa );
+
+       if (!dPriv->numClipRects) {
+               UNLOCK_HARDWARE(rmesa);
+               usleep(10000);  /* throttle invisible client 10ms */
+               return 0;
+       }
+
+       radeonWaitForFrameCompletion(rmesa);
+
+       UNLOCK_HARDWARE(rmesa);
+       driWaitForVBlank(dPriv, missed_target);
+
+       return 0;
+}
+
+static GLboolean radeonPageFlip( __DRIdrawablePrivate *dPriv )
+{
+       radeonContextPtr radeon;
+       GLint ret;
+       __DRIscreenPrivate *psp;
+       struct radeon_renderbuffer *rrb;
+       struct radeon_framebuffer *rfb;
+
+       assert(dPriv);
+       assert(dPriv->driContextPriv);
+       assert(dPriv->driContextPriv->driverPrivate);
+
+       radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
+       rfb = dPriv->driverPrivate;
+       rrb = (void *)rfb->base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
+
+       psp = dPriv->driScreenPriv;
+
+       LOCK_HARDWARE(radeon);
+
+       if ( RADEON_DEBUG & DEBUG_IOCTL ) {
+               fprintf(stderr, "%s: pfCurrentPage: %d %d\n", __FUNCTION__,
+                       radeon->sarea->pfCurrentPage, radeon->sarea->pfState);
+       }
+       drm_clip_rect_t *box = dPriv->pClipRects;
+       drm_clip_rect_t *b = radeon->sarea->boxes;
+       b[0] = box[0];
+       radeon->sarea->nbox = 1;
+
+       ret = drmCommandNone( radeon->dri.fd, DRM_RADEON_FLIP );
+
+       UNLOCK_HARDWARE(radeon);
+
+       if ( ret ) {
+               fprintf( stderr, "DRM_RADEON_FLIP: return = %d\n", ret );
+               return GL_FALSE;
+       }
+
+       if (!rfb->pf_active)
+               return GL_FALSE;
+
+       rfb->pf_current_page = radeon->sarea->pfCurrentPage;
+       radeon_flip_renderbuffers(rfb);
+       radeon_draw_buffer(radeon->glCtx, &rfb->base);
+
+       return GL_TRUE;
+}
+
+
+/**
+ * Swap front and back buffer.
+ */
+void radeonSwapBuffers(__DRIdrawablePrivate * dPriv)
+{
+       int64_t ust;
+       __DRIscreenPrivate *psp;
+
+       if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+               radeonContextPtr radeon;
+               GLcontext *ctx;
+
+               radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
+               ctx = radeon->glCtx;
+
+               if (ctx->Visual.doubleBufferMode) {
+                       GLboolean missed_target;
+                       struct radeon_framebuffer *rfb = dPriv->driverPrivate;
+                       _mesa_notifySwapBuffers(ctx);/* flush pending rendering comands */
+
+                       radeonScheduleSwap(dPriv, &missed_target);
+
+                       if (rfb->pf_active) {
+                               radeonPageFlip(dPriv);
+                       } else {
+                               radeonCopyBuffer(dPriv, NULL);
+                       }
+
+                       psp = dPriv->driScreenPriv;
+
+                       rfb->swap_count++;
+                       (*psp->systemTime->getUST)( & ust );
+                       if ( missed_target ) {
+                               rfb->swap_missed_count++;
+                               rfb->swap_missed_ust = ust - rfb->swap_ust;
+                       }
+
+                       rfb->swap_ust = ust;
+                       radeon->hw.all_dirty = GL_TRUE;
+               }
+       } else {
+               /* XXX this shouldn't be an error but we can't handle it for now */
+               _mesa_problem(NULL, "%s: drawable has no context!",
+                             __FUNCTION__);
+       }
+}
+
+void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
+                        int x, int y, int w, int h )
+{
+       if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+               radeonContextPtr radeon;
+               GLcontext *ctx;
+
+               radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
+               ctx = radeon->glCtx;
+
+               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 */
+                       radeonCopyBuffer(dPriv, &rect);
+               }
+       } else {
+               /* XXX this shouldn't be an error but we can't handle it for now */
+               _mesa_problem(NULL, "%s: drawable has no context!",
+                             __FUNCTION__);
+       }
+}
+
+void radeon_draw_buffer(GLcontext *ctx, struct gl_framebuffer *fb)
+{
+       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+       struct radeon_renderbuffer *rrbDepth = NULL, *rrbStencil = NULL,
+               *rrbColor = NULL;
+       uint32_t offset = 0;
+
+
+       if (!fb) {
+               /* this can happen during the initial context initialization */
+               return;
+       }
+
+       /* radeons only handle 1 color draw so far */
+       if (fb->_NumColorDrawBuffers != 1) {
+               radeon->vtbl.fallback(ctx, RADEON_FALLBACK_DRAW_BUFFER, GL_TRUE);
+               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)
+               ;/* do something depthy/stencily TODO */
+
+
+               /* none */
+       if (fb->Name == 0) {
+               if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
+                       rrbColor = radeon_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+                       radeon->front_cliprects = GL_TRUE;
+                       radeon->front_buffer_dirty = GL_TRUE;
+               } else {
+                       rrbColor = radeon_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer);
+                       radeon->front_cliprects = GL_FALSE;
+               }
+       } else {
+               /* user FBO in theory */
+               struct radeon_renderbuffer *rrb;
+               rrb = radeon_renderbuffer(fb->_ColorDrawBuffers[0]);
+               if (rrb) {
+                       offset = rrb->draw_offset;
+                       rrbColor = rrb;
+               }
+               radeon->constant_cliprect = GL_TRUE;
+       }
+
+       if (rrbColor == NULL)
+               radeon->vtbl.fallback(ctx, RADEON_FALLBACK_DRAW_BUFFER, GL_TRUE);
+       else
+               radeon->vtbl.fallback(ctx, RADEON_FALLBACK_DRAW_BUFFER, GL_FALSE);
+
+
+       if (fb->_DepthBuffer && fb->_DepthBuffer->Wrapped) {
+               rrbDepth = radeon_renderbuffer(fb->_DepthBuffer->Wrapped);
+               if (rrbDepth && rrbDepth->bo) {
+                       radeon->vtbl.fallback(ctx, RADEON_FALLBACK_DEPTH_BUFFER, GL_FALSE);
+               } else {
+                       radeon->vtbl.fallback(ctx, RADEON_FALLBACK_DEPTH_BUFFER, GL_TRUE);
+               }
+       } else {
+               radeon->vtbl.fallback(ctx, RADEON_FALLBACK_DEPTH_BUFFER, GL_FALSE);
+               rrbDepth = NULL;
+       }
+
+       if (fb->_StencilBuffer && fb->_StencilBuffer->Wrapped) {
+               rrbStencil = radeon_renderbuffer(fb->_DepthBuffer->Wrapped);
+               if (rrbStencil && rrbStencil->bo) {
+                       radeon->vtbl.fallback(ctx, RADEON_FALLBACK_STENCIL_BUFFER, GL_FALSE);
+                       /* need to re-compute stencil hw state */
+                       if (!rrbDepth)
+                               rrbDepth = rrbStencil;
+               } else {
+                       radeon->vtbl.fallback(ctx, RADEON_FALLBACK_STENCIL_BUFFER, GL_TRUE);
+               }
+       } else {
+               radeon->vtbl.fallback(ctx, RADEON_FALLBACK_STENCIL_BUFFER, GL_FALSE);
+               if (ctx->Driver.Enable != NULL)
+                       ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled);
+               else
+                       ctx->NewState |= _NEW_STENCIL;
+       }
+
+       /* 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;
+
+       /*
+        * Update depth test state
+        */
+       if (ctx->Driver.Enable) {
+               ctx->Driver.Enable(ctx, GL_DEPTH_TEST,
+                                  (ctx->Depth.Test && fb->Visual.depthBits > 0));
+               /* Need to update the derived ctx->Stencil._Enabled first */
+               _mesa_update_stencil(ctx);
+               ctx->Driver.Enable(ctx, GL_STENCIL_TEST,
+                                  (ctx->Stencil._Enabled && fb->Visual.stencilBits > 0));
+       } else {
+               ctx->NewState |= (_NEW_DEPTH | _NEW_STENCIL);
+       }
+
+       _mesa_reference_renderbuffer(&radeon->state.depth.rb, &rrbDepth->base);
+       _mesa_reference_renderbuffer(&radeon->state.color.rb, &rrbColor->base);
+       radeon->state.color.draw_offset = offset;
+
+#if 0
+       /* 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 {
+
+       }
+#endif
+       ctx->NewState |= _NEW_VIEWPORT;
+
+       /* Set state we know depends on drawable parameters:
+        */
+       radeonUpdateScissor(ctx);
+       radeon->NewGLState |= _NEW_SCISSOR;
+
+       if (ctx->Driver.DepthRange)
+               ctx->Driver.DepthRange(ctx,
+                                      ctx->Viewport.Near,
+                                      ctx->Viewport.Far);
+
+       /* 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;
+}
+
+/**
+ * Called via glDrawBuffer.
+ */
+void radeonDrawBuffer( GLcontext *ctx, GLenum mode )
+{
+       if (RADEON_DEBUG & DEBUG_DRI)
+               fprintf(stderr, "%s %s\n", __FUNCTION__,
+                       _mesa_lookup_enum_by_nr( mode ));
+
+       if (ctx->DrawBuffer->Name == 0) {
+               radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+
+               const GLboolean was_front_buffer_rendering =
+                       radeon->is_front_buffer_rendering;
+
+               radeon->is_front_buffer_rendering = (mode == GL_FRONT_LEFT) ||
+                                            (mode == GL_FRONT);
+
+      /* If we weren't front-buffer rendering before but we are now, make sure
+       * that the front-buffer has actually been allocated.
+       */
+               if (!was_front_buffer_rendering && radeon->is_front_buffer_rendering) {
+                       radeon_update_renderbuffers(radeon->dri.context,
+                               radeon->dri.context->driDrawablePriv);
+      }
+       }
+
+       radeon_draw_buffer(ctx, ctx->DrawBuffer);
+}
+
+void radeonReadBuffer( GLcontext *ctx, GLenum mode )
+{
+       /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
+       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.
+                */
+               radeon_draw_buffer(ctx, ctx->DrawBuffer);
+       }
+}
+
+
+/* Turn on/off page flipping according to the flags in the sarea:
+ */
+void radeonUpdatePageFlipping(radeonContextPtr radeon)
+{
+       struct radeon_framebuffer *rfb = radeon_get_drawable(radeon)->driverPrivate;
+
+       rfb->pf_active = radeon->sarea->pfState;
+       rfb->pf_current_page = radeon->sarea->pfCurrentPage;
+       rfb->pf_num_pages = 2;
+       radeon_flip_renderbuffers(rfb);
+       radeon_draw_buffer(radeon->glCtx, radeon->glCtx->DrawBuffer);
+}
+
+void radeon_window_moved(radeonContextPtr radeon)
+{
+       if (!radeon->radeonScreen->driScreen->dri2.enabled) {
+               radeonUpdatePageFlipping(radeon);
+       }
+       radeonSetCliprects(radeon);
+}
+
+void radeon_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+       __DRIcontext *driContext = radeon->dri.context;
+       void (*old_viewport)(GLcontext *ctx, GLint x, GLint y,
+                            GLsizei w, GLsizei h);
+
+       if (!driContext->driScreenPriv->dri2.enabled)
+               return;
+
+       radeon_update_renderbuffers(driContext, driContext->driDrawablePriv);
+       if (driContext->driDrawablePriv != driContext->driReadablePriv)
+               radeon_update_renderbuffers(driContext, driContext->driReadablePriv);
+
+       old_viewport = ctx->Driver.Viewport;
+       ctx->Driver.Viewport = NULL;
+       radeon_window_moved(radeon);
+       radeon_draw_buffer(ctx, radeon->glCtx->DrawBuffer);
+       ctx->Driver.Viewport = old_viewport;
+}
+
+static void radeon_print_state_atom(radeonContextPtr radeon, struct radeon_state_atom *state)
+{
+       int i, j, reg;
+       int dwords = (*state->check) (radeon->glCtx, state);
+       drm_r300_cmd_header_t cmd;
+
+       fprintf(stderr, "  emit %s %d/%d\n", state->name, dwords, state->cmd_size);
+
+       if (RADEON_DEBUG & DEBUG_VERBOSE) {
+               for (i = 0; i < dwords;) {
+                       cmd = *((drm_r300_cmd_header_t *) &state->cmd[i]);
+                       reg = (cmd.packet0.reghi << 8) | cmd.packet0.reglo;
+                       fprintf(stderr, "      %s[%d]: cmdpacket0 (first reg=0x%04x, count=%d)\n",
+                                       state->name, i, reg, cmd.packet0.count);
+                       ++i;
+                       for (j = 0; j < cmd.packet0.count && i < dwords; j++) {
+                               fprintf(stderr, "      %s[%d]: 0x%04x = %08x\n",
+                                               state->name, i, reg, state->cmd[i]);
+                               reg += 4;
+                               ++i;
+                       }
+               }
+       }
+}
+
+static void radeon_print_state_atom_kmm(radeonContextPtr radeon, struct radeon_state_atom *state)
+{
+       int i, j, reg, count;
+       int dwords = (*state->check) (radeon->glCtx, state);
+       uint32_t packet0;
+
+       fprintf(stderr, "  emit %s %d/%d\n", state->name, dwords, state->cmd_size);
+
+       if (RADEON_DEBUG & DEBUG_VERBOSE) {
+               for (i = 0; i < dwords;) {
+                       packet0 = state->cmd[i];
+                       reg = (packet0 & 0x1FFF) << 2;
+                       count = ((packet0 & 0x3FFF0000) >> 16) + 1;
+                       fprintf(stderr, "      %s[%d]: cmdpacket0 (first reg=0x%04x, count=%d)\n",
+                                       state->name, i, reg, count);
+                       ++i;
+                       for (j = 0; j < count && i < dwords; j++) {
+                               fprintf(stderr, "      %s[%d]: 0x%04x = %08x\n",
+                                               state->name, i, reg, state->cmd[i]);
+                               reg += 4;
+                               ++i;
+                       }
+               }
+       }
+}
+
+static INLINE void radeonEmitAtoms(radeonContextPtr radeon, GLboolean dirty)
+{
+       BATCH_LOCALS(radeon);
+       struct radeon_state_atom *atom;
+       int dwords;
+
+       if (radeon->vtbl.pre_emit_atoms)
+               radeon->vtbl.pre_emit_atoms(radeon);
+
+       /* Emit actual atoms */
+       foreach(atom, &radeon->hw.atomlist) {
+               if ((atom->dirty || radeon->hw.all_dirty) == dirty) {
+                       dwords = (*atom->check) (radeon->glCtx, atom);
+                       if (dwords) {
+                               if (DEBUG_CMDBUF && RADEON_DEBUG & DEBUG_STATE) {
+                                       if (radeon->radeonScreen->kernel_mm)
+                                               radeon_print_state_atom_kmm(radeon, atom);
+                                       else
+                                               radeon_print_state_atom(radeon, atom);
+                               }
+                               if (atom->emit) {
+                                       (*atom->emit)(radeon->glCtx, atom);
+                               } else {
+                                       BEGIN_BATCH_NO_AUTOSTATE(dwords);
+                                       OUT_BATCH_TABLE(atom->cmd, dwords);
+                                       END_BATCH();
+                               }
+                               atom->dirty = GL_FALSE;
+                       } else {
+                               if (DEBUG_CMDBUF && RADEON_DEBUG & DEBUG_STATE) {
+                                       fprintf(stderr, "  skip state %s\n",
+                                               atom->name);
+                               }
+                       }
+               }
+       }
+
+       COMMIT_BATCH();
+}
+
+GLboolean radeon_revalidate_bos(GLcontext *ctx)
+{
+       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+       int flushed = 0;
+       int ret;
+again:
+       ret = radeon_cs_space_check(radeon->cmdbuf.cs, radeon->state.bos, radeon->state.validated_bo_count);
+       if (ret == RADEON_CS_SPACE_OP_TO_BIG)
+               return GL_FALSE;
+       if (ret == RADEON_CS_SPACE_FLUSH) {
+               radeonFlush(ctx);
+               if (flushed)
+                       return GL_FALSE;
+               flushed = 1;
+               goto again;
+       }
+       return GL_TRUE;
+}
+
+void radeon_validate_reset_bos(radeonContextPtr radeon)
+{
+       int i;
+
+       for (i = 0; i < radeon->state.validated_bo_count; i++) {
+               radeon_bo_unref(radeon->state.bos[i].bo);
+               radeon->state.bos[i].bo = NULL;
+               radeon->state.bos[i].read_domains = 0;
+               radeon->state.bos[i].write_domain = 0;
+               radeon->state.bos[i].new_accounted = 0;
+       }
+       radeon->state.validated_bo_count = 0;
+}
+
+void radeon_validate_bo(radeonContextPtr radeon, struct radeon_bo *bo, uint32_t read_domains, uint32_t write_domain)
+{
+       radeon_bo_ref(bo);
+       radeon->state.bos[radeon->state.validated_bo_count].bo = bo;
+       radeon->state.bos[radeon->state.validated_bo_count].read_domains = read_domains;
+       radeon->state.bos[radeon->state.validated_bo_count].write_domain = write_domain;
+       radeon->state.bos[radeon->state.validated_bo_count].new_accounted = 0;
+       radeon->state.validated_bo_count++;
+
+       assert(radeon->state.validated_bo_count < RADEON_MAX_BOS);
+}
+
+void radeonEmitState(radeonContextPtr radeon)
+{
+       if (RADEON_DEBUG & (DEBUG_STATE|DEBUG_PRIMS))
+               fprintf(stderr, "%s\n", __FUNCTION__);
+
+       if (radeon->vtbl.pre_emit_state)
+               radeon->vtbl.pre_emit_state(radeon);
+
+       /* this code used to return here but now it emits zbs */
+       if (radeon->cmdbuf.cs->cdw && !radeon->hw.is_dirty && !radeon->hw.all_dirty)
+               return;
+
+       /* To avoid going across the entire set of states multiple times, just check
+        * for enough space for the case of emitting all state, and inline the
+        * radeonAllocCmdBuf code here without all the checks.
+        */
+       rcommonEnsureCmdBufSpace(radeon, radeon->hw.max_state_size, __FUNCTION__);
+
+       if (!radeon->cmdbuf.cs->cdw) {
+               if (RADEON_DEBUG & DEBUG_STATE)
+                       fprintf(stderr, "Begin reemit state\n");
+
+               radeonEmitAtoms(radeon, GL_FALSE);
+       }
+
+       if (RADEON_DEBUG & DEBUG_STATE)
+               fprintf(stderr, "Begin dirty state\n");
+
+       radeonEmitAtoms(radeon, GL_TRUE);
+       radeon->hw.is_dirty = GL_FALSE;
+       radeon->hw.all_dirty = GL_FALSE;
+
+}
+
+
+void radeonFlush(GLcontext *ctx)
+{
+       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+       if (RADEON_DEBUG & DEBUG_IOCTL)
+               fprintf(stderr, "%s %d\n", __FUNCTION__, radeon->cmdbuf.cs->cdw);
+
+       /* okay if we have no cmds in the buffer &&
+          we have no DMA flush &&
+          we have no DMA buffer allocated.
+          then no point flushing anything at all.
+       */
+       if (!radeon->dma.flush && !radeon->cmdbuf.cs->cdw && !radeon->dma.current)
+               return;
+
+       if (radeon->dma.flush)
+               radeon->dma.flush( ctx );
+
+       radeonEmitState(radeon);
+
+       if (radeon->cmdbuf.cs->cdw)
+               rcommonFlushCmdBuf(radeon, __FUNCTION__);
+
+       if ((ctx->DrawBuffer->Name == 0) && radeon->front_buffer_dirty) {
+               __DRIscreen *const screen = radeon->radeonScreen->driScreen;
+
+               if (screen->dri2.loader && (screen->dri2.loader->base.version >= 2)
+                       && (screen->dri2.loader->flushFrontBuffer != NULL)) {
+                       __DRIdrawablePrivate * drawable = radeon_get_drawable(radeon);
+                       (*screen->dri2.loader->flushFrontBuffer)(drawable, drawable->loaderPrivate);
+
+                       /* Only clear the dirty bit if front-buffer rendering is no longer
+                        * enabled.  This is done so that the dirty bit can only be set in
+                        * glDrawBuffer.  Otherwise the dirty bit would have to be set at
+                        * each of N places that do rendering.  This has worse performances,
+                        * but it is much easier to get correct.
+                        */
+                       if (radeon->is_front_buffer_rendering) {
+                               radeon->front_buffer_dirty = GL_FALSE;
+                       }
+               }
+       }
+}
+
+/* Make sure all commands have been sent to the hardware and have
+ * completed processing.
+ */
+void radeonFinish(GLcontext * ctx)
+{
+       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+       struct gl_framebuffer *fb = ctx->DrawBuffer;
+       int i;
+
+       radeonFlush(ctx);
+
+       if (radeon->radeonScreen->kernel_mm) {
+               for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
+                       struct radeon_renderbuffer *rrb;
+                       rrb = radeon_renderbuffer(fb->_ColorDrawBuffers[i]);
+                       if (rrb && rrb->bo)
+                               radeon_bo_wait(rrb->bo);
+               }
+               {
+                       struct radeon_renderbuffer *rrb;
+                       rrb = radeon_get_depthbuffer(radeon);
+                       if (rrb && rrb->bo)
+                               radeon_bo_wait(rrb->bo);
+               }
+       } else if (radeon->do_irqs) {
+               LOCK_HARDWARE(radeon);
+               radeonEmitIrqLocked(radeon);
+               UNLOCK_HARDWARE(radeon);
+               radeonWaitIrq(radeon);
+       } else {
+               radeonWaitForIdle(radeon);
+       }
+}
+
+/* cmdbuffer */
+/**
+ * Send the current command buffer via ioctl to the hardware.
+ */
+int rcommonFlushCmdBufLocked(radeonContextPtr rmesa, const char *caller)
+{
+       int ret = 0;
+
+       if (rmesa->cmdbuf.flushing) {
+               fprintf(stderr, "Recursive call into r300FlushCmdBufLocked!\n");
+               exit(-1);
+       }
+       rmesa->cmdbuf.flushing = 1;
+
+       if (RADEON_DEBUG & DEBUG_IOCTL) {
+               fprintf(stderr, "%s from %s - %i cliprects\n",
+                       __FUNCTION__, caller, rmesa->numClipRects);
+       }
+
+       if (rmesa->cmdbuf.cs->cdw) {
+               ret = radeon_cs_emit(rmesa->cmdbuf.cs);
+               rmesa->hw.all_dirty = GL_TRUE;
+       }
+       radeon_cs_erase(rmesa->cmdbuf.cs);
+       rmesa->cmdbuf.flushing = 0;
+
+       if (radeon_revalidate_bos(rmesa->glCtx) == GL_FALSE) {
+               fprintf(stderr,"failed to revalidate buffers\n");
+       }
+
+       return ret;
+}
+
+int rcommonFlushCmdBuf(radeonContextPtr rmesa, const char *caller)
+{
+       int ret;
+
+       radeonReleaseDmaRegion(rmesa);
+
+       LOCK_HARDWARE(rmesa);
+       ret = rcommonFlushCmdBufLocked(rmesa, caller);
+       UNLOCK_HARDWARE(rmesa);
+
+       if (ret) {
+               fprintf(stderr, "drmRadeonCmdBuffer: %d\n", ret);
+               _mesa_exit(ret);
+       }
+
+       return ret;
+}
+
+/**
+ * Make sure that enough space is available in the command buffer
+ * by flushing if necessary.
+ *
+ * \param dwords The number of dwords we need to be free on the command buffer
+ */
+void rcommonEnsureCmdBufSpace(radeonContextPtr rmesa, int dwords, const char *caller)
+{
+       if ((rmesa->cmdbuf.cs->cdw + dwords + 128) > rmesa->cmdbuf.size ||
+           radeon_cs_need_flush(rmesa->cmdbuf.cs)) {
+               rcommonFlushCmdBuf(rmesa, caller);
+       }
+}
+
+void rcommonInitCmdBuf(radeonContextPtr rmesa)
+{
+       GLuint size;
+       /* Initialize command buffer */
+       size = 256 * driQueryOptioni(&rmesa->optionCache,
+                                    "command_buffer_size");
+       if (size < 2 * rmesa->hw.max_state_size) {
+               size = 2 * rmesa->hw.max_state_size + 65535;
+       }
+       if (size > 64 * 256)
+               size = 64 * 256;
+
+       if (RADEON_DEBUG & (DEBUG_IOCTL | DEBUG_DMA)) {
+               fprintf(stderr, "sizeof(drm_r300_cmd_header_t)=%zd\n",
+                       sizeof(drm_r300_cmd_header_t));
+               fprintf(stderr, "sizeof(drm_radeon_cmd_buffer_t)=%zd\n",
+                       sizeof(drm_radeon_cmd_buffer_t));
+               fprintf(stderr,
+                       "Allocating %d bytes command buffer (max state is %d bytes)\n",
+                       size * 4, rmesa->hw.max_state_size * 4);
+       }
+
+       if (rmesa->radeonScreen->kernel_mm) {
+               int fd = rmesa->radeonScreen->driScreen->fd;
+               rmesa->cmdbuf.csm = radeon_cs_manager_gem_ctor(fd);
+       } else {
+               rmesa->cmdbuf.csm = radeon_cs_manager_legacy_ctor(rmesa);
+       }
+       if (rmesa->cmdbuf.csm == NULL) {
+               /* FIXME: fatal error */
+               return;
+       }
+       rmesa->cmdbuf.cs = radeon_cs_create(rmesa->cmdbuf.csm, size);
+       assert(rmesa->cmdbuf.cs != NULL);
+       rmesa->cmdbuf.size = size;
+
+       if (!rmesa->radeonScreen->kernel_mm) {
+               radeon_cs_set_limit(rmesa->cmdbuf.cs, RADEON_GEM_DOMAIN_VRAM, rmesa->radeonScreen->texSize[0]);
+               radeon_cs_set_limit(rmesa->cmdbuf.cs, RADEON_GEM_DOMAIN_GTT, rmesa->radeonScreen->gartTextures.size);
+       } else {
+               struct drm_radeon_gem_info mminfo = { 0 };
+
+               if (!drmCommandWriteRead(rmesa->dri.fd, DRM_RADEON_GEM_INFO, &mminfo, sizeof(mminfo)))
+               {
+                       radeon_cs_set_limit(rmesa->cmdbuf.cs, RADEON_GEM_DOMAIN_VRAM, mminfo.vram_visible);
+                       radeon_cs_set_limit(rmesa->cmdbuf.cs, RADEON_GEM_DOMAIN_GTT, mminfo.gart_size);
+               }
+       }
+
+}
+/**
+ * Destroy the command buffer
+ */
+void rcommonDestroyCmdBuf(radeonContextPtr rmesa)
+{
+       radeon_cs_destroy(rmesa->cmdbuf.cs);
+       if (rmesa->radeonScreen->driScreen->dri2.enabled || rmesa->radeonScreen->kernel_mm) {
+               radeon_cs_manager_gem_dtor(rmesa->cmdbuf.csm);
+       } else {
+               radeon_cs_manager_legacy_dtor(rmesa->cmdbuf.csm);
+       }
+}
+
+void rcommonBeginBatch(radeonContextPtr rmesa, int n,
+                      int dostate,
+                      const char *file,
+                      const char *function,
+                      int line)
+{
+       rcommonEnsureCmdBufSpace(rmesa, n, function);
+       if (!rmesa->cmdbuf.cs->cdw && dostate) {
+               if (RADEON_DEBUG & DEBUG_IOCTL)
+                       fprintf(stderr, "Reemit state after flush (from %s)\n", function);
+               radeonEmitState(rmesa);
+       }
+       radeon_cs_begin(rmesa->cmdbuf.cs, n, file, function, line);
+
+        if (DEBUG_CMDBUF && RADEON_DEBUG & DEBUG_IOCTL)
+                fprintf(stderr, "BEGIN_BATCH(%d) at %d, from %s:%i\n",
+                        n, rmesa->cmdbuf.cs->cdw, function, line);
+
+}
+
+
+
+static void
+radeon_meta_set_passthrough_transform(radeonContextPtr radeon)
+{
+   GLcontext *ctx = radeon->glCtx;
+
+   radeon->meta.saved_vp_x = ctx->Viewport.X;
+   radeon->meta.saved_vp_y = ctx->Viewport.Y;
+   radeon->meta.saved_vp_width = ctx->Viewport.Width;
+   radeon->meta.saved_vp_height = ctx->Viewport.Height;
+   radeon->meta.saved_matrix_mode = ctx->Transform.MatrixMode;
+
+   _mesa_Viewport(0, 0, ctx->DrawBuffer->Width, ctx->DrawBuffer->Height);
+
+   _mesa_MatrixMode(GL_PROJECTION);
+   _mesa_PushMatrix();
+   _mesa_LoadIdentity();
+   _mesa_Ortho(0, ctx->DrawBuffer->Width, 0, ctx->DrawBuffer->Height, 1, -1);
+
+   _mesa_MatrixMode(GL_MODELVIEW);
+   _mesa_PushMatrix();
+   _mesa_LoadIdentity();
+}
+
+static void
+radeon_meta_restore_transform(radeonContextPtr radeon)
+{
+   _mesa_MatrixMode(GL_PROJECTION);
+   _mesa_PopMatrix();
+   _mesa_MatrixMode(GL_MODELVIEW);
+   _mesa_PopMatrix();
+
+   _mesa_MatrixMode(radeon->meta.saved_matrix_mode);
+
+   _mesa_Viewport(radeon->meta.saved_vp_x, radeon->meta.saved_vp_y,
+                 radeon->meta.saved_vp_width, radeon->meta.saved_vp_height);
+}
+
+
+/**
+ * Perform glClear where mask contains only color, depth, and/or stencil.
+ *
+ * The implementation is based on calling into Mesa to set GL state and
+ * performing normal triangle rendering.  The intent of this path is to
+ * have as generic a path as possible, so that any driver could make use of
+ * it.
+ */
+
+
+void radeon_clear_tris(GLcontext *ctx, GLbitfield mask)
+{
+   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   GLfloat vertices[4][3];
+   GLfloat color[4][4];
+   GLfloat dst_z;
+   struct gl_framebuffer *fb = ctx->DrawBuffer;
+   int i;
+   GLboolean saved_fp_enable = GL_FALSE, saved_vp_enable = GL_FALSE;
+   GLboolean saved_shader_program = 0;
+   unsigned int saved_active_texture;
+
+   assert((mask & ~(TRI_CLEAR_COLOR_BITS | BUFFER_BIT_DEPTH |
+                   BUFFER_BIT_STENCIL)) == 0);
+
+   _mesa_PushAttrib(GL_COLOR_BUFFER_BIT |
+                   GL_CURRENT_BIT |
+                   GL_DEPTH_BUFFER_BIT |
+                   GL_ENABLE_BIT |
+                   GL_POLYGON_BIT |
+                   GL_STENCIL_BUFFER_BIT |
+                   GL_TRANSFORM_BIT |
+                   GL_CURRENT_BIT);
+   _mesa_PushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
+   saved_active_texture = ctx->Texture.CurrentUnit;
+
+  /* Disable existing GL state we don't want to apply to a clear. */
+   _mesa_Disable(GL_ALPHA_TEST);
+   _mesa_Disable(GL_BLEND);
+   _mesa_Disable(GL_CULL_FACE);
+   _mesa_Disable(GL_FOG);
+   _mesa_Disable(GL_POLYGON_SMOOTH);
+   _mesa_Disable(GL_POLYGON_STIPPLE);
+   _mesa_Disable(GL_POLYGON_OFFSET_FILL);
+   _mesa_Disable(GL_LIGHTING);
+   _mesa_Disable(GL_CLIP_PLANE0);
+   _mesa_Disable(GL_CLIP_PLANE1);
+   _mesa_Disable(GL_CLIP_PLANE2);
+   _mesa_Disable(GL_CLIP_PLANE3);
+   _mesa_Disable(GL_CLIP_PLANE4);
+   _mesa_Disable(GL_CLIP_PLANE5);
+   _mesa_PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+   if (ctx->Extensions.ARB_fragment_program && ctx->FragmentProgram.Enabled) {
+      saved_fp_enable = GL_TRUE;
+      _mesa_Disable(GL_FRAGMENT_PROGRAM_ARB);
+   }
+   if (ctx->Extensions.ARB_vertex_program && ctx->VertexProgram.Enabled) {
+      saved_vp_enable = GL_TRUE;
+      _mesa_Disable(GL_VERTEX_PROGRAM_ARB);
+   }
+   if (ctx->Extensions.ARB_shader_objects && ctx->Shader.CurrentProgram) {
+      saved_shader_program = ctx->Shader.CurrentProgram->Name;
+      _mesa_UseProgramObjectARB(0);
+   }
+
+   if (ctx->Texture._EnabledUnits != 0) {
+      int i;
+
+      for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
+        _mesa_ActiveTextureARB(GL_TEXTURE0 + i);
+        _mesa_Disable(GL_TEXTURE_1D);
+        _mesa_Disable(GL_TEXTURE_2D);
+        _mesa_Disable(GL_TEXTURE_3D);
+        if (ctx->Extensions.ARB_texture_cube_map)
+           _mesa_Disable(GL_TEXTURE_CUBE_MAP_ARB);
+        if (ctx->Extensions.NV_texture_rectangle)
+           _mesa_Disable(GL_TEXTURE_RECTANGLE_NV);
+        if (ctx->Extensions.MESA_texture_array) {
+           _mesa_Disable(GL_TEXTURE_1D_ARRAY_EXT);
+           _mesa_Disable(GL_TEXTURE_2D_ARRAY_EXT);
+        }
+      }
+   }
+
+#if FEATURE_ARB_vertex_buffer_object
+   _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
+   _mesa_BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
+#endif
+
+   radeon_meta_set_passthrough_transform(rmesa);
+
+   for (i = 0; i < 4; i++) {
+      color[i][0] = ctx->Color.ClearColor[0];
+      color[i][1] = ctx->Color.ClearColor[1];
+      color[i][2] = ctx->Color.ClearColor[2];
+      color[i][3] = ctx->Color.ClearColor[3];
+   }
+
+   /* convert clear Z from [0,1] to NDC coord in [-1,1] */
+
+   dst_z = -1.0 + 2.0 * ctx->Depth.Clear;
+   /* Prepare the vertices, which are the same regardless of which buffer we're
+    * drawing to.
+    */
+   vertices[0][0] = fb->_Xmin;
+   vertices[0][1] = fb->_Ymin;
+   vertices[0][2] = dst_z;
+   vertices[1][0] = fb->_Xmax;
+   vertices[1][1] = fb->_Ymin;
+   vertices[1][2] = dst_z;
+   vertices[2][0] = fb->_Xmax;
+   vertices[2][1] = fb->_Ymax;
+   vertices[2][2] = dst_z;
+   vertices[3][0] = fb->_Xmin;
+   vertices[3][1] = fb->_Ymax;
+   vertices[3][2] = dst_z;
+
+   _mesa_ColorPointer(4, GL_FLOAT, 4 * sizeof(GLfloat), &color);
+   _mesa_VertexPointer(3, GL_FLOAT, 3 * sizeof(GLfloat), &vertices);
+   _mesa_Enable(GL_COLOR_ARRAY);
+   _mesa_Enable(GL_VERTEX_ARRAY);
+
+   while (mask != 0) {
+      GLuint this_mask = 0;
+      GLuint color_bit;
+
+      color_bit = _mesa_ffs(mask & TRI_CLEAR_COLOR_BITS);
+      if (color_bit != 0)
+        this_mask |= (1 << (color_bit - 1));
+
+      /* Clear depth/stencil in the same pass as color. */
+      this_mask |= (mask & (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL));
+
+      /* Select the current color buffer and use the color write mask if
+       * we have one, otherwise don't write any color channels.
+       */
+      if (this_mask & BUFFER_BIT_FRONT_LEFT)
+        _mesa_DrawBuffer(GL_FRONT_LEFT);
+      else if (this_mask & BUFFER_BIT_BACK_LEFT)
+        _mesa_DrawBuffer(GL_BACK_LEFT);
+      else if (color_bit != 0)
+        _mesa_DrawBuffer(GL_COLOR_ATTACHMENT0 +
+                         (color_bit - BUFFER_COLOR0 - 1));
+      else
+        _mesa_ColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+
+      /* Control writing of the depth clear value to depth. */
+      if (this_mask & BUFFER_BIT_DEPTH) {
+        _mesa_DepthFunc(GL_ALWAYS);
+        _mesa_DepthMask(GL_TRUE);
+        _mesa_Enable(GL_DEPTH_TEST);
+      } else {
+        _mesa_Disable(GL_DEPTH_TEST);
+        _mesa_DepthMask(GL_FALSE);
+      }
+
+      /* Control writing of the stencil clear value to stencil. */
+      if (this_mask & BUFFER_BIT_STENCIL) {
+        _mesa_Enable(GL_STENCIL_TEST);
+        _mesa_StencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
+        _mesa_StencilFuncSeparate(GL_FRONT_AND_BACK, GL_ALWAYS, ctx->Stencil.Clear,
+                                  ctx->Stencil.WriteMask[0]);
+      } else {
+        _mesa_Disable(GL_STENCIL_TEST);
+      }
+
+      CALL_DrawArrays(ctx->Exec, (GL_TRIANGLE_FAN, 0, 4));
+
+      mask &= ~this_mask;
+   }
+
+   radeon_meta_restore_transform(rmesa);
+
+   _mesa_ActiveTextureARB(GL_TEXTURE0 + saved_active_texture);
+   if (saved_fp_enable)
+      _mesa_Enable(GL_FRAGMENT_PROGRAM_ARB);
+   if (saved_vp_enable)
+      _mesa_Enable(GL_VERTEX_PROGRAM_ARB);
+
+   if (saved_shader_program)
+      _mesa_UseProgramObjectARB(saved_shader_program);
+
+   _mesa_PopClientAttrib();
+   _mesa_PopAttrib();
+}
diff --git a/src/mesa/drivers/dri/radeon/radeon_common.h b/src/mesa/drivers/dri/radeon/radeon_common.h
new file mode 100644 (file)
index 0000000..b60792d
--- /dev/null
@@ -0,0 +1,100 @@
+#ifndef COMMON_MISC_H
+#define COMMON_MISC_H
+
+#include "radeon_common_context.h"
+#include "radeon_dma.h"
+#include "radeon_texture.h"
+
+
+#define TRI_CLEAR_COLOR_BITS (BUFFER_BIT_BACK_LEFT |                   \
+                             BUFFER_BIT_FRONT_LEFT |                   \
+                             BUFFER_BIT_COLOR0 |                       \
+                             BUFFER_BIT_COLOR1 |                       \
+                             BUFFER_BIT_COLOR2 |                       \
+                             BUFFER_BIT_COLOR3 |                       \
+                             BUFFER_BIT_COLOR4 |                       \
+                             BUFFER_BIT_COLOR5 |                       \
+                             BUFFER_BIT_COLOR6 |                       \
+                             BUFFER_BIT_COLOR7)
+
+void radeonRecalcScissorRects(radeonContextPtr radeon);
+void radeonSetCliprects(radeonContextPtr radeon);
+void radeonUpdateScissor( GLcontext *ctx );
+void radeonScissor(GLcontext* ctx, GLint x, GLint y, GLsizei w, GLsizei h);
+
+void radeonWaitForIdleLocked(radeonContextPtr radeon);
+extern uint32_t radeonGetAge(radeonContextPtr radeon);
+void radeonCopyBuffer( __DRIdrawablePrivate *dPriv,
+                      const drm_clip_rect_t      *rect);
+void radeonSwapBuffers(__DRIdrawablePrivate * dPriv);
+void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
+                        int x, int y, int w, int h );
+
+void radeonUpdatePageFlipping(radeonContextPtr rmesa);
+
+void radeonFlush(GLcontext *ctx);
+void radeonFinish(GLcontext * ctx);
+void radeonEmitState(radeonContextPtr radeon);
+
+void radeon_clear_tris(GLcontext *ctx, GLbitfield mask);
+
+void radeon_window_moved(radeonContextPtr radeon);
+void radeon_draw_buffer(GLcontext *ctx, struct gl_framebuffer *fb);
+void radeonDrawBuffer( GLcontext *ctx, GLenum mode );
+void radeonReadBuffer( GLcontext *ctx, GLenum mode );
+void radeon_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height);
+void radeon_get_cliprects(radeonContextPtr radeon,
+                         struct drm_clip_rect **cliprects,
+                         unsigned int *num_cliprects,
+                         int *x_off, int *y_off);
+GLboolean radeon_revalidate_bos(GLcontext *ctx);
+void radeon_validate_bo(radeonContextPtr radeon, struct radeon_bo *bo, uint32_t read_domains, uint32_t write_domain);
+void radeon_validate_reset_bos(radeonContextPtr radeon);
+
+void radeon_fbo_init(struct radeon_context *radeon);
+void
+radeon_renderbuffer_set_bo(struct radeon_renderbuffer *rb,
+                          struct radeon_bo *bo);
+struct radeon_renderbuffer *
+radeon_create_renderbuffer(GLenum format, __DRIdrawablePrivate *driDrawPriv);
+static inline struct radeon_renderbuffer *radeon_renderbuffer(struct gl_renderbuffer *rb)
+{
+       struct radeon_renderbuffer *rrb = (struct radeon_renderbuffer *)rb;
+       if (rrb && rrb->base.ClassID == RADEON_RB_CLASS)
+               return rrb;
+       else
+               return NULL;
+}
+
+static inline struct radeon_renderbuffer *radeon_get_renderbuffer(struct gl_framebuffer *fb, int att_index)
+{
+       if (att_index >= 0)
+               return radeon_renderbuffer(fb->Attachment[att_index].Renderbuffer);
+       else
+               return NULL;
+}
+
+static inline struct radeon_renderbuffer *radeon_get_depthbuffer(radeonContextPtr rmesa)
+{
+       struct radeon_renderbuffer *rrb;
+       rrb = radeon_renderbuffer(rmesa->state.depth.rb);
+       if (!rrb)
+               return NULL;
+
+       return rrb;
+}
+
+static inline struct radeon_renderbuffer *radeon_get_colorbuffer(radeonContextPtr rmesa)
+{
+       struct radeon_renderbuffer *rrb;
+
+       rrb = radeon_renderbuffer(rmesa->state.color.rb);
+       if (!rrb)
+               return NULL;
+       return rrb;
+}
+
+#include "radeon_cmdbuf.h"
+
+
+#endif
diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.c b/src/mesa/drivers/dri/radeon/radeon_common_context.c
new file mode 100644 (file)
index 0000000..eb0e5b3
--- /dev/null
@@ -0,0 +1,738 @@
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+                     VA Linux Systems Inc., Fremont, California.
+Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial
+portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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_common.h"
+#include "xmlpool.h"           /* for symbolic values of enum-type options */
+#include "utils.h"
+#include "vblank.h"
+#include "drirenderbuffer.h"
+#include "main/context.h"
+#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
+#include "main/state.h"
+#include "main/simple_list.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+
+#define DRIVER_DATE "20090101"
+
+#ifndef RADEON_DEBUG
+int RADEON_DEBUG = (0);
+#endif
+
+
+static const char* get_chip_family_name(int chip_family)
+{
+       switch(chip_family) {
+       case CHIP_FAMILY_R100: return "R100";
+       case CHIP_FAMILY_RV100: return "RV100";
+       case CHIP_FAMILY_RS100: return "RS100";
+       case CHIP_FAMILY_RV200: return "RV200";
+       case CHIP_FAMILY_RS200: return "RS200";
+       case CHIP_FAMILY_R200: return "R200";
+       case CHIP_FAMILY_RV250: return "RV250";
+       case CHIP_FAMILY_RS300: return "RS300";
+       case CHIP_FAMILY_RV280: return "RV280";
+       case CHIP_FAMILY_R300: return "R300";
+       case CHIP_FAMILY_R350: return "R350";
+       case CHIP_FAMILY_RV350: return "RV350";
+       case CHIP_FAMILY_RV380: return "RV380";
+       case CHIP_FAMILY_R420: return "R420";
+       case CHIP_FAMILY_RV410: return "RV410";
+       case CHIP_FAMILY_RS400: return "RS400";
+       case CHIP_FAMILY_RS600: return "RS600";
+       case CHIP_FAMILY_RS690: return "RS690";
+       case CHIP_FAMILY_RS740: return "RS740";
+       case CHIP_FAMILY_RV515: return "RV515";
+       case CHIP_FAMILY_R520: return "R520";
+       case CHIP_FAMILY_RV530: return "RV530";
+       case CHIP_FAMILY_R580: return "R580";
+       case CHIP_FAMILY_RV560: return "RV560";
+       case CHIP_FAMILY_RV570: return "RV570";
+       default: return "unknown";
+       }
+}
+
+
+/* Return various strings for glGetString().
+ */
+static const GLubyte *radeonGetString(GLcontext * ctx, GLenum name)
+{
+       radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+       static char buffer[128];
+
+       switch (name) {
+       case GL_VENDOR:
+               if (IS_R300_CLASS(radeon->radeonScreen))
+                       return (GLubyte *) "DRI R300 Project";
+               else
+                       return (GLubyte *) "Tungsten Graphics, Inc.";
+
+       case GL_RENDERER:
+       {
+               unsigned offset;
+               GLuint agp_mode = (radeon->radeonScreen->card_type==RADEON_CARD_PCI) ? 0 :
+                       radeon->radeonScreen->AGPMode;
+               const char* chipclass;
+               char hardwarename[32];
+
+               if (IS_R300_CLASS(radeon->radeonScreen))
+                       chipclass = "R300";
+               else if (IS_R200_CLASS(radeon->radeonScreen))
+                       chipclass = "R200";
+               else
+                       chipclass = "R100";
+
+               sprintf(hardwarename, "%s (%s %04X)",
+                       chipclass,
+                       get_chip_family_name(radeon->radeonScreen->chip_family),
+                       radeon->radeonScreen->device_id);
+
+               offset = driGetRendererString(buffer, hardwarename, DRIVER_DATE,
+                                             agp_mode);
+
+               if (IS_R300_CLASS(radeon->radeonScreen)) {
+                       sprintf(&buffer[offset], " %sTCL",
+                               (radeon->radeonScreen->chip_flags & RADEON_CHIPSET_TCL)
+                               ? "" : "NO-");
+               } else {
+                       sprintf(&buffer[offset], " %sTCL",
+                               !(radeon->TclFallback & RADEON_TCL_FALLBACK_TCL_DISABLE)
+                               ? "" : "NO-");
+               }
+
+               if (radeon->radeonScreen->driScreen->dri2.enabled)
+                       strcat(buffer, " DRI2");
+
+               return (GLubyte *) buffer;
+       }
+
+       default:
+               return NULL;
+       }
+}
+
+/* Initialize the driver's misc functions.
+ */
+static void radeonInitDriverFuncs(struct dd_function_table *functions)
+{
+       functions->GetString = radeonGetString;
+}
+
+/**
+ * Create and initialize all common fields of the context,
+ * including the Mesa context itself.
+ */
+GLboolean radeonInitContext(radeonContextPtr radeon,
+                           struct dd_function_table* functions,
+                           const __GLcontextModes * glVisual,
+                           __DRIcontextPrivate * driContextPriv,
+                           void *sharedContextPrivate)
+{
+       __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+       radeonScreenPtr screen = (radeonScreenPtr) (sPriv->private);
+       GLcontext* ctx;
+       GLcontext* shareCtx;
+       int fthrottle_mode;
+
+       /* Fill in additional standard functions. */
+       radeonInitDriverFuncs(functions);
+
+       radeon->radeonScreen = screen;
+       /* Allocate and initialize the Mesa context */
+       if (sharedContextPrivate)
+               shareCtx = ((radeonContextPtr)sharedContextPrivate)->glCtx;
+       else
+               shareCtx = NULL;
+       radeon->glCtx = _mesa_create_context(glVisual, shareCtx,
+                                           functions, (void *)radeon);
+       if (!radeon->glCtx)
+               return GL_FALSE;
+
+       ctx = radeon->glCtx;
+       driContextPriv->driverPrivate = radeon;
+
+       /* DRI fields */
+       radeon->dri.context = driContextPriv;
+       radeon->dri.screen = sPriv;
+       radeon->dri.hwContext = driContextPriv->hHWContext;
+       radeon->dri.hwLock = &sPriv->pSAREA->lock;
+       radeon->dri.fd = sPriv->fd;
+       radeon->dri.drmMinor = sPriv->drm_version.minor;
+
+       radeon->sarea = (drm_radeon_sarea_t *) ((GLubyte *) sPriv->pSAREA +
+                                              screen->sarea_priv_offset);
+
+       /* Setup IRQs */
+       fthrottle_mode = driQueryOptioni(&radeon->optionCache, "fthrottle_mode");
+       radeon->iw.irq_seq = -1;
+       radeon->irqsEmitted = 0;
+       radeon->do_irqs = (fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS &&
+                         radeon->radeonScreen->irq);
+
+       radeon->do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS);
+
+       if (!radeon->do_irqs)
+               fprintf(stderr,
+                       "IRQ's not enabled, falling back to %s: %d %d\n",
+                       radeon->do_usleeps ? "usleeps" : "busy waits",
+                       fthrottle_mode, radeon->radeonScreen->irq);
+
+        radeon->texture_depth = driQueryOptioni (&radeon->optionCache,
+                                               "texture_depth");
+        if (radeon->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
+                radeon->texture_depth = ( glVisual->rgbBits > 16 ) ?
+               DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
+
+       radeon->texture_row_align = 32;
+
+       return GL_TRUE;
+}
+
+
+
+/**
+ * Destroy the command buffer and state atoms.
+ */
+static void radeon_destroy_atom_list(radeonContextPtr radeon)
+{
+       struct radeon_state_atom *atom;
+
+       foreach(atom, &radeon->hw.atomlist) {
+               FREE(atom->cmd);
+               if (atom->lastcmd)
+                       FREE(atom->lastcmd);
+       }
+
+}
+
+/**
+ * Cleanup common context fields.
+ * Called by r200DestroyContext/r300DestroyContext
+ */
+void radeonDestroyContext(__DRIcontextPrivate *driContextPriv )
+{
+#ifdef RADEON_BO_TRACK
+       FILE *track;
+#endif
+       GET_CURRENT_CONTEXT(ctx);
+       radeonContextPtr radeon = (radeonContextPtr) driContextPriv->driverPrivate;
+       radeonContextPtr current = ctx ? RADEON_CONTEXT(ctx) : NULL;
+
+       if (radeon == current) {
+               radeon_firevertices(radeon);
+               _mesa_make_current(NULL, NULL, NULL);
+       }
+
+       assert(radeon);
+       if (radeon) {
+
+               if (radeon->dma.current) {
+                       rcommonFlushCmdBuf( radeon, __FUNCTION__ );
+               }
+
+               radeonReleaseArrays(radeon->glCtx, ~0);
+
+               if (radeon->vtbl.free_context)
+                       radeon->vtbl.free_context(radeon->glCtx);
+               _swsetup_DestroyContext( radeon->glCtx );
+               _tnl_DestroyContext( radeon->glCtx );
+               _vbo_DestroyContext( radeon->glCtx );
+               _swrast_DestroyContext( radeon->glCtx );
+
+               /* free atom list */
+               /* free the Mesa context */
+               _mesa_destroy_context(radeon->glCtx);
+
+               /* _mesa_destroy_context() might result in calls to functions that
+                * depend on the DriverCtx, so don't set it to NULL before.
+                *
+                * radeon->glCtx->DriverCtx = NULL;
+                */
+               /* free the option cache */
+               driDestroyOptionCache(&radeon->optionCache);
+
+               rcommonDestroyCmdBuf(radeon);
+
+               radeon_destroy_atom_list(radeon);
+
+               if (radeon->state.scissor.pClipRects) {
+                       FREE(radeon->state.scissor.pClipRects);
+                       radeon->state.scissor.pClipRects = 0;
+               }
+       }
+#ifdef RADEON_BO_TRACK
+       track = fopen("/tmp/tracklog", "w");
+       if (track) {
+               radeon_tracker_print(&radeon->radeonScreen->bom->tracker, track);
+               fclose(track);
+       }
+#endif
+       FREE(radeon);
+}
+
+/* Force the context `c' to be unbound from its buffer.
+ */
+GLboolean radeonUnbindContext(__DRIcontextPrivate * driContextPriv)
+{
+       radeonContextPtr radeon = (radeonContextPtr) driContextPriv->driverPrivate;
+
+       if (RADEON_DEBUG & DEBUG_DRI)
+               fprintf(stderr, "%s ctx %p\n", __FUNCTION__,
+                       radeon->glCtx);
+
+       return GL_TRUE;
+}
+
+
+static void
+radeon_make_kernel_renderbuffer_current(radeonContextPtr radeon,
+                                       struct radeon_framebuffer *draw)
+{
+       /* if radeon->fake */
+       struct radeon_renderbuffer *rb;
+
+       if ((rb = (void *)draw->base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer)) {
+               if (!rb->bo) {
+                       rb->bo = radeon_bo_open(radeon->radeonScreen->bom,
+                                               radeon->radeonScreen->frontOffset,
+                                               0,
+                                               0,
+                                               RADEON_GEM_DOMAIN_VRAM,
+                                               0);
+               }
+               rb->cpp = radeon->radeonScreen->cpp;
+               rb->pitch = radeon->radeonScreen->frontPitch * rb->cpp;
+       }
+       if ((rb = (void *)draw->base.Attachment[BUFFER_BACK_LEFT].Renderbuffer)) {
+               if (!rb->bo) {
+                       rb->bo = radeon_bo_open(radeon->radeonScreen->bom,
+                                               radeon->radeonScreen->backOffset,
+                                               0,
+                                               0,
+                                               RADEON_GEM_DOMAIN_VRAM,
+                                               0);
+               }
+               rb->cpp = radeon->radeonScreen->cpp;
+               rb->pitch = radeon->radeonScreen->backPitch * rb->cpp;
+       }
+       if ((rb = (void *)draw->base.Attachment[BUFFER_DEPTH].Renderbuffer)) {
+               if (!rb->bo) {
+                       rb->bo = radeon_bo_open(radeon->radeonScreen->bom,
+                                               radeon->radeonScreen->depthOffset,
+                                               0,
+                                               0,
+                                               RADEON_GEM_DOMAIN_VRAM,
+                                               0);
+               }
+               rb->cpp = radeon->radeonScreen->cpp;
+               rb->pitch = radeon->radeonScreen->depthPitch * rb->cpp;
+       }
+       if ((rb = (void *)draw->base.Attachment[BUFFER_STENCIL].Renderbuffer)) {
+               if (!rb->bo) {
+                       rb->bo = radeon_bo_open(radeon->radeonScreen->bom,
+                                               radeon->radeonScreen->depthOffset,
+                                               0,
+                                               0,
+                                               RADEON_GEM_DOMAIN_VRAM,
+                                               0);
+               }
+               rb->cpp = radeon->radeonScreen->cpp;
+               rb->pitch = radeon->radeonScreen->depthPitch * rb->cpp;
+       }
+}
+
+static void
+radeon_make_renderbuffer_current(radeonContextPtr radeon,
+                                struct radeon_framebuffer *draw)
+{
+       int size = 4096*4096*4;
+       /* if radeon->fake */
+       struct radeon_renderbuffer *rb;
+
+       if (radeon->radeonScreen->kernel_mm) {
+               radeon_make_kernel_renderbuffer_current(radeon, draw);
+               return;
+       }
+
+
+       if ((rb = (void *)draw->base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer)) {
+               if (!rb->bo) {
+                       rb->bo = radeon_bo_open(radeon->radeonScreen->bom,
+                                               radeon->radeonScreen->frontOffset +
+                                               radeon->radeonScreen->fbLocation,
+                                               size,
+                                               4096,
+                                               RADEON_GEM_DOMAIN_VRAM,
+                                               0);
+               }
+               rb->cpp = radeon->radeonScreen->cpp;
+               rb->pitch = radeon->radeonScreen->frontPitch * rb->cpp;
+       }
+       if ((rb = (void *)draw->base.Attachment[BUFFER_BACK_LEFT].Renderbuffer)) {
+               if (!rb->bo) {
+                       rb->bo = radeon_bo_open(radeon->radeonScreen->bom,
+                                               radeon->radeonScreen->backOffset +
+                                               radeon->radeonScreen->fbLocation,
+                                               size,
+                                               4096,
+                                               RADEON_GEM_DOMAIN_VRAM,
+                                               0);
+               }
+               rb->cpp = radeon->radeonScreen->cpp;
+               rb->pitch = radeon->radeonScreen->backPitch * rb->cpp;
+       }
+       if ((rb = (void *)draw->base.Attachment[BUFFER_DEPTH].Renderbuffer)) {
+               if (!rb->bo) {
+                       rb->bo = radeon_bo_open(radeon->radeonScreen->bom,
+                                               radeon->radeonScreen->depthOffset +
+                                               radeon->radeonScreen->fbLocation,
+                                               size,
+                                               4096,
+                                               RADEON_GEM_DOMAIN_VRAM,
+                                               0);
+               }
+               rb->cpp = radeon->radeonScreen->cpp;
+               rb->pitch = radeon->radeonScreen->depthPitch * rb->cpp;
+       }
+       if ((rb = (void *)draw->base.Attachment[BUFFER_STENCIL].Renderbuffer)) {
+               if (!rb->bo) {
+                       rb->bo = radeon_bo_open(radeon->radeonScreen->bom,
+                                               radeon->radeonScreen->depthOffset +
+                                               radeon->radeonScreen->fbLocation,
+                                               size,
+                                               4096,
+                                               RADEON_GEM_DOMAIN_VRAM,
+                                               0);
+               }
+               rb->cpp = radeon->radeonScreen->cpp;
+               rb->pitch = radeon->radeonScreen->depthPitch * rb->cpp;
+       }
+}
+
+static unsigned
+radeon_bits_per_pixel(const struct radeon_renderbuffer *rb)
+{
+   switch (rb->base._ActualFormat) {
+   case GL_RGB5:
+   case GL_DEPTH_COMPONENT16:
+      return 16;
+   case GL_RGB8:
+   case GL_RGBA8:
+   case GL_DEPTH_COMPONENT24:
+   case GL_DEPTH24_STENCIL8_EXT:
+   case GL_STENCIL_INDEX8_EXT:
+      return 32;
+   default:
+      return 0;
+   }
+}
+
+void
+radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
+{
+       unsigned int attachments[10];
+       __DRIbuffer *buffers = NULL;
+       __DRIscreen *screen;
+       struct radeon_renderbuffer *rb;
+       int i, count;
+       struct radeon_framebuffer *draw;
+       radeonContextPtr radeon;
+       char *regname;
+       struct radeon_bo *depth_bo = NULL, *bo;
+
+       if (RADEON_DEBUG & DEBUG_DRI)
+           fprintf(stderr, "enter %s, drawable %p\n", __func__, drawable);
+
+       draw = drawable->driverPrivate;
+       screen = context->driScreenPriv;
+       radeon = (radeonContextPtr) context->driverPrivate;
+
+       if (screen->dri2.loader
+          && (screen->dri2.loader->base.version > 2)
+          && (screen->dri2.loader->getBuffersWithFormat != NULL)) {
+               struct radeon_renderbuffer *depth_rb;
+               struct radeon_renderbuffer *stencil_rb;
+
+               i = 0;
+               if ((radeon->is_front_buffer_rendering || !draw->color_rb[1])
+                       && draw->color_rb[0]) {
+                       attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
+                       attachments[i++] = radeon_bits_per_pixel(draw->color_rb[0]);
+               }
+
+               if (draw->color_rb[1]) {
+                       attachments[i++] = __DRI_BUFFER_BACK_LEFT;
+                       attachments[i++] = radeon_bits_per_pixel(draw->color_rb[1]);
+               }
+
+               depth_rb = radeon_get_renderbuffer(&draw->base, BUFFER_DEPTH);
+               stencil_rb = radeon_get_renderbuffer(&draw->base, BUFFER_STENCIL);
+
+               if ((depth_rb != NULL) && (stencil_rb != NULL)) {
+                       attachments[i++] = __DRI_BUFFER_DEPTH_STENCIL;
+                       attachments[i++] = radeon_bits_per_pixel(depth_rb);
+               } else if (depth_rb != NULL) {
+                       attachments[i++] = __DRI_BUFFER_DEPTH;
+                       attachments[i++] = radeon_bits_per_pixel(depth_rb);
+               } else if (stencil_rb != NULL) {
+                       attachments[i++] = __DRI_BUFFER_STENCIL;
+                       attachments[i++] = radeon_bits_per_pixel(stencil_rb);
+               }
+
+               buffers = (*screen->dri2.loader->getBuffersWithFormat)(drawable,
+                                                               &drawable->w,
+                                                               &drawable->h,
+                                                               attachments, i / 2,
+                                                               &count,
+                                                               drawable->loaderPrivate);
+       } else if (screen->dri2.loader) {
+               i = 0;
+               if (draw->color_rb[0])
+                       attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
+               if (draw->color_rb[1])
+                       attachments[i++] = __DRI_BUFFER_BACK_LEFT;
+               if (radeon_get_renderbuffer(&draw->base, BUFFER_DEPTH))
+                       attachments[i++] = __DRI_BUFFER_DEPTH;
+               if (radeon_get_renderbuffer(&draw->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;
+
+       /* set one cliprect to cover the whole drawable */
+       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;
+       for (i = 0; i < count; i++) {
+               switch (buffers[i].attachment) {
+               case __DRI_BUFFER_FRONT_LEFT:
+                       rb = draw->color_rb[0];
+                       regname = "dri2 front buffer";
+                       break;
+               case __DRI_BUFFER_FAKE_FRONT_LEFT:
+                       rb = draw->color_rb[0];
+                       regname = "dri2 fake front buffer";
+                       break;
+               case __DRI_BUFFER_BACK_LEFT:
+                       rb = draw->color_rb[1];
+                       regname = "dri2 back buffer";
+                       break;
+               case __DRI_BUFFER_DEPTH:
+                       rb = radeon_get_renderbuffer(&draw->base, BUFFER_DEPTH);
+                       regname = "dri2 depth buffer";
+                       break;
+               case __DRI_BUFFER_DEPTH_STENCIL:
+                       rb = radeon_get_renderbuffer(&draw->base, BUFFER_DEPTH);
+                       regname = "dri2 depth / stencil buffer";
+                       break;
+               case __DRI_BUFFER_STENCIL:
+                       rb = radeon_get_renderbuffer(&draw->base, BUFFER_STENCIL);
+                       regname = "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 == NULL)
+                       continue;
+
+               if (rb->bo) {
+                       uint32_t name = radeon_gem_name_bo(rb->bo);
+                       if (name == buffers[i].name)
+                               continue;
+               }
+
+               if (RADEON_DEBUG & DEBUG_DRI)
+                       fprintf(stderr,
+                               "attaching buffer %s, %d, at %d, cpp %d, pitch %d\n",
+                               regname, buffers[i].name, buffers[i].attachment,
+                               buffers[i].cpp, buffers[i].pitch);
+
+               rb->cpp = buffers[i].cpp;
+               rb->pitch = buffers[i].pitch;
+               rb->width = drawable->w;
+               rb->height = drawable->h;
+               rb->has_surface = 0;
+
+               if (buffers[i].attachment == __DRI_BUFFER_STENCIL && depth_bo) {
+                       if (RADEON_DEBUG & DEBUG_DRI)
+                               fprintf(stderr, "(reusing depth buffer as stencil)\n");
+                       bo = depth_bo;
+                       radeon_bo_ref(bo);
+               } else {
+                       bo = radeon_bo_open(radeon->radeonScreen->bom,
+                                               buffers[i].name,
+                                               0,
+                                               0,
+                                               RADEON_GEM_DOMAIN_VRAM,
+                                               buffers[i].flags);
+                       if (bo == NULL) {
+
+                               fprintf(stderr, "failed to attach %s %d\n",
+                                       regname, buffers[i].name);
+
+                       }
+               }
+
+               if (buffers[i].attachment == __DRI_BUFFER_DEPTH) {
+                       if (draw->base.Visual.depthBits == 16)
+                               rb->cpp = 2;
+                       depth_bo = bo;
+               }
+
+               radeon_renderbuffer_set_bo(rb, bo);
+               radeon_bo_unref(bo);
+
+               if (buffers[i].attachment == __DRI_BUFFER_DEPTH_STENCIL) {
+                       rb = radeon_get_renderbuffer(&draw->base, BUFFER_STENCIL);
+                       if (rb != NULL) {
+                               struct radeon_bo *stencil_bo = NULL;
+
+                               if (rb->bo) {
+                                       uint32_t name = radeon_gem_name_bo(rb->bo);
+                                       if (name == buffers[i].name)
+                                               continue;
+                               }
+
+                               stencil_bo = bo;
+                               radeon_bo_ref(stencil_bo);
+                               radeon_renderbuffer_set_bo(rb, stencil_bo);
+                               radeon_bo_unref(stencil_bo);
+                       }
+               }
+       }
+
+       driUpdateFramebufferSize(radeon->glCtx, drawable);
+}
+
+/* Force the context `c' to be the current context and associate with it
+ * buffer `b'.
+ */
+GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
+                           __DRIdrawablePrivate * driDrawPriv,
+                           __DRIdrawablePrivate * driReadPriv)
+{
+       radeonContextPtr radeon;
+       struct radeon_framebuffer *drfb;
+       struct gl_framebuffer *readfb;
+
+       if (!driContextPriv) {
+               if (RADEON_DEBUG & DEBUG_DRI)
+                       fprintf(stderr, "%s ctx is null\n", __FUNCTION__);
+               _mesa_make_current(NULL, NULL, NULL);
+               return GL_TRUE;
+       }
+
+       radeon = (radeonContextPtr) driContextPriv->driverPrivate;
+       drfb = driDrawPriv->driverPrivate;
+       readfb = driReadPriv->driverPrivate;
+
+       if (driContextPriv->driScreenPriv->dri2.enabled) {
+               radeon_update_renderbuffers(driContextPriv, driDrawPriv);
+               if (driDrawPriv != driReadPriv)
+                       radeon_update_renderbuffers(driContextPriv, driReadPriv);
+               _mesa_reference_renderbuffer(&radeon->state.color.rb,
+                       &(radeon_get_renderbuffer(&drfb->base, BUFFER_BACK_LEFT)->base));
+               _mesa_reference_renderbuffer(&radeon->state.depth.rb,
+                       &(radeon_get_renderbuffer(&drfb->base, BUFFER_DEPTH)->base));
+       } else {
+               radeon_make_renderbuffer_current(radeon, drfb);
+       }
+
+
+       if (RADEON_DEBUG & DEBUG_DRI)
+            fprintf(stderr, "%s ctx %p dfb %p rfb %p\n", __FUNCTION__, radeon->glCtx, drfb, readfb);
+
+       driUpdateFramebufferSize(radeon->glCtx, driDrawPriv);
+       if (driReadPriv != driDrawPriv)
+               driUpdateFramebufferSize(radeon->glCtx, driReadPriv);
+
+       _mesa_make_current(radeon->glCtx, &drfb->base, readfb);
+
+       _mesa_update_state(radeon->glCtx);
+
+       if (radeon->glCtx->DrawBuffer == &drfb->base) {
+               if (driDrawPriv->swap_interval == (unsigned)-1) {
+                       int i;
+                       driDrawPriv->vblFlags =
+                               (radeon->radeonScreen->irq != 0)
+                               ? driGetDefaultVBlankFlags(&radeon->
+                                                          optionCache)
+                               : VBLANK_FLAG_NO_IRQ;
+
+                       driDrawableInitVBlank(driDrawPriv);
+                       drfb->vbl_waited = driDrawPriv->vblSeq;
+
+                       for (i = 0; i < 2; i++) {
+                               if (drfb->color_rb[i])
+                                       drfb->color_rb[i]->vbl_pending = driDrawPriv->vblSeq;
+                       }
+
+               }
+
+               radeon_window_moved(radeon);
+               radeon_draw_buffer(radeon->glCtx, &drfb->base);
+       }
+
+
+       if (RADEON_DEBUG & DEBUG_DRI)
+               fprintf(stderr, "End %s\n", __FUNCTION__);
+       return GL_TRUE;
+}
+
diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.h b/src/mesa/drivers/dri/radeon/radeon_common_context.h
new file mode 100644 (file)
index 0000000..061168f
--- /dev/null
@@ -0,0 +1,581 @@
+
+#ifndef COMMON_CONTEXT_H
+#define COMMON_CONTEXT_H
+
+#include "main/mm.h"
+#include "math/m_vector.h"
+#include "texmem.h"
+#include "tnl/t_context.h"
+#include "main/colormac.h"
+
+#include "radeon_screen.h"
+#include "radeon_drm.h"
+#include "dri_util.h"
+#include "tnl/t_vertex.h"
+
+struct radeon_context;
+
+#include "radeon_bocs_wrapper.h"
+
+/* This union is used to avoid warnings/miscompilation
+   with float to uint32_t casts due to strict-aliasing */
+typedef union { GLfloat f; uint32_t ui32; } float_ui32_type;
+
+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
+
+/* Rasterizing fallbacks */
+/* See correponding strings in r200_swtcl.c */
+#define RADEON_FALLBACK_TEXTURE                0x0001
+#define RADEON_FALLBACK_DRAW_BUFFER    0x0002
+#define RADEON_FALLBACK_STENCIL                0x0004
+#define RADEON_FALLBACK_RENDER_MODE    0x0008
+#define RADEON_FALLBACK_BLEND_EQ       0x0010
+#define RADEON_FALLBACK_BLEND_FUNC     0x0020
+#define RADEON_FALLBACK_DISABLE        0x0040
+#define RADEON_FALLBACK_BORDER_MODE    0x0080
+#define RADEON_FALLBACK_DEPTH_BUFFER   0x0100
+#define RADEON_FALLBACK_STENCIL_BUFFER  0x0200
+
+#define R200_FALLBACK_TEXTURE           0x01
+#define R200_FALLBACK_DRAW_BUFFER       0x02
+#define R200_FALLBACK_STENCIL           0x04
+#define R200_FALLBACK_RENDER_MODE       0x08
+#define R200_FALLBACK_DISABLE           0x10
+#define R200_FALLBACK_BORDER_MODE       0x20
+
+#define RADEON_TCL_FALLBACK_RASTER            0x1 /* rasterization */
+#define RADEON_TCL_FALLBACK_UNFILLED          0x2 /* unfilled tris */
+#define RADEON_TCL_FALLBACK_LIGHT_TWOSIDE     0x4 /* twoside tris */
+#define RADEON_TCL_FALLBACK_MATERIAL          0x8 /* material in vb */
+#define RADEON_TCL_FALLBACK_TEXGEN_0          0x10 /* texgen, unit 0 */
+#define RADEON_TCL_FALLBACK_TEXGEN_1          0x20 /* texgen, unit 1 */
+#define RADEON_TCL_FALLBACK_TEXGEN_2          0x40 /* texgen, unit 2 */
+#define RADEON_TCL_FALLBACK_TCL_DISABLE       0x80 /* user disable */
+#define RADEON_TCL_FALLBACK_FOGCOORDSPEC      0x100 /* fogcoord, sep. spec light */
+
+/* The blit width for texture uploads
+ */
+#define BLIT_WIDTH_BYTES 1024
+
+/* Use the templated vertex format:
+ */
+#define COLOR_IS_RGBA
+#define TAG(x) radeon##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
+
+#define RADEON_RB_CLASS 0xdeadbeef
+
+struct radeon_renderbuffer
+{
+       struct gl_renderbuffer base;
+       struct radeon_bo *bo;
+       unsigned int cpp;
+       /* unsigned int offset; */
+       unsigned int pitch;
+       unsigned int width;
+       unsigned int height;
+
+       uint32_t draw_offset; /* FBO */
+       /* boo Xorg 6.8.2 compat */
+       int has_surface;
+
+       GLuint pf_pending;  /**< sequence number of pending flip */
+       GLuint vbl_pending;   /**< vblank sequence number of pending flip */
+       __DRIdrawablePrivate *dPriv;
+};
+
+struct radeon_framebuffer
+{
+       struct gl_framebuffer base;
+
+       struct radeon_renderbuffer *color_rb[2];
+
+       GLuint vbl_waited;
+
+       /* buffer swap */
+       int64_t swap_ust;
+       int64_t swap_missed_ust;
+
+       GLuint swap_count;
+       GLuint swap_missed_count;
+
+       /* Drawable page flipping state */
+       GLboolean pf_active;
+       GLint pf_current_page;
+       GLint pf_num_pages;
+
+};
+
+
+struct radeon_colorbuffer_state {
+       GLuint clear;
+       int roundEnable;
+       struct gl_renderbuffer *rb;
+       uint32_t draw_offset; /* offset into color renderbuffer - FBOs */
+};
+
+struct radeon_depthbuffer_state {
+       GLuint clear;
+       struct gl_renderbuffer *rb;
+};
+
+struct radeon_scissor_state {
+       drm_clip_rect_t rect;
+       GLboolean enabled;
+
+       GLuint numClipRects;    /* Cliprects active */
+       GLuint numAllocedClipRects;     /* Cliprects available */
+       drm_clip_rect_t *pClipRects;
+};
+
+struct radeon_stencilbuffer_state {
+       GLuint clear;           /* rb3d_stencilrefmask value */
+};
+
+struct radeon_stipple_state {
+       GLuint mask[32];
+};
+
+struct radeon_state_atom {
+       struct radeon_state_atom *next, *prev;
+       const char *name;       /* for debug */
+       int cmd_size;           /* size in bytes */
+        GLuint idx;
+       GLuint is_tcl;
+        GLuint *cmd;           /* one or more cmd's */
+       GLuint *lastcmd;                /* one or more cmd's */
+       GLboolean dirty;        /* dirty-mark in emit_state_list */
+        int (*check) (GLcontext *, struct radeon_state_atom *atom); /* is this state active? */
+        void (*emit) (GLcontext *, struct radeon_state_atom *atom);
+};
+
+struct radeon_hw_state {
+       /* Head of the linked list of state atoms. */
+       struct radeon_state_atom atomlist;
+       int max_state_size;     /* Number of bytes necessary for a full state emit. */
+       GLboolean is_dirty, all_dirty;
+};
+
+
+/* Texture related */
+typedef struct _radeon_texture_image radeon_texture_image;
+
+struct _radeon_texture_image {
+       struct gl_texture_image base;
+
+       /**
+        * If mt != 0, the image is stored in hardware format in the
+        * given mipmap tree. In this case, base.Data may point into the
+        * mapping of the buffer object that contains the mipmap tree.
+        *
+        * If mt == 0, the image is stored in normal memory pointed to
+        * by base.Data.
+        */
+       struct _radeon_mipmap_tree *mt;
+       struct radeon_bo *bo;
+
+       int mtlevel; /** if mt != 0, this is the image's level in the mipmap tree */
+       int mtface; /** if mt != 0, this is the image's face in the mipmap tree */
+};
+
+
+static INLINE radeon_texture_image *get_radeon_texture_image(struct gl_texture_image *image)
+{
+       return (radeon_texture_image*)image;
+}
+
+
+typedef struct radeon_tex_obj radeonTexObj, *radeonTexObjPtr;
+
+#define RADEON_TXO_MICRO_TILE               (1 << 3)
+
+/* Texture object in locally shared texture space.
+ */
+struct radeon_tex_obj {
+       struct gl_texture_object base;
+       struct _radeon_mipmap_tree *mt;
+
+       /**
+        * This is true if we've verified that the mipmap tree above is complete
+        * and so on.
+        */
+       GLboolean validated;
+
+       GLuint override_offset;
+       GLboolean image_override; /* Image overridden by GLX_EXT_tfp */
+       GLuint tile_bits;       /* hw texture tile bits used on this texture */
+        struct radeon_bo *bo;
+
+       GLuint pp_txfilter;     /* hardware register values */
+       GLuint pp_txformat;
+       GLuint pp_txformat_x;
+       GLuint pp_txsize;       /* npot only */
+       GLuint pp_txpitch;      /* npot only */
+       GLuint pp_border_color;
+       GLuint pp_cubic_faces;  /* cube face 1,2,3,4 log2 sizes */
+
+        GLuint pp_txfilter_1;  /*  r300 */
+
+       GLboolean border_fallback;
+
+
+};
+
+static INLINE radeonTexObj* radeon_tex_obj(struct gl_texture_object *texObj)
+{
+       return (radeonTexObj*)texObj;
+}
+
+/* Need refcounting on dma buffers:
+ */
+struct radeon_dma_buffer {
+       int refcount;           /* the number of retained regions in buf */
+       drmBufPtr buf;
+};
+
+struct radeon_aos {
+       struct radeon_bo *bo; /** Buffer object where vertex data is stored */
+       int offset; /** Offset into buffer object, in bytes */
+       int components; /** Number of components per vertex */
+       int stride; /** Stride in dwords (may be 0 for repeating) */
+       int count; /** Number of vertices */
+};
+
+struct radeon_dma {
+        /* Active dma region.  Allocations for vertices and retained
+         * regions come from here.  Also used for emitting random vertices,
+         * these may be flushed by calling flush_current();
+         */
+        struct radeon_bo *current; /** Buffer that DMA memory is allocated from */
+        int current_used; /** Number of bytes allocated and forgotten about */
+        int current_vertexptr; /** End of active vertex region */
+
+        /**
+         * If current_vertexptr != current_used then flush must be non-zero.
+         * flush must be called before non-active vertex allocations can be
+         * performed.
+         */
+        void (*flush) (GLcontext *);
+
+        /* Number of "in-flight" DMA buffers, i.e. the number of buffers
+         * for which a DISCARD command is currently queued in the command buffer
+.
+         */
+        GLuint nr_released_bufs;
+};
+
+/* radeon_swtcl.c
+ */
+struct radeon_swtcl_info {
+
+       GLuint RenderIndex;
+       GLuint vertex_size;
+       GLubyte *verts;
+
+       /* Fallback rasterization functions
+        */
+       GLuint hw_primitive;
+       GLenum render_primitive;
+       GLuint numverts;
+
+       struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
+       GLuint vertex_attr_count;
+
+};
+
+#define RADEON_MAX_AOS_ARRAYS          16
+struct radeon_tcl_info {
+       struct radeon_aos aos[RADEON_MAX_AOS_ARRAYS];
+       GLuint aos_count;
+       struct radeon_bo *elt_dma_bo; /** Buffer object that contains element indices */
+       int elt_dma_offset; /** Offset into this buffer object, in bytes */
+};
+
+struct radeon_ioctl {
+       GLuint vertex_offset;
+        struct radeon_bo *bo;
+       GLuint vertex_size;
+};
+
+#define RADEON_MAX_PRIMS 64
+
+struct radeon_prim {
+       GLuint start;
+       GLuint end;
+       GLuint prim;
+};
+
+static INLINE GLuint radeonPackColor(GLuint cpp,
+                                     GLubyte r, GLubyte g,
+                                     GLubyte b, GLubyte a)
+{
+       switch (cpp) {
+       case 2:
+               return PACK_COLOR_565(r, g, b);
+       case 4:
+               return PACK_COLOR_8888(a, r, g, b);
+       default:
+               return 0;
+       }
+}
+
+#define MAX_CMD_BUF_SZ (16*1024)
+
+#define MAX_DMA_BUF_SZ (64*1024)
+
+struct radeon_store {
+       GLuint statenr;
+       GLuint primnr;
+       char cmd_buf[MAX_CMD_BUF_SZ];
+       int cmd_used;
+       int elts_start;
+};
+
+struct radeon_dri_mirror {
+       __DRIcontextPrivate *context;   /* DRI context */
+       __DRIscreenPrivate *screen;     /* DRI screen */
+
+       drm_context_t hwContext;
+       drm_hw_lock_t *hwLock;
+       int fd;
+       int drmMinor;
+};
+
+#define DEBUG_TEXTURE  0x001
+#define DEBUG_STATE    0x002
+#define DEBUG_IOCTL    0x004
+#define DEBUG_PRIMS    0x008
+#define DEBUG_VERTS    0x010
+#define DEBUG_FALLBACKS        0x020
+#define DEBUG_VFMT     0x040
+#define DEBUG_CODEGEN  0x080
+#define DEBUG_VERBOSE  0x100
+#define DEBUG_DRI       0x200
+#define DEBUG_DMA       0x400
+#define DEBUG_SANITY    0x800
+#define DEBUG_SYNC      0x1000
+#define DEBUG_PIXEL     0x2000
+#define DEBUG_MEMORY    0x4000
+
+
+typedef void (*radeon_tri_func) (radeonContextPtr,
+                                radeonVertex *,
+                                radeonVertex *, radeonVertex *);
+
+typedef void (*radeon_line_func) (radeonContextPtr,
+                                 radeonVertex *, radeonVertex *);
+
+typedef void (*radeon_point_func) (radeonContextPtr, radeonVertex *);
+
+#define RADEON_MAX_BOS 32
+struct radeon_state {
+       struct radeon_colorbuffer_state color;
+       struct radeon_depthbuffer_state depth;
+       struct radeon_scissor_state scissor;
+       struct radeon_stencilbuffer_state stencil;
+
+       struct radeon_cs_space_check bos[RADEON_MAX_BOS];
+       int validated_bo_count;
+};
+
+/**
+ * This structure holds the command buffer while it is being constructed.
+ *
+ * The first batch of commands in the buffer is always the state that needs
+ * to be re-emitted when the context is lost. This batch can be skipped
+ * otherwise.
+ */
+struct radeon_cmdbuf {
+       struct radeon_cs_manager    *csm;
+       struct radeon_cs            *cs;
+       int size; /** # of dwords total */
+       unsigned int flushing:1; /** whether we're currently in FlushCmdBufLocked */
+};
+
+struct radeon_context {
+   GLcontext *glCtx;
+   radeonScreenPtr radeonScreen;       /* Screen private DRI data */
+
+   /* Texture object bookkeeping
+    */
+   int                   texture_depth;
+   float                 initialMaxAnisotropy;
+   uint32_t              texture_row_align;
+
+  struct radeon_dma dma;
+  struct radeon_hw_state hw;
+   /* Rasterization and vertex state:
+    */
+   GLuint TclFallback;
+   GLuint Fallback;
+   GLuint NewGLState;
+   DECLARE_RENDERINPUTS(tnl_index_bitset);     /* index of bits for last tnl_install_attrs */
+
+   /* Drawable, cliprect and scissor information */
+   GLuint numClipRects;        /* Cliprects for the draw buffer */
+   drm_clip_rect_t *pClipRects;
+   unsigned int lastStamp;
+   GLboolean lost_context;
+   drm_radeon_sarea_t *sarea;  /* Private SAREA data */
+
+   /* Mirrors of some DRI state */
+   struct radeon_dri_mirror dri;
+
+   /* Busy waiting */
+   GLuint do_usleeps;
+   GLuint do_irqs;
+   GLuint irqsEmitted;
+   drm_radeon_irq_wait_t iw;
+
+   /* Derived state - for r300 only */
+   struct radeon_state state;
+
+   struct radeon_swtcl_info swtcl;
+   struct radeon_tcl_info tcl;
+   /* Configuration cache
+    */
+   driOptionCache optionCache;
+
+   struct radeon_cmdbuf cmdbuf;
+
+  drm_clip_rect_t fboRect;
+  GLboolean constant_cliprect; /* use for FBO or DRI2 rendering */
+  GLboolean front_cliprects;
+
+   /**
+    * Set if rendering has occured to the drawable's front buffer.
+    *
+    * This is used in the DRI2 case to detect that glFlush should also copy
+    * the contents of the fake front buffer to the real front buffer.
+    */
+   GLboolean front_buffer_dirty;
+
+   /**
+    * Track whether front-buffer rendering is currently enabled
+    *
+    * A separate flag is used to track this in order to support MRT more
+    * easily.
+    */
+   GLboolean is_front_buffer_rendering;
+
+  struct {
+      struct gl_fragment_program *bitmap_fp;
+      struct gl_vertex_program *passthrough_vp;
+
+      struct gl_fragment_program *saved_fp;
+      GLboolean saved_fp_enable;
+      struct gl_vertex_program *saved_vp;
+      GLboolean saved_vp_enable;
+
+      GLint saved_vp_x, saved_vp_y;
+      GLsizei saved_vp_width, saved_vp_height;
+      GLenum saved_matrix_mode;
+   } meta;
+
+   struct {
+          void (*get_lock)(radeonContextPtr radeon);
+          void (*update_viewport_offset)(GLcontext *ctx);
+          void (*emit_cs_header)(struct radeon_cs *cs, radeonContextPtr rmesa);
+          void (*swtcl_flush)(GLcontext *ctx, uint32_t offset);
+          void (*pre_emit_atoms)(radeonContextPtr rmesa);
+          void (*pre_emit_state)(radeonContextPtr rmesa);
+          void (*fallback)(GLcontext *ctx, GLuint bit, GLboolean mode);
+          void (*free_context)(GLcontext *ctx);
+   } vtbl;
+};
+
+#define RADEON_CONTEXT(glctx) ((radeonContextPtr)(ctx->DriverCtx))
+
+static inline __DRIdrawablePrivate* radeon_get_drawable(radeonContextPtr radeon)
+{
+       return radeon->dri.context->driDrawablePriv;
+}
+
+static inline __DRIdrawablePrivate* radeon_get_readable(radeonContextPtr radeon)
+{
+       return radeon->dri.context->driReadablePriv;
+}
+
+
+/**
+ * This function takes a float and packs it into a uint32_t
+ */
+static INLINE uint32_t radeonPackFloat32(float fl)
+{
+       union {
+               float fl;
+               uint32_t u;
+       } u;
+
+       u.fl = fl;
+       return u.u;
+}
+
+/* This is probably wrong for some values, I need to test this
+ * some more.  Range checking would be a good idea also..
+ *
+ * But it works for most things.  I'll fix it later if someone
+ * else with a better clue doesn't
+ */
+static INLINE uint32_t radeonPackFloat24(float f)
+{
+       float mantissa;
+       int exponent;
+       uint32_t float24 = 0;
+
+       if (f == 0.0)
+               return 0;
+
+       mantissa = frexpf(f, &exponent);
+
+       /* Handle -ve */
+       if (mantissa < 0) {
+               float24 |= (1 << 23);
+               mantissa = mantissa * -1.0;
+       }
+       /* Handle exponent, bias of 63 */
+       exponent += 62;
+       float24 |= (exponent << 16);
+       /* Kill 7 LSB of mantissa */
+       float24 |= (radeonPackFloat32(mantissa) & 0x7FFFFF) >> 7;
+
+       return float24;
+}
+
+GLboolean radeonInitContext(radeonContextPtr radeon,
+                           struct dd_function_table* functions,
+                           const __GLcontextModes * glVisual,
+                           __DRIcontextPrivate * driContextPriv,
+                           void *sharedContextPrivate);
+
+void radeonCleanupContext(radeonContextPtr radeon);
+GLboolean radeonUnbindContext(__DRIcontextPrivate * driContextPriv);
+void radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable);
+GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
+                           __DRIdrawablePrivate * driDrawPriv,
+                           __DRIdrawablePrivate * driReadPriv);
+extern void radeonDestroyContext(__DRIcontextPrivate * driContextPriv);
+
+/* ================================================================
+ * Debugging:
+ */
+#define DO_DEBUG               1
+
+#if DO_DEBUG
+extern int RADEON_DEBUG;
+#else
+#define RADEON_DEBUG           0
+#endif
+
+#endif
diff --git a/src/mesa/drivers/dri/radeon/radeon_compat.c b/src/mesa/drivers/dri/radeon/radeon_compat.c
deleted file mode 100644 (file)
index 46b490d..0000000
+++ /dev/null
@@ -1,301 +0,0 @@
-/**************************************************************************
-
-Copyright 2002 ATI Technologies Inc., Ontario, Canada, and
-               Tungsten Graphics Inc., Austin, Texas.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, and/or sell copies of the Software, and to permit persons to whom
-the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-ATI, TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Keith Whitwell <keith@tungstengraphics.com>
- *
- */
-
-#include "main/glheader.h"
-#include "main/imports.h"
-
-#include "radeon_context.h"
-#include "radeon_state.h"
-#include "radeon_ioctl.h"
-
-
-static struct { 
-       int start; 
-       int len; 
-       const char *name;
-} packet[RADEON_MAX_STATE_PACKETS] = {
-       { RADEON_PP_MISC,7,"RADEON_PP_MISC" },
-       { RADEON_PP_CNTL,3,"RADEON_PP_CNTL" },
-       { RADEON_RB3D_COLORPITCH,1,"RADEON_RB3D_COLORPITCH" },
-       { RADEON_RE_LINE_PATTERN,2,"RADEON_RE_LINE_PATTERN" },
-       { RADEON_SE_LINE_WIDTH,1,"RADEON_SE_LINE_WIDTH" },
-       { RADEON_PP_LUM_MATRIX,1,"RADEON_PP_LUM_MATRIX" },
-       { RADEON_PP_ROT_MATRIX_0,2,"RADEON_PP_ROT_MATRIX_0" },
-       { RADEON_RB3D_STENCILREFMASK,3,"RADEON_RB3D_STENCILREFMASK" },
-       { RADEON_SE_VPORT_XSCALE,6,"RADEON_SE_VPORT_XSCALE" },
-       { RADEON_SE_CNTL,2,"RADEON_SE_CNTL" },
-       { RADEON_SE_CNTL_STATUS,1,"RADEON_SE_CNTL_STATUS" },
-       { RADEON_RE_MISC,1,"RADEON_RE_MISC" },
-       { RADEON_PP_TXFILTER_0,6,"RADEON_PP_TXFILTER_0" },
-       { RADEON_PP_BORDER_COLOR_0,1,"RADEON_PP_BORDER_COLOR_0" },
-       { RADEON_PP_TXFILTER_1,6,"RADEON_PP_TXFILTER_1" },
-       { RADEON_PP_BORDER_COLOR_1,1,"RADEON_PP_BORDER_COLOR_1" },
-       { RADEON_PP_TXFILTER_2,6,"RADEON_PP_TXFILTER_2" },
-       { RADEON_PP_BORDER_COLOR_2,1,"RADEON_PP_BORDER_COLOR_2" },
-       { RADEON_SE_ZBIAS_FACTOR,2,"RADEON_SE_ZBIAS_FACTOR" },
-       { RADEON_SE_TCL_OUTPUT_VTX_FMT,11,"RADEON_SE_TCL_OUTPUT_VTX_FMT" },
-       { RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED,17,"RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED" },
-};
-
-
-static void radeonCompatEmitPacket( radeonContextPtr rmesa, 
-                                   struct radeon_state_atom *state )
-{
-   drm_radeon_sarea_t *sarea = rmesa->sarea;
-   drm_radeon_context_regs_t *ctx = &sarea->context_state;
-   drm_radeon_texture_regs_t *tex0 = &sarea->tex_state[0];
-   drm_radeon_texture_regs_t *tex1 = &sarea->tex_state[1];
-   int i;
-   int *buf = state->cmd;
-
-   for ( i = 0 ; i < state->cmd_size ; ) {
-      drm_radeon_cmd_header_t *header = (drm_radeon_cmd_header_t *)&buf[i++];
-
-      if (RADEON_DEBUG & DEBUG_STATE)
-        fprintf(stderr, "%s %d: %s\n", __FUNCTION__, header->packet.packet_id,
-                packet[(int)header->packet.packet_id].name);
-
-      switch (header->packet.packet_id) {
-      case RADEON_EMIT_PP_MISC:
-        ctx->pp_misc = buf[i++]; 
-        ctx->pp_fog_color = buf[i++];
-        ctx->re_solid_color = buf[i++];
-        ctx->rb3d_blendcntl = buf[i++];
-        ctx->rb3d_depthoffset = buf[i++];
-        ctx->rb3d_depthpitch = buf[i++];
-        ctx->rb3d_zstencilcntl = buf[i++];
-        sarea->dirty |= RADEON_UPLOAD_CONTEXT;
-        break;
-      case RADEON_EMIT_PP_CNTL:
-        ctx->pp_cntl = buf[i++];
-        ctx->rb3d_cntl = buf[i++];
-        ctx->rb3d_coloroffset = buf[i++];
-        sarea->dirty |= RADEON_UPLOAD_CONTEXT;
-        break;
-      case RADEON_EMIT_RB3D_COLORPITCH:
-        ctx->rb3d_colorpitch = buf[i++];
-        sarea->dirty |= RADEON_UPLOAD_CONTEXT;
-        break;
-      case RADEON_EMIT_RE_LINE_PATTERN:
-        ctx->re_line_pattern = buf[i++];
-        ctx->re_line_state = buf[i++];
-        sarea->dirty |= RADEON_UPLOAD_LINE;
-        break;
-      case RADEON_EMIT_SE_LINE_WIDTH:
-        ctx->se_line_width = buf[i++];
-        sarea->dirty |= RADEON_UPLOAD_LINE;
-        break;
-      case RADEON_EMIT_PP_LUM_MATRIX:
-        ctx->pp_lum_matrix = buf[i++];
-        sarea->dirty |= RADEON_UPLOAD_BUMPMAP;
-        break;
-      case RADEON_EMIT_PP_ROT_MATRIX_0:
-        ctx->pp_rot_matrix_0 = buf[i++];
-        ctx->pp_rot_matrix_1 = buf[i++];
-        sarea->dirty |= RADEON_UPLOAD_BUMPMAP;
-        break;
-      case RADEON_EMIT_RB3D_STENCILREFMASK:
-        ctx->rb3d_stencilrefmask = buf[i++];
-        ctx->rb3d_ropcntl = buf[i++];
-        ctx->rb3d_planemask = buf[i++];
-        sarea->dirty |= RADEON_UPLOAD_MASKS;
-        break;
-      case RADEON_EMIT_SE_VPORT_XSCALE:
-        ctx->se_vport_xscale = buf[i++];
-        ctx->se_vport_xoffset = buf[i++];
-        ctx->se_vport_yscale = buf[i++];
-        ctx->se_vport_yoffset = buf[i++];
-        ctx->se_vport_zscale = buf[i++];
-        ctx->se_vport_zoffset = buf[i++];
-        sarea->dirty |= RADEON_UPLOAD_VIEWPORT;
-        break;
-      case RADEON_EMIT_SE_CNTL:
-        ctx->se_cntl = buf[i++];
-        ctx->se_coord_fmt = buf[i++];
-        sarea->dirty |= RADEON_UPLOAD_CONTEXT | RADEON_UPLOAD_VERTFMT;
-        break;
-      case RADEON_EMIT_SE_CNTL_STATUS:
-        ctx->se_cntl_status = buf[i++];
-        sarea->dirty |= RADEON_UPLOAD_SETUP;
-        break;
-      case RADEON_EMIT_RE_MISC:
-        ctx->re_misc = buf[i++];
-        sarea->dirty |= RADEON_UPLOAD_MISC;
-        break;
-      case RADEON_EMIT_PP_TXFILTER_0:
-        tex0->pp_txfilter = buf[i++];
-        tex0->pp_txformat = buf[i++];
-        tex0->pp_txoffset = buf[i++];
-        tex0->pp_txcblend = buf[i++];
-        tex0->pp_txablend = buf[i++];
-        tex0->pp_tfactor = buf[i++];
-        sarea->dirty |= RADEON_UPLOAD_TEX0;
-        break;
-      case RADEON_EMIT_PP_BORDER_COLOR_0:
-        tex0->pp_border_color = buf[i++];
-        sarea->dirty |= RADEON_UPLOAD_TEX0;
-        break;
-      case RADEON_EMIT_PP_TXFILTER_1:
-        tex1->pp_txfilter = buf[i++];
-        tex1->pp_txformat = buf[i++];
-        tex1->pp_txoffset = buf[i++];
-        tex1->pp_txcblend = buf[i++];
-        tex1->pp_txablend = buf[i++];
-        tex1->pp_tfactor = buf[i++];
-        sarea->dirty |= RADEON_UPLOAD_TEX1;
-        break;
-      case RADEON_EMIT_PP_BORDER_COLOR_1:
-        tex1->pp_border_color = buf[i++];
-        sarea->dirty |= RADEON_UPLOAD_TEX1;
-        break;
-
-      case RADEON_EMIT_SE_ZBIAS_FACTOR:
-        i++;
-        i++;
-        break;
-
-      case RADEON_EMIT_PP_TXFILTER_2:
-      case RADEON_EMIT_PP_BORDER_COLOR_2:
-      case RADEON_EMIT_SE_TCL_OUTPUT_VTX_FMT:
-      case RADEON_EMIT_SE_TCL_MATERIAL_EMMISSIVE_RED:
-      default:
-        /* These states aren't understood by radeon drm 1.1 */
-        fprintf(stderr, "Tried to emit unsupported state\n");
-        return;
-      }
-   }
-}
-
-
-
-static void radeonCompatEmitStateLocked( radeonContextPtr rmesa )
-{
-   struct radeon_state_atom *atom;
-
-   if (RADEON_DEBUG & (DEBUG_STATE|DEBUG_PRIMS))
-      fprintf(stderr, "%s\n", __FUNCTION__);
-
-   if (!rmesa->hw.is_dirty && !rmesa->hw.all_dirty)
-      return;
-
-   foreach(atom, &rmesa->hw.atomlist) {
-      if (rmesa->hw.all_dirty)
-        atom->dirty = GL_TRUE;
-      if (atom->is_tcl)
-        atom->dirty = GL_FALSE;
-      if (atom->dirty)
-        radeonCompatEmitPacket(rmesa, atom);
-   }
-   rmesa->hw.is_dirty = GL_FALSE;
-   rmesa->hw.all_dirty = GL_FALSE;
-}
-
-
-static void radeonCompatEmitPrimitiveLocked( radeonContextPtr rmesa,
-                                            GLuint hw_primitive,
-                                            GLuint nverts,
-                                            drm_clip_rect_t *pbox,
-                                            GLuint nbox )
-{
-   int i;
-
-   for ( i = 0 ; i < nbox ; ) {
-      int nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS, nbox );
-      drm_clip_rect_t *b = rmesa->sarea->boxes;
-      drm_radeon_vertex_t vtx;
-      
-      rmesa->sarea->dirty |= RADEON_UPLOAD_CLIPRECTS;
-      rmesa->sarea->nbox = nr - i;
-
-      for ( ; i < nr ; i++) 
-        *b++ = pbox[i];
-      
-      if (RADEON_DEBUG & DEBUG_IOCTL)
-        fprintf(stderr, 
-                "RadeonFlushVertexBuffer: prim %x buf %d verts %d "
-                "disc %d nbox %d\n",
-                hw_primitive, 
-                rmesa->dma.current.buf->buf->idx, 
-                nverts, 
-                nr == nbox,
-                rmesa->sarea->nbox );
-
-      vtx.prim = hw_primitive;
-      vtx.idx = rmesa->dma.current.buf->buf->idx;
-      vtx.count = nverts;
-      vtx.discard = (nr == nbox);      
-
-      drmCommandWrite( rmesa->dri.fd, 
-                      DRM_RADEON_VERTEX,
-                      &vtx, sizeof(vtx));
-   }
-}
-
-
-
-/* No 'start' for 1.1 vertices ioctl: only one vertex prim/buffer!  
- */
-void radeonCompatEmitPrimitive( radeonContextPtr rmesa,
-                               GLuint vertex_format,
-                               GLuint hw_primitive,
-                               GLuint nrverts )
-{
-   if (RADEON_DEBUG & DEBUG_IOCTL)
-      fprintf(stderr, "%s\n", __FUNCTION__);
-
-   LOCK_HARDWARE( rmesa );
-
-   radeonCompatEmitStateLocked( rmesa );
-   rmesa->sarea->vc_format = vertex_format;
-   
-   if (rmesa->state.scissor.enabled) {
-      radeonCompatEmitPrimitiveLocked( rmesa, 
-                                      hw_primitive,
-                                      nrverts,
-                                      rmesa->state.scissor.pClipRects,
-                                      rmesa->state.scissor.numClipRects );
-   }
-   else {
-      radeonCompatEmitPrimitiveLocked( rmesa, 
-                                      hw_primitive,
-                                      nrverts,
-                                      rmesa->pClipRects,
-                                      rmesa->numClipRects );
-   }
-
-
-   UNLOCK_HARDWARE( rmesa );
-}
-
index ea81a3250b785a68ef183146686da5d569a71202..8f780c443c914e6248069f98067ce6ab2099be45 100644 (file)
@@ -53,6 +53,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "drivers/common/driverfuncs.h"
 
+#include "radeon_common.h"
 #include "radeon_context.h"
 #include "radeon_ioctl.h"
 #include "radeon_state.h"
@@ -65,6 +66,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define need_GL_EXT_blend_minmax
 #define need_GL_EXT_fog_coord
 #define need_GL_EXT_secondary_color
+#define need_GL_EXT_framebuffer_object
 #include "extension_helper.h"
 
 #define DRIVER_DATE    "20061018"
@@ -72,40 +74,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "vblank.h"
 #include "utils.h"
 #include "xmlpool.h" /* for symbolic values of enum-type options */
-#ifndef RADEON_DEBUG
-int RADEON_DEBUG = (0);
-#endif
-
-
-/* Return various strings for glGetString().
- */
-static const GLubyte *radeonGetString( GLcontext *ctx, GLenum name )
-{
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-   static char buffer[128];
-   unsigned   offset;
-   GLuint agp_mode = (rmesa->radeonScreen->card_type==RADEON_CARD_PCI) ? 0 :
-      rmesa->radeonScreen->AGPMode;
-
-   switch ( name ) {
-   case GL_VENDOR:
-      return (GLubyte *)"Tungsten Graphics, Inc.";
-
-   case GL_RENDERER:
-      offset = driGetRendererString( buffer, "Radeon", DRIVER_DATE,
-                                    agp_mode );
-
-      sprintf( & buffer[ offset ], " %sTCL",
-              !(rmesa->TclFallback & RADEON_TCL_FALLBACK_TCL_DISABLE)
-              ? "" : "NO-" );
-
-      return (GLubyte *)buffer;
-
-   default:
-      return NULL;
-   }
-}
-
 
 /* Extension strings exported by the R100 driver.
  */
@@ -121,6 +89,7 @@ const struct dri_extension card_extensions[] =
     { "GL_EXT_blend_logic_op",             NULL },
     { "GL_EXT_blend_subtract",             GL_EXT_blend_minmax_functions },
     { "GL_EXT_fog_coord",                  GL_EXT_fog_coord_functions },
+    { "GL_EXT_packed_depth_stencil",      NULL},
     { "GL_EXT_secondary_color",            GL_EXT_secondary_color_functions },
     { "GL_EXT_stencil_wrap",               NULL },
     { "GL_EXT_texture_edge_clamp",         NULL },
@@ -137,6 +106,11 @@ const struct dri_extension card_extensions[] =
     { NULL,                                NULL }
 };
 
+const struct dri_extension mm_extensions[] = {
+  { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions },
+  { NULL, NULL }
+};
+
 extern const struct tnl_pipeline_stage _radeon_render_stage;
 extern const struct tnl_pipeline_stage _radeon_tcl_stage;
 
@@ -160,15 +134,6 @@ static const struct tnl_pipeline_stage *radeon_pipeline[] = {
    NULL,
 };
 
-
-
-/* Initialize the driver's misc functions.
- */
-static void radeonInitDriverFuncs( struct dd_function_table *functions )
-{
-    functions->GetString       = radeonGetString;
-}
-
 static const struct dri_debug_control debug_control[] =
 {
     { "fall",  DEBUG_FALLBACKS },
@@ -188,19 +153,69 @@ static const struct dri_debug_control debug_control[] =
     { NULL,    0 }
 };
 
+static void r100_get_lock(radeonContextPtr radeon)
+{
+   r100ContextPtr rmesa = (r100ContextPtr)radeon;
+   drm_radeon_sarea_t *sarea = radeon->sarea;
+
+   RADEON_STATECHANGE(rmesa, ctx);
+   if (rmesa->radeon.sarea->tiling_enabled) {
+      rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |=
+        RADEON_COLOR_TILE_ENABLE;
+   } else {
+      rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] &=
+        ~RADEON_COLOR_TILE_ENABLE;
+   }
+   
+   if (sarea->ctx_owner != rmesa->radeon.dri.hwContext) {
+      sarea->ctx_owner = rmesa->radeon.dri.hwContext;
+      
+      if (!radeon->radeonScreen->kernel_mm)
+         radeon_bo_legacy_texture_age(radeon->radeonScreen->bom);
+   }
+}
+
+static void r100_vtbl_emit_cs_header(struct radeon_cs *cs, radeonContextPtr rmesa)
+{
+}
+
+static void r100_vtbl_pre_emit_state(radeonContextPtr radeon)
+{
+   r100ContextPtr rmesa = (r100ContextPtr)radeon;
+   
+   /* r100 always needs to emit ZBS to avoid TCL lockups */
+   rmesa->hw.zbs.dirty = 1;
+   radeon->hw.is_dirty = 1;
+}
+
+static void r100_vtbl_free_context(GLcontext *ctx)
+{
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
+   _mesa_vector4f_free( &rmesa->tcl.ObjClean );
+}
+
+static void r100_init_vtbl(radeonContextPtr radeon)
+{
+   radeon->vtbl.get_lock = r100_get_lock;
+   radeon->vtbl.update_viewport_offset = radeonUpdateViewportOffset;
+   radeon->vtbl.emit_cs_header = r100_vtbl_emit_cs_header;
+   radeon->vtbl.swtcl_flush = r100_swtcl_flush;
+   radeon->vtbl.pre_emit_state = r100_vtbl_pre_emit_state;
+   radeon->vtbl.fallback = radeonFallback;
+}
 
 /* Create the device specific context.
  */
 GLboolean
-radeonCreateContext( const __GLcontextModes *glVisual,
+r100CreateContext( const __GLcontextModes *glVisual,
                      __DRIcontextPrivate *driContextPriv,
                      void *sharedContextPrivate)
 {
    __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
    radeonScreenPtr screen = (radeonScreenPtr)(sPriv->private);
    struct dd_function_table functions;
-   radeonContextPtr rmesa;
-   GLcontext *ctx, *shareCtx;
+   r100ContextPtr rmesa;
+   GLcontext *ctx;
    int i;
    int tcl_mode, fthrottle_mode;
 
@@ -209,10 +224,12 @@ radeonCreateContext( const __GLcontextModes *glVisual,
    assert(screen);
 
    /* Allocate the Radeon context */
-   rmesa = (radeonContextPtr) CALLOC( sizeof(*rmesa) );
+   rmesa = (r100ContextPtr) CALLOC( sizeof(*rmesa) );
    if ( !rmesa )
       return GL_FALSE;
 
+   r100_init_vtbl(&rmesa->radeon);
+
    /* init exp fog table data */
    radeonInitStaticFogData();
    
@@ -220,12 +237,12 @@ radeonCreateContext( const __GLcontextModes *glVisual,
     * Do this here so that initialMaxAnisotropy is set before we create
     * the default textures.
     */
-   driParseConfigFiles (&rmesa->optionCache, &screen->optionCache,
+   driParseConfigFiles (&rmesa->radeon.optionCache, &screen->optionCache,
                        screen->driScreen->myNum, "radeon");
-   rmesa->initialMaxAnisotropy = driQueryOptionf(&rmesa->optionCache,
+   rmesa->radeon.initialMaxAnisotropy = driQueryOptionf(&rmesa->radeon.optionCache,
                                                  "def_max_anisotropy");
 
-   if ( driQueryOptionb( &rmesa->optionCache, "hyperz" ) ) {
+   if ( driQueryOptionb( &rmesa->radeon.optionCache, "hyperz" ) ) {
       if ( sPriv->drm_version.minor < 13 )
         fprintf( stderr, "DRM version 1.%d too old to support HyperZ, "
                          "disabling.\n", sPriv->drm_version.minor );
@@ -240,65 +257,17 @@ radeonCreateContext( const __GLcontextModes *glVisual,
     * (the texture functions are especially important)
     */
    _mesa_init_driver_functions( &functions );
-   radeonInitDriverFuncs( &functions );
    radeonInitTextureFuncs( &functions );
 
-   /* Allocate the Mesa context */
-   if (sharedContextPrivate)
-      shareCtx = ((radeonContextPtr) sharedContextPrivate)->glCtx;
-   else
-      shareCtx = NULL;
-   rmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
-                                       &functions, (void *) rmesa);
-   if (!rmesa->glCtx) {
-      FREE(rmesa);
-      return GL_FALSE;
-   }
-   driContextPriv->driverPrivate = rmesa;
-
-   /* Init radeon context data */
-   rmesa->dri.context = driContextPriv;
-   rmesa->dri.screen = sPriv;
-   rmesa->dri.drawable = NULL;
-   rmesa->dri.readable = NULL;
-   rmesa->dri.hwContext = driContextPriv->hHWContext;
-   rmesa->dri.hwLock = &sPriv->pSAREA->lock;
-   rmesa->dri.fd = sPriv->fd;
-   rmesa->dri.drmMinor = sPriv->drm_version.minor;
-
-   rmesa->radeonScreen = screen;
-   rmesa->sarea = (drm_radeon_sarea_t *)((GLubyte *)sPriv->pSAREA +
-                                      screen->sarea_priv_offset);
-
-
-   rmesa->dma.buf0_address = rmesa->radeonScreen->buffers->list[0].address;
-
-   (void) memset( rmesa->texture_heaps, 0, sizeof( rmesa->texture_heaps ) );
-   make_empty_list( & rmesa->swapped );
-
-   rmesa->nr_heaps = screen->numTexHeaps;
-   for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
-      rmesa->texture_heaps[i] = driCreateTextureHeap( i, rmesa,
-           screen->texSize[i],
-           12,
-           RADEON_NR_TEX_REGIONS,
-           (drmTextureRegionPtr)rmesa->sarea->tex_list[i],
-           & rmesa->sarea->tex_age[i],
-           & rmesa->swapped,
-           sizeof( radeonTexObj ),
-           (destroy_texture_object_t *) radeonDestroyTexObj );
-
-      driSetTextureSwapCounterLocation( rmesa->texture_heaps[i],
-                                       & rmesa->c_textureSwaps );
+   if (!radeonInitContext(&rmesa->radeon, &functions,
+                         glVisual, driContextPriv,
+                         sharedContextPrivate)) {
+     FREE(rmesa);
+     return GL_FALSE;
    }
-   rmesa->texture_depth = driQueryOptioni (&rmesa->optionCache,
-                                          "texture_depth");
-   if (rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
-      rmesa->texture_depth = ( screen->cpp == 4 ) ?
-        DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
 
-   rmesa->swtcl.RenderIndex = ~0;
-   rmesa->hw.all_dirty = GL_TRUE;
+   rmesa->radeon.swtcl.RenderIndex = ~0;
+   rmesa->radeon.hw.all_dirty = GL_TRUE;
 
    /* Set the maximum texture size small enough that we can guarentee that
     * all texture units can bind a maximal texture and have all of them in
@@ -306,26 +275,18 @@ radeonCreateContext( const __GLcontextModes *glVisual,
     * setting allow larger textures.
     */
 
-   ctx = rmesa->glCtx;
-   ctx->Const.MaxTextureUnits = driQueryOptioni (&rmesa->optionCache,
+   ctx = rmesa->radeon.glCtx;
+   ctx->Const.MaxTextureUnits = driQueryOptioni (&rmesa->radeon.optionCache,
                                                 "texture_units");
    ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits;
    ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits;
 
-   i = driQueryOptioni( &rmesa->optionCache, "allow_large_textures");
-
-   driCalculateMaxTextureLevels( rmesa->texture_heaps,
-                                rmesa->nr_heaps,
-                                & ctx->Const,
-                                4,
-                                11, /* max 2D texture size is 2048x2048 */
-                                8,  /* 256^3 */
-                                9,  /* \todo: max cube texture size seems to be 512x512(x6) */
-                                11, /* max rect texture size is 2048x2048. */
-                                12,
-                                GL_FALSE,
-                                i );
+   i = driQueryOptioni( &rmesa->radeon.optionCache, "allow_large_textures");
 
+   /* FIXME: When no memory manager is available we should set this 
+    * to some reasonable value based on texture memory pool size */
+   /* FIXME: does r100 support 2048x2048 texture ? */
+   ctx->Const.MaxTextureLevels = 12;
 
    ctx->Const.MaxTextureMaxAnisotropy = 16.0;
 
@@ -388,38 +349,39 @@ radeonCreateContext( const __GLcontextModes *glVisual,
    }
 
    driInitExtensions( ctx, card_extensions, GL_TRUE );
-   if (rmesa->radeonScreen->drmSupportsCubeMapsR100)
+   if (rmesa->radeon.radeonScreen->kernel_mm)
+     driInitExtensions(ctx, mm_extensions, GL_FALSE);
+   if (rmesa->radeon.radeonScreen->drmSupportsCubeMapsR100)
       _mesa_enable_extension( ctx, "GL_ARB_texture_cube_map" );
-   if (rmesa->glCtx->Mesa_DXTn) {
+   if (rmesa->radeon.glCtx->Mesa_DXTn) {
       _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
       _mesa_enable_extension( ctx, "GL_S3_s3tc" );
    }
-   else if (driQueryOptionb (&rmesa->optionCache, "force_s3tc_enable")) {
+   else if (driQueryOptionb (&rmesa->radeon.optionCache, "force_s3tc_enable")) {
       _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
    }
 
-   if (rmesa->dri.drmMinor >= 9)
+   if (rmesa->radeon.dri.drmMinor >= 9)
       _mesa_enable_extension( ctx, "GL_NV_texture_rectangle");
 
    /* XXX these should really go right after _mesa_init_driver_functions() */
+   radeon_fbo_init(&rmesa->radeon);
+   radeonInitSpanFuncs( ctx );
    radeonInitIoctlFuncs( ctx );
    radeonInitStateFuncs( ctx );
-   radeonInitSpanFuncs( ctx );
    radeonInitState( rmesa );
    radeonInitSwtcl( ctx );
 
    _mesa_vector4f_alloc( &rmesa->tcl.ObjClean, 0, 
                         ctx->Const.MaxArrayLockSize, 32 );
 
-   fthrottle_mode = driQueryOptioni(&rmesa->optionCache, "fthrottle_mode");
-   rmesa->iw.irq_seq = -1;
-   rmesa->irqsEmitted = 0;
-   rmesa->do_irqs = (rmesa->radeonScreen->irq != 0 &&
-                    fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS);
-
-   rmesa->do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS);
+   fthrottle_mode = driQueryOptioni(&rmesa->radeon.optionCache, "fthrottle_mode");
+   rmesa->radeon.iw.irq_seq = -1;
+   rmesa->radeon.irqsEmitted = 0;
+   rmesa->radeon.do_irqs = (rmesa->radeon.radeonScreen->irq != 0 &&
+                           fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS);
 
-   (*sPriv->systemTime->getUST)( & rmesa->swap_ust );
+   rmesa->radeon.do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS);
 
 
 #if DO_DEBUG
@@ -427,206 +389,21 @@ radeonCreateContext( const __GLcontextModes *glVisual,
                                       debug_control );
 #endif
 
-   tcl_mode = driQueryOptioni(&rmesa->optionCache, "tcl_mode");
-   if (driQueryOptionb(&rmesa->optionCache, "no_rast")) {
+   tcl_mode = driQueryOptioni(&rmesa->radeon.optionCache, "tcl_mode");
+   if (driQueryOptionb(&rmesa->radeon.optionCache, "no_rast")) {
       fprintf(stderr, "disabling 3D acceleration\n");
       FALLBACK(rmesa, RADEON_FALLBACK_DISABLE, 1);
    } else if (tcl_mode == DRI_CONF_TCL_SW ||
-             !(rmesa->radeonScreen->chip_flags & RADEON_CHIPSET_TCL)) {
-      if (rmesa->radeonScreen->chip_flags & RADEON_CHIPSET_TCL) {
-        rmesa->radeonScreen->chip_flags &= ~RADEON_CHIPSET_TCL;
+             !(rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL)) {
+      if (rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL) {
+        rmesa->radeon.radeonScreen->chip_flags &= ~RADEON_CHIPSET_TCL;
         fprintf(stderr, "Disabling HW TCL support\n");
       }
-      TCL_FALLBACK(rmesa->glCtx, RADEON_TCL_FALLBACK_TCL_DISABLE, 1);
+      TCL_FALLBACK(rmesa->radeon.glCtx, RADEON_TCL_FALLBACK_TCL_DISABLE, 1);
    }
 
-   if (rmesa->radeonScreen->chip_flags & RADEON_CHIPSET_TCL) {
+   if (rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL) {
 /*       _tnl_need_dlist_norm_lengths( ctx, GL_FALSE ); */
    }
    return GL_TRUE;
 }
-
-
-/* Destroy the device specific context.
- */
-/* Destroy the Mesa and driver specific context data.
- */
-void radeonDestroyContext( __DRIcontextPrivate *driContextPriv )
-{
-   GET_CURRENT_CONTEXT(ctx);
-   radeonContextPtr rmesa = (radeonContextPtr) driContextPriv->driverPrivate;
-   radeonContextPtr current = ctx ? RADEON_CONTEXT(ctx) : NULL;
-
-   /* check if we're deleting the currently bound context */
-   if (rmesa == current) {
-      RADEON_FIREVERTICES( rmesa );
-      _mesa_make_current(NULL, NULL, NULL);
-   }
-
-   /* Free radeon context resources */
-   assert(rmesa); /* should never be null */
-   if ( rmesa ) {
-      GLboolean   release_texture_heaps;
-
-
-      release_texture_heaps = (rmesa->glCtx->Shared->RefCount == 1);
-      _swsetup_DestroyContext( rmesa->glCtx );
-      _tnl_DestroyContext( rmesa->glCtx );
-      _vbo_DestroyContext( rmesa->glCtx );
-      _swrast_DestroyContext( rmesa->glCtx );
-
-      radeonDestroySwtcl( rmesa->glCtx );
-      radeonReleaseArrays( rmesa->glCtx, ~0 );
-      if (rmesa->dma.current.buf) {
-        radeonReleaseDmaRegion( rmesa, &rmesa->dma.current, __FUNCTION__ );
-        radeonFlushCmdBuf( rmesa, __FUNCTION__ );
-      }
-
-      _mesa_vector4f_free( &rmesa->tcl.ObjClean );
-
-      if (rmesa->state.scissor.pClipRects) {
-        FREE(rmesa->state.scissor.pClipRects);
-        rmesa->state.scissor.pClipRects = NULL;
-      }
-
-      if ( release_texture_heaps ) {
-         /* This share group is about to go away, free our private
-          * texture object data.
-          */
-         int i;
-
-         for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
-           driDestroyTextureHeap( rmesa->texture_heaps[ i ] );
-           rmesa->texture_heaps[ i ] = NULL;
-         }
-
-        assert( is_empty_list( & rmesa->swapped ) );
-      }
-
-      /* free the Mesa context */
-      rmesa->glCtx->DriverCtx = NULL;
-      _mesa_destroy_context( rmesa->glCtx );
-
-      /* free the option cache */
-      driDestroyOptionCache (&rmesa->optionCache);
-
-      FREE( rmesa );
-   }
-}
-
-
-
-
-void
-radeonSwapBuffers( __DRIdrawablePrivate *dPriv )
-{
-
-   if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
-      radeonContextPtr rmesa;
-      GLcontext *ctx;
-      rmesa = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
-      ctx = rmesa->glCtx;
-      if (ctx->Visual.doubleBufferMode) {
-         _mesa_notifySwapBuffers( ctx );  /* flush pending rendering comands */
-
-         if ( rmesa->doPageFlip ) {
-            radeonPageFlip( dPriv );
-         }
-         else {
-            radeonCopyBuffer( dPriv, NULL );
-         }
-      }
-   }
-   else {
-      /* XXX this shouldn't be an error but we can't handle it for now */
-      _mesa_problem(NULL, "%s: drawable has no context!", __FUNCTION__);
-   }
-}
-
-void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
-                        int x, int y, int w, int h )
-{
-    if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
-       radeonContextPtr radeon;
-       GLcontext *ctx;
-
-       radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
-       ctx = radeon->glCtx;
-
-       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 */
-           radeonCopyBuffer(dPriv, &rect);
-       }
-    } else {
-       /* XXX this shouldn't be an error but we can't handle it for now */
-       _mesa_problem(NULL, "%s: drawable has no context!",
-                     __FUNCTION__);
-    }
-}
-
-/* Make context `c' the current context and bind it to the given
- * drawing and reading surfaces.
- */
-GLboolean
-radeonMakeCurrent( __DRIcontextPrivate *driContextPriv,
-                   __DRIdrawablePrivate *driDrawPriv,
-                   __DRIdrawablePrivate *driReadPriv )
-{
-   if ( driContextPriv ) {
-      radeonContextPtr newCtx = 
-        (radeonContextPtr) driContextPriv->driverPrivate;
-
-      if (RADEON_DEBUG & DEBUG_DRI)
-        fprintf(stderr, "%s ctx %p\n", __FUNCTION__, (void *) newCtx->glCtx);
-
-      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);
-        radeonUpdateViewportOffset( newCtx->glCtx );
-      }
-
-      _mesa_make_current( newCtx->glCtx,
-                         (GLframebuffer *) driDrawPriv->driverPrivate,
-                         (GLframebuffer *) driReadPriv->driverPrivate );
-
-      _mesa_update_state( newCtx->glCtx );
-   } else {
-      if (RADEON_DEBUG & DEBUG_DRI)
-        fprintf(stderr, "%s ctx is null\n", __FUNCTION__);
-      _mesa_make_current( NULL, NULL, NULL );
-   }
-
-   if (RADEON_DEBUG & DEBUG_DRI)
-      fprintf(stderr, "End %s\n", __FUNCTION__);
-   return GL_TRUE;
-}
-
-/* Force the context `c' to be unbound from its buffer.
- */
-GLboolean
-radeonUnbindContext( __DRIcontextPrivate *driContextPriv )
-{
-   radeonContextPtr rmesa = (radeonContextPtr) driContextPriv->driverPrivate;
-
-   if (RADEON_DEBUG & DEBUG_DRI)
-      fprintf(stderr, "%s ctx %p\n", __FUNCTION__, (void *) rmesa->glCtx);
-
-   return GL_TRUE;
-}
index 53df766f8cbe7aa627b493992842034b160a190a..1795d8bdb6d496d1f7da4e593572eed29943f203 100644 (file)
@@ -48,91 +48,23 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "drm.h"
 #include "radeon_drm.h"
 #include "texmem.h"
-
 #include "main/macros.h"
 #include "main/mtypes.h"
 #include "main/colormac.h"
-
-struct radeon_context;
-typedef struct radeon_context radeonContextRec;
-typedef struct radeon_context *radeonContextPtr;
-
-/* This union is used to avoid warnings/miscompilation
-   with float to uint32_t casts due to strict-aliasing */
-typedef union {
-       GLfloat f;
-       uint32_t ui32;
-} float_ui32_type;
-
-#include "radeon_lock.h"
 #include "radeon_screen.h"
-#include "main/mm.h"
-
-#include "math/m_vector.h"
-
-#define TEX_0   0x1
-#define TEX_1   0x2
-#define TEX_2   0x4
-#define TEX_ALL 0x7
-
-/* Rasterizing fallbacks */
-/* See correponding strings in r200_swtcl.c */
-#define RADEON_FALLBACK_TEXTURE                0x0001
-#define RADEON_FALLBACK_DRAW_BUFFER    0x0002
-#define RADEON_FALLBACK_STENCIL                0x0004
-#define RADEON_FALLBACK_RENDER_MODE    0x0008
-#define RADEON_FALLBACK_BLEND_EQ       0x0010
-#define RADEON_FALLBACK_BLEND_FUNC     0x0020
-#define RADEON_FALLBACK_DISABLE        0x0040
-#define RADEON_FALLBACK_BORDER_MODE    0x0080
-
-/* The blit width for texture uploads
- */
-#define BLIT_WIDTH_BYTES 1024
 
-/* Use the templated vertex format:
- */
-#define COLOR_IS_RGBA
-#define TAG(x) radeon##x
-#include "tnl_dd/t_dd_vertex.h"
-#undef TAG
-
-typedef void (*radeon_tri_func) (radeonContextPtr,
-                                radeonVertex *,
-                                radeonVertex *, radeonVertex *);
-
-typedef void (*radeon_line_func) (radeonContextPtr,
-                                 radeonVertex *, radeonVertex *);
+#include "radeon_common.h"
 
-typedef void (*radeon_point_func) (radeonContextPtr, radeonVertex *);
-
-struct radeon_colorbuffer_state {
-       GLuint clear;
-       int roundEnable;
-};
 
-struct radeon_depthbuffer_state {
-       GLuint clear;
-       GLfloat scale;
-};
+struct r100_context;
+typedef struct r100_context r100ContextRec;
+typedef struct r100_context *r100ContextPtr;
 
-struct radeon_scissor_state {
-       drm_clip_rect_t rect;
-       GLboolean enabled;
+#include "radeon_lock.h"
 
-       GLuint numClipRects;    /* Cliprects active */
-       GLuint numAllocedClipRects;     /* Cliprects available */
-       drm_clip_rect_t *pClipRects;
-};
 
-struct radeon_stencilbuffer_state {
-       GLboolean hwBuffer;
-       GLuint clear;           /* rb3d_stencilrefmask value */
-};
 
-struct radeon_stipple_state {
-       GLuint mask[32];
-};
+#define R100_TEX_ALL 0x7
 
 /* used for both tcl_vtx and vc_frmt tex bits (they are identical) */
 #define RADEON_ST_BIT(unit) \
@@ -141,42 +73,6 @@ struct radeon_stipple_state {
 #define RADEON_Q_BIT(unit) \
 (unit == 0 ? RADEON_CP_VC_FRMT_Q0 : (RADEON_CP_VC_FRMT_Q1 >> 2) << (2 * unit))
 
-typedef struct radeon_tex_obj radeonTexObj, *radeonTexObjPtr;
-
-/* Texture object in locally shared texture space.
- */
-struct radeon_tex_obj {
-       driTextureObject base;
-
-       GLuint bufAddr;         /* Offset to start of locally
-                                  shared texture block */
-
-       GLuint dirty_state;     /* Flags (1 per texunit) for
-                                  whether or not this texobj
-                                  has dirty hardware state
-                                  (pp_*) that needs to be
-                                  brought into the
-                                  texunit. */
-
-       drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS];
-       /* Six, for the cube faces */
-
-       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.
-                                  All cube faces follow. */
-       GLuint pp_txsize;       /* npot only */
-       GLuint pp_txpitch;      /* npot only */
-       GLuint pp_border_color;
-       GLuint pp_cubic_faces;  /* cube face 1,2,3,4 log2 sizes */
-
-       GLboolean border_fallback;
-
-       GLuint tile_bits;       /* hw texture tile bits used on this texture */
-};
-
 struct radeon_texture_env_state {
        radeonTexObjPtr texobj;
        GLenum format;
@@ -187,17 +83,6 @@ struct radeon_texture_state {
        struct radeon_texture_env_state unit[RADEON_MAX_TEXTURE_UNITS];
 };
 
-struct radeon_state_atom {
-       struct radeon_state_atom *next, *prev;
-       const char *name;       /* for debug */
-       int cmd_size;           /* size in bytes */
-       GLuint is_tcl;
-       int *cmd;               /* one or more cmd's */
-       int *lastcmd;           /* one or more cmd's */
-       GLboolean dirty;        /* dirty-mark in emit_state_list */
-        GLboolean(*check) (GLcontext *);       /* is this state active? */
-};
-
 /* Trying to keep these relatively short as the variables are becoming
  * extravagently long.  Drop the driver name prefix off the front of
  * everything - I think we know which driver we're in by now, and keep the
@@ -410,10 +295,7 @@ struct radeon_state_atom {
 #define SHN_SHININESS      1
 #define SHN_STATE_SIZE     2
 
-struct radeon_hw_state {
-       /* Head of the linked list of state atoms. */
-       struct radeon_state_atom atomlist;
-
+struct r100_hw_state {
        /* Hardware state, stored as cmdbuf commands:  
         *   -- Need to doublebuffer for
         *           - eliding noop statechange loops? (except line stipple count)
@@ -438,89 +320,19 @@ struct radeon_hw_state {
        struct radeon_state_atom glt;
        struct radeon_state_atom txr[3];        /* for NPOT */
 
-       int max_state_size;     /* Number of bytes necessary for a full state emit. */
-       GLboolean is_dirty, all_dirty;
 };
 
-struct radeon_state {
-       /* Derived state for internal purposes:
-        */
-       struct radeon_colorbuffer_state color;
-       struct radeon_depthbuffer_state depth;
-       struct radeon_scissor_state scissor;
-       struct radeon_stencilbuffer_state stencil;
+
+struct r100_state {
        struct radeon_stipple_state stipple;
        struct radeon_texture_state texture;
 };
 
-/* Need refcounting on dma buffers:
- */
-struct radeon_dma_buffer {
-       int refcount;           /* the number of retained regions in buf */
-       drmBufPtr buf;
-};
-
-#define GET_START(rvb) (rmesa->radeonScreen->gart_buffer_offset +                      \
-                       (rvb)->address - rmesa->dma.buf0_address +      \
-                       (rvb)->start)
-
-/* A retained region, eg vertices for indexed vertices.
- */
-struct radeon_dma_region {
-       struct radeon_dma_buffer *buf;
-       char *address;          /* == buf->address */
-       int start, end, ptr;    /* offsets from start of buf */
-       int aos_start;
-       int aos_stride;
-       int aos_size;
-};
-
-struct radeon_dma {
-       /* Active dma region.  Allocations for vertices and retained
-        * regions come from here.  Also used for emitting random vertices,
-        * these may be flushed by calling flush_current();
-        */
-       struct radeon_dma_region current;
-
-       void (*flush) (radeonContextPtr);
-
-       char *buf0_address;     /* start of buf[0], for index calcs */
-       GLuint nr_released_bufs;        /* flush after so many buffers released */
-};
-
-struct radeon_dri_mirror {
-       __DRIcontextPrivate *context;   /* DRI context */
-       __DRIscreenPrivate *screen;     /* DRI screen */
-
-   /**
-    * DRI drawable bound to this context for drawing.
-    */
-       __DRIdrawablePrivate *drawable;
-
-   /**
-    * DRI drawable bound to this context for reading.
-    */
-       __DRIdrawablePrivate *readable;
-
-       drm_context_t hwContext;
-       drm_hw_lock_t *hwLock;
-       int fd;
-       int drmMinor;
-};
-
 #define RADEON_CMD_BUF_SZ  (8*1024)
-
-struct radeon_store {
-       GLuint statenr;
-       GLuint primnr;
-       char cmd_buf[RADEON_CMD_BUF_SZ];
-       int cmd_used;
-       int elts_start;
-};
-
+#define R200_ELT_BUF_SZ  (8*1024)
 /* radeon_tcl.c
  */
-struct radeon_tcl_info {
+struct r100_tcl_info {
        GLuint vertex_format;
        GLuint hw_primitive;
 
@@ -529,30 +341,18 @@ struct radeon_tcl_info {
         */
        GLvector4f ObjClean;
 
-       struct radeon_dma_region *aos_components[8];
-       GLuint nr_aos_components;
-
        GLuint *Elts;
 
-       struct radeon_dma_region indexed_verts;
-       struct radeon_dma_region obj;
-       struct radeon_dma_region rgba;
-       struct radeon_dma_region spec;
-       struct radeon_dma_region fog;
-       struct radeon_dma_region tex[RADEON_MAX_TEXTURE_UNITS];
-       struct radeon_dma_region norm;
+        int elt_cmd_offset;
+       int elt_cmd_start;
+        int elt_used;
 };
 
 /* radeon_swtcl.c
  */
-struct radeon_swtcl_info {
-       GLuint RenderIndex;
-       GLuint vertex_size;
+struct r100_swtcl_info {
        GLuint vertex_format;
 
-       struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
-       GLuint vertex_attr_count;
-
        GLubyte *verts;
 
        /* Fallback rasterization functions
@@ -561,10 +361,6 @@ struct radeon_swtcl_info {
        radeon_line_func draw_line;
        radeon_tri_func draw_tri;
 
-       GLuint hw_primitive;
-       GLenum render_primitive;
-       GLuint numverts;
-
    /**
     * Offset of the 4UB color data within a hardware (swtcl) vertex.
     */
@@ -576,22 +372,9 @@ struct radeon_swtcl_info {
        GLuint specoffset;
 
        GLboolean needproj;
-
-       struct radeon_dma_region indexed_verts;
 };
 
-struct radeon_ioctl {
-       GLuint vertex_offset;
-       GLuint vertex_size;
-};
-
-#define RADEON_MAX_PRIMS 64
 
-struct radeon_prim {
-       GLuint start;
-       GLuint end;
-       GLuint prim;
-};
 
 /* A maximum total of 20 elements per vertex:  3 floats for position, 3
  * floats for normal, 4 floats for color, 4 bytes for secondary color,
@@ -602,59 +385,18 @@ struct radeon_prim {
  */
 #define RADEON_MAX_VERTEX_SIZE 20
 
-struct radeon_context {
-       GLcontext *glCtx;       /* Mesa context */
+struct r100_context {
+        struct radeon_context radeon;
 
        /* Driver and hardware state management
         */
-       struct radeon_hw_state hw;
-       struct radeon_state state;
-
-       /* Texture object bookkeeping
-        */
-       unsigned nr_heaps;
-       driTexHeap *texture_heaps[RADEON_NR_TEX_HEAPS];
-       driTextureObject swapped;
-       int texture_depth;
-       float initialMaxAnisotropy;
-
-       /* Rasterization and vertex state:
-        */
-       GLuint TclFallback;
-       GLuint Fallback;
-       GLuint NewGLState;
-        DECLARE_RENDERINPUTS(tnl_index_bitset);        /* index of bits for last tnl_install_attrs */
+       struct r100_hw_state hw;
+       struct r100_state state;
 
        /* Vertex buffers
         */
        struct radeon_ioctl ioctl;
-       struct radeon_dma dma;
        struct radeon_store store;
-       /* A full state emit as of the first state emit in the main store, in case
-        * the context is lost.
-        */
-       struct radeon_store backup_store;
-
-       /* Page flipping
-        */
-       GLuint doPageFlip;
-
-       /* Busy waiting
-        */
-       GLuint do_usleeps;
-       GLuint do_irqs;
-       GLuint irqsEmitted;
-       drm_radeon_irq_wait_t iw;
-
-       /* Drawable, cliprect and scissor information
-        */
-       GLuint numClipRects;    /* Cliprects for the draw buffer */
-       drm_clip_rect_t *pClipRects;
-       unsigned int lastStamp;
-       GLboolean lost_context;
-       GLboolean save_on_next_emit;
-       radeonScreenPtr radeonScreen;   /* Screen private DRI data */
-       drm_radeon_sarea_t *sarea;      /* Private SAREA data */
 
        /* TCL stuff
         */
@@ -667,29 +409,13 @@ struct radeon_context {
        GLmatrix tmpmat[RADEON_MAX_TEXTURE_UNITS];
        GLuint last_ReallyEnabled;
 
-       /* VBI
-        */
-       int64_t swap_ust;
-       int64_t swap_missed_ust;
-
-       GLuint swap_count;
-       GLuint swap_missed_count;
-
        /* radeon_tcl.c
         */
-       struct radeon_tcl_info tcl;
+       struct r100_tcl_info tcl;
 
        /* radeon_swtcl.c
         */
-       struct radeon_swtcl_info swtcl;
-
-       /* Mirrors of some DRI state
-        */
-       struct radeon_dri_mirror dri;
-
-       /* Configuration cache
-        */
-       driOptionCache optionCache;
+       struct r100_swtcl_info swtcl;
 
        GLboolean using_hyperz;
        GLboolean texmicrotile;
@@ -703,61 +429,19 @@ struct radeon_context {
        GLuint c_textureSwaps;
        GLuint c_textureBytes;
        GLuint c_vertexBuffers;
+
 };
 
-#define RADEON_CONTEXT(ctx)            ((radeonContextPtr)(ctx->DriverCtx))
-
-static INLINE GLuint radeonPackColor(GLuint cpp,
-                                     GLubyte r, GLubyte g,
-                                     GLubyte b, GLubyte a)
-{
-       switch (cpp) {
-       case 2:
-               return PACK_COLOR_565(r, g, b);
-       case 4:
-               return PACK_COLOR_8888(a, r, g, b);
-       default:
-               return 0;
-       }
-}
+
+#define R100_CONTEXT(ctx)              ((r100ContextPtr)(ctx->DriverCtx))
+
 
 #define RADEON_OLD_PACKETS 1
 
-extern void radeonDestroyContext(__DRIcontextPrivate * driContextPriv);
-extern GLboolean radeonCreateContext(const __GLcontextModes * glVisual,
-                                    __DRIcontextPrivate * driContextPriv,
-                                    void *sharedContextPrivate);
-extern void radeonSwapBuffers(__DRIdrawablePrivate * dPriv);
-extern void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
-                               int x, int y, int w, int h);
-extern GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
-                                  __DRIdrawablePrivate * driDrawPriv,
-                                  __DRIdrawablePrivate * driReadPriv);
-extern GLboolean radeonUnbindContext(__DRIcontextPrivate * driContextPriv);
-
-/* ================================================================
- * Debugging:
- */
-#define DO_DEBUG               1
-
-#if DO_DEBUG
-extern int RADEON_DEBUG;
-#else
-#define RADEON_DEBUG           0
-#endif
-
-#define DEBUG_TEXTURE  0x0001
-#define DEBUG_STATE    0x0002
-#define DEBUG_IOCTL    0x0004
-#define DEBUG_PRIMS    0x0008
-#define DEBUG_VERTS    0x0010
-#define DEBUG_FALLBACKS        0x0020
-#define DEBUG_VFMT     0x0040
-#define DEBUG_CODEGEN  0x0080
-#define DEBUG_VERBOSE  0x0100
-#define DEBUG_DRI       0x0200
-#define DEBUG_DMA       0x0400
-#define DEBUG_SANITY    0x0800
-#define DEBUG_SYNC      0x1000
+extern GLboolean r100CreateContext( const __GLcontextModes *glVisual,
+                                   __DRIcontextPrivate *driContextPriv,
+                                   void *sharedContextPrivate);
+  
+
 
 #endif                         /* __RADEON_CONTEXT_H__ */
diff --git a/src/mesa/drivers/dri/radeon/radeon_cs_drm.h b/src/mesa/drivers/dri/radeon/radeon_cs_drm.h
new file mode 100644 (file)
index 0000000..984725a
--- /dev/null
@@ -0,0 +1,207 @@
+/* 
+ * Copyright Â© 2008 Nicolai Haehnle
+ * Copyright Â© 2008 Jérôme Glisse
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or 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:
+ *      Aapo Tahkola <aet@rasterburn.org>
+ *      Nicolai Haehnle <prefect_@gmx.net>
+ *      Jérôme Glisse <glisse@freedesktop.org>
+ */
+#ifndef RADEON_CS_H
+#define RADEON_CS_H
+
+#include <stdint.h>
+#include <string.h>
+#include "drm.h"
+#include "radeon_drm.h"
+
+struct radeon_cs_reloc {
+    struct radeon_bo    *bo;
+    uint32_t            read_domain;
+    uint32_t            write_domain;
+    uint32_t            flags;
+};
+
+
+#define RADEON_CS_SPACE_OK 0
+#define RADEON_CS_SPACE_OP_TO_BIG 1
+#define RADEON_CS_SPACE_FLUSH 2
+
+struct radeon_cs_space_check {
+    struct radeon_bo *bo;
+    uint32_t read_domains;
+    uint32_t write_domain;
+    uint32_t new_accounted;
+};
+
+struct radeon_cs_manager;
+
+struct radeon_cs {
+    struct radeon_cs_manager    *csm;
+    void                        *relocs;
+    uint32_t                    *packets;
+    unsigned                    crelocs;
+    unsigned                    relocs_total_size;
+    unsigned                    cdw;
+    unsigned                    ndw;
+    int                         section;
+    unsigned                    section_ndw;
+    unsigned                    section_cdw;
+    const char                  *section_file;
+    const char                  *section_func;
+    int                         section_line;
+
+};
+
+/* cs functions */
+struct radeon_cs_funcs {
+    struct radeon_cs *(*cs_create)(struct radeon_cs_manager *csm,
+                                   uint32_t ndw);
+    int (*cs_write_reloc)(struct radeon_cs *cs,
+                          struct radeon_bo *bo,
+                          uint32_t read_domain,
+                          uint32_t write_domain,
+                          uint32_t flags);
+    int (*cs_begin)(struct radeon_cs *cs,
+                    uint32_t ndw,
+                    const char *file,
+                    const char *func,
+                    int line);
+    int (*cs_end)(struct radeon_cs *cs,
+                  const char *file,
+                  const char *func,
+                  int line);
+    int (*cs_emit)(struct radeon_cs *cs);
+    int (*cs_destroy)(struct radeon_cs *cs);
+    int (*cs_erase)(struct radeon_cs *cs);
+    int (*cs_need_flush)(struct radeon_cs *cs);
+    void (*cs_print)(struct radeon_cs *cs, FILE *file);
+    int (*cs_space_check)(struct radeon_cs *cs, struct radeon_cs_space_check *bos,
+                         int num_bo);
+};
+
+struct radeon_cs_manager {
+    struct radeon_cs_funcs  *funcs;
+    int                     fd;
+    uint32_t vram_limit, gart_limit;
+    uint32_t vram_write_used, gart_write_used;
+    uint32_t read_used;
+};
+
+static inline struct radeon_cs *radeon_cs_create(struct radeon_cs_manager *csm,
+                                                 uint32_t ndw)
+{
+    return csm->funcs->cs_create(csm, ndw);
+}
+
+static inline int radeon_cs_write_reloc(struct radeon_cs *cs,
+                                        struct radeon_bo *bo,
+                                        uint32_t read_domain,
+                                        uint32_t write_domain,
+                                        uint32_t flags)
+{
+    return cs->csm->funcs->cs_write_reloc(cs,
+                                          bo,
+                                          read_domain,
+                                          write_domain,
+                                          flags);
+}
+
+static inline int radeon_cs_begin(struct radeon_cs *cs,
+                                  uint32_t ndw,
+                                  const char *file,
+                                  const char *func,
+                                  int line)
+{
+    return cs->csm->funcs->cs_begin(cs, ndw, file, func, line);
+}
+
+static inline int radeon_cs_end(struct radeon_cs *cs,
+                                const char *file,
+                                const char *func,
+                                int line)
+{
+    return cs->csm->funcs->cs_end(cs, file, func, line);
+}
+
+static inline int radeon_cs_emit(struct radeon_cs *cs)
+{
+    return cs->csm->funcs->cs_emit(cs);
+}
+
+static inline int radeon_cs_destroy(struct radeon_cs *cs)
+{
+    return cs->csm->funcs->cs_destroy(cs);
+}
+
+static inline int radeon_cs_erase(struct radeon_cs *cs)
+{
+    return cs->csm->funcs->cs_erase(cs);
+}
+
+static inline int radeon_cs_need_flush(struct radeon_cs *cs)
+{
+    return cs->csm->funcs->cs_need_flush(cs);
+}
+
+static inline void radeon_cs_print(struct radeon_cs *cs, FILE *file)
+{
+    cs->csm->funcs->cs_print(cs, file);
+}
+
+static inline int radeon_cs_space_check(struct radeon_cs *cs,
+                                           struct radeon_cs_space_check *bos,
+                                           int num_bo)
+{
+    return cs->csm->funcs->cs_space_check(cs, bos, num_bo);
+}
+
+static inline void radeon_cs_set_limit(struct radeon_cs *cs, uint32_t domain, uint32_t limit)
+{
+    
+    if (domain == RADEON_GEM_DOMAIN_VRAM)
+       cs->csm->vram_limit = limit;
+    else
+       cs->csm->gart_limit = limit;
+}
+
+static inline void radeon_cs_write_dword(struct radeon_cs *cs, uint32_t dword)
+{
+    cs->packets[cs->cdw++] = dword;
+    if (cs->section) {
+        cs->section_cdw++;
+    }
+}
+
+static inline void radeon_cs_write_qword(struct radeon_cs *cs, uint64_t qword)
+{
+
+    memcpy(cs->packets + cs->cdw, &qword, sizeof(qword));
+    cs->cdw+=2;
+    if (cs->section) {
+        cs->section_cdw+=2;
+    }
+}
+#endif
diff --git a/src/mesa/drivers/dri/radeon/radeon_cs_legacy.c b/src/mesa/drivers/dri/radeon/radeon_cs_legacy.c
new file mode 100644 (file)
index 0000000..e4ee2b9
--- /dev/null
@@ -0,0 +1,496 @@
+/* 
+ * Copyright Â© 2008 Nicolai Haehnle
+ * Copyright Â© 2008 Jérôme Glisse
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or 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:
+ *      Aapo Tahkola <aet@rasterburn.org>
+ *      Nicolai Haehnle <prefect_@gmx.net>
+ *      Jérôme Glisse <glisse@freedesktop.org>
+ */
+#include <errno.h>
+
+#include "radeon_bocs_wrapper.h"
+
+struct cs_manager_legacy {
+    struct radeon_cs_manager    base;
+    struct radeon_context       *ctx;
+    /* hack for scratch stuff */
+    uint32_t                    pending_age;
+    uint32_t                    pending_count;
+
+
+};
+
+struct cs_reloc_legacy {
+    struct radeon_cs_reloc  base;
+    uint32_t                cindices;
+    uint32_t                *indices;
+};
+
+
+static struct radeon_cs *cs_create(struct radeon_cs_manager *csm,
+                                   uint32_t ndw)
+{
+    struct radeon_cs *cs;
+
+    cs = (struct radeon_cs*)calloc(1, sizeof(struct radeon_cs));
+    if (cs == NULL) {
+        return NULL;
+    }
+    cs->csm = csm;
+    cs->ndw = (ndw + 0x3FF) & (~0x3FF);
+    cs->packets = (uint32_t*)malloc(4*cs->ndw);
+    if (cs->packets == NULL) {
+        free(cs);
+        return NULL;
+    }
+    cs->relocs_total_size = 0;
+    return cs;
+}
+
+static int cs_write_reloc(struct radeon_cs *cs,
+                          struct radeon_bo *bo,
+                          uint32_t read_domain,
+                          uint32_t write_domain,
+                          uint32_t flags)
+{
+    struct cs_reloc_legacy *relocs;
+    int i;
+
+    relocs = (struct cs_reloc_legacy *)cs->relocs;
+    /* check domains */
+    if ((read_domain && write_domain) || (!read_domain && !write_domain)) {
+        /* in one CS a bo can only be in read or write domain but not
+         * in read & write domain at the same sime
+         */
+        return -EINVAL;
+    }
+    if (read_domain == RADEON_GEM_DOMAIN_CPU) {
+        return -EINVAL;
+    }
+    if (write_domain == RADEON_GEM_DOMAIN_CPU) {
+        return -EINVAL;
+    }
+    /* check if bo is already referenced */
+    for(i = 0; i < cs->crelocs; i++) {
+        uint32_t *indices;
+
+        if (relocs[i].base.bo->handle == bo->handle) {
+            /* Check domains must be in read or write. As we check already
+             * checked that in argument one of the read or write domain was
+             * set we only need to check that if previous reloc as the read
+             * domain set then the read_domain should also be set for this
+             * new relocation.
+             */
+            if (relocs[i].base.read_domain && !read_domain) {
+                return -EINVAL;
+            }
+            if (relocs[i].base.write_domain && !write_domain) {
+                return -EINVAL;
+            }
+            relocs[i].base.read_domain |= read_domain;
+            relocs[i].base.write_domain |= write_domain;
+            /* save indice */
+            relocs[i].cindices++;
+            indices = (uint32_t*)realloc(relocs[i].indices,
+                                         relocs[i].cindices * 4);
+            if (indices == NULL) {
+                relocs[i].cindices -= 1;
+                return -ENOMEM;
+            }
+            relocs[i].indices = indices;
+            relocs[i].indices[relocs[i].cindices - 1] = cs->cdw - 1;
+            return 0;
+        }
+    }
+    /* add bo to reloc */
+    relocs = (struct cs_reloc_legacy*)
+             realloc(cs->relocs,
+                     sizeof(struct cs_reloc_legacy) * (cs->crelocs + 1));
+    if (relocs == NULL) {
+        return -ENOMEM;
+    }
+    cs->relocs = relocs;
+    relocs[cs->crelocs].base.bo = bo;
+    relocs[cs->crelocs].base.read_domain = read_domain;
+    relocs[cs->crelocs].base.write_domain = write_domain;
+    relocs[cs->crelocs].base.flags = flags;
+    relocs[cs->crelocs].indices = (uint32_t*)malloc(4);
+    if (relocs[cs->crelocs].indices == NULL) {
+        return -ENOMEM;
+    }
+    relocs[cs->crelocs].indices[0] = cs->cdw - 1;
+    relocs[cs->crelocs].cindices = 1;
+    cs->relocs_total_size += radeon_bo_legacy_relocs_size(bo);
+    cs->crelocs++;
+    radeon_bo_ref(bo);
+    return 0;
+}
+
+static int cs_begin(struct radeon_cs *cs,
+                    uint32_t ndw,
+                    const char *file,
+                    const char *func,
+                    int line)
+{
+    if (cs->section) {
+        fprintf(stderr, "CS already in a section(%s,%s,%d)\n",
+                cs->section_file, cs->section_func, cs->section_line);
+        fprintf(stderr, "CS can't start section(%s,%s,%d)\n",
+                file, func, line);
+        return -EPIPE;
+    }
+    cs->section = 1;
+    cs->section_ndw = ndw;
+    cs->section_cdw = 0;
+    cs->section_file = file;
+    cs->section_func = func;
+    cs->section_line = line;
+
+
+    if (cs->cdw + ndw > cs->ndw) {
+        uint32_t tmp, *ptr;
+       int num = (ndw > 0x3FF) ? ndw : 0x3FF;
+
+        tmp = (cs->cdw + 1 + num) & (~num);
+        ptr = (uint32_t*)realloc(cs->packets, 4 * tmp);
+        if (ptr == NULL) {
+            return -ENOMEM;
+        }
+        cs->packets = ptr;
+        cs->ndw = tmp;
+    }
+
+    return 0;
+}
+
+static int cs_end(struct radeon_cs *cs,
+                  const char *file,
+                  const char *func,
+                  int line)
+
+{
+    if (!cs->section) {
+        fprintf(stderr, "CS no section to end at (%s,%s,%d)\n",
+                file, func, line);
+        return -EPIPE;
+    }
+    cs->section = 0;
+    if (cs->section_ndw != cs->section_cdw) {
+        fprintf(stderr, "CS section size missmatch start at (%s,%s,%d) %d vs %d\n",
+                cs->section_file, cs->section_func, cs->section_line, cs->section_ndw, cs->section_cdw);
+        fprintf(stderr, "CS section end at (%s,%s,%d)\n",
+                file, func, line);
+        return -EPIPE;
+    }
+    return 0;
+}
+
+static int cs_process_relocs(struct radeon_cs *cs)
+{
+    struct cs_manager_legacy *csm = (struct cs_manager_legacy*)cs->csm;
+    struct cs_reloc_legacy *relocs;
+    int i, j, r;
+
+    csm = (struct cs_manager_legacy*)cs->csm;
+    relocs = (struct cs_reloc_legacy *)cs->relocs;
+ restart:
+    for (i = 0; i < cs->crelocs; i++) {
+        for (j = 0; j < relocs[i].cindices; j++) {
+            uint32_t soffset, eoffset;
+
+            r = radeon_bo_legacy_validate(relocs[i].base.bo,
+                                           &soffset, &eoffset);
+           if (r == -EAGAIN)
+             goto restart;
+            if (r) {
+                fprintf(stderr, "validated %p [0x%08X, 0x%08X]\n",
+                        relocs[i].base.bo, soffset, eoffset);
+                return r;
+            }
+            cs->packets[relocs[i].indices[j]] += soffset;
+            if (cs->packets[relocs[i].indices[j]] >= eoffset) {
+             /*                radeon_bo_debug(relocs[i].base.bo, 12); */
+                fprintf(stderr, "validated %p [0x%08X, 0x%08X]\n",
+                        relocs[i].base.bo, soffset, eoffset);
+                fprintf(stderr, "above end: %p 0x%08X 0x%08X\n",
+                        relocs[i].base.bo,
+                        cs->packets[relocs[i].indices[j]],
+                        eoffset);
+                exit(0);
+                return -EINVAL;
+            }
+        }
+    }
+    return 0;
+}
+
+static int cs_set_age(struct radeon_cs *cs)
+{
+    struct cs_manager_legacy *csm = (struct cs_manager_legacy*)cs->csm;
+    struct cs_reloc_legacy *relocs;
+    int i;
+
+    relocs = (struct cs_reloc_legacy *)cs->relocs;
+    for (i = 0; i < cs->crelocs; i++) {
+        radeon_bo_legacy_pending(relocs[i].base.bo, csm->pending_age);
+        radeon_bo_unref(relocs[i].base.bo);
+    }
+    return 0;
+}
+
+static int cs_emit(struct radeon_cs *cs)
+{
+    struct cs_manager_legacy *csm = (struct cs_manager_legacy*)cs->csm;
+    drm_radeon_cmd_buffer_t cmd;
+    drm_r300_cmd_header_t age;
+    uint64_t ull;
+    int r;
+
+    csm->ctx->vtbl.emit_cs_header(cs, csm->ctx);
+
+    /* append buffer age */
+    if (IS_R300_CLASS(csm->ctx->radeonScreen)) {
+      age.scratch.cmd_type = R300_CMD_SCRATCH;
+      /* Scratch register 2 corresponds to what radeonGetAge polls */
+      csm->pending_age = 0;
+      csm->pending_count = 1;
+      ull = (uint64_t) (intptr_t) &csm->pending_age;
+      age.scratch.reg = 2;
+      age.scratch.n_bufs = 1;
+      age.scratch.flags = 0;
+      radeon_cs_write_dword(cs, age.u);
+      radeon_cs_write_qword(cs, ull);
+      radeon_cs_write_dword(cs, 0);
+    }
+
+    r = cs_process_relocs(cs);
+    if (r) {
+        return 0;
+    }
+
+    cmd.buf = (char *)cs->packets;
+    cmd.bufsz = cs->cdw * 4;
+    if (csm->ctx->state.scissor.enabled) {
+        cmd.nbox = csm->ctx->state.scissor.numClipRects;
+        cmd.boxes = (drm_clip_rect_t *) csm->ctx->state.scissor.pClipRects;
+    } else {
+        cmd.nbox = csm->ctx->numClipRects;
+        cmd.boxes = (drm_clip_rect_t *) csm->ctx->pClipRects;
+    }
+
+    //dump_cmdbuf(cs);
+
+    r = drmCommandWrite(cs->csm->fd, DRM_RADEON_CMDBUF, &cmd, sizeof(cmd));
+    if (r) {
+        return r;
+    }
+    if (!IS_R300_CLASS(csm->ctx->radeonScreen)) {
+       drm_radeon_irq_emit_t emit_cmd;
+       emit_cmd.irq_seq = &csm->pending_age;
+       r = drmCommandWrite(cs->csm->fd, DRM_RADEON_IRQ_EMIT, &emit_cmd, sizeof(emit_cmd));
+       if (r) {
+               return r;
+       }
+    }
+    cs_set_age(cs);
+
+    cs->csm->read_used = 0;
+    cs->csm->vram_write_used = 0;
+    cs->csm->gart_write_used = 0;
+    return 0;
+}
+
+static void inline cs_free_reloc(void *relocs_p, int crelocs)
+{
+    struct cs_reloc_legacy *relocs = relocs_p;
+    int i;
+    if (!relocs_p)
+      return;
+    for (i = 0; i < crelocs; i++)
+      free(relocs[i].indices);
+}
+
+static int cs_destroy(struct radeon_cs *cs)
+{
+    cs_free_reloc(cs->relocs, cs->crelocs);
+    free(cs->relocs);
+    free(cs->packets);
+    free(cs);
+    return 0;
+}
+
+static int cs_erase(struct radeon_cs *cs)
+{
+    cs_free_reloc(cs->relocs, cs->crelocs);
+    free(cs->relocs);
+    cs->relocs_total_size = 0;
+    cs->relocs = NULL;
+    cs->crelocs = 0;
+    cs->cdw = 0;
+    cs->section = 0;
+    return 0;
+}
+
+static int cs_need_flush(struct radeon_cs *cs)
+{
+    /* this function used to flush when the BO usage got to
+     * a certain size, now the higher levels handle this better */
+    return 0;
+}
+
+static void cs_print(struct radeon_cs *cs, FILE *file)
+{
+}
+
+static int cs_check_space(struct radeon_cs *cs, struct radeon_cs_space_check *bos, int num_bo)
+{
+    struct radeon_cs_manager *csm = cs->csm;
+    int this_op_read = 0, this_op_gart_write = 0, this_op_vram_write = 0;
+    uint32_t read_domains, write_domain;
+    int i;
+    struct radeon_bo *bo;
+
+    /* check the totals for this operation */
+
+    if (num_bo == 0)
+        return 0;
+
+    /* prepare */
+    for (i = 0; i < num_bo; i++) {
+      bo = bos[i].bo;
+
+      bos[i].new_accounted = 0;
+      read_domains = bos[i].read_domains;
+      write_domain = bos[i].write_domain;
+               
+      /* pinned bos don't count */
+      if (radeon_legacy_bo_is_static(bo))
+         continue;
+      /* already accounted this bo */
+      if (write_domain && (write_domain == bo->space_accounted))
+         continue;
+
+      if (read_domains && ((read_domains << 16) == bo->space_accounted))
+         continue;
+      
+      if (bo->space_accounted == 0) {
+         if (write_domain == RADEON_GEM_DOMAIN_VRAM)
+             this_op_vram_write += bo->size;
+         else if (write_domain == RADEON_GEM_DOMAIN_GTT)
+             this_op_gart_write += bo->size;
+         else
+             this_op_read += bo->size;
+         bos[i].new_accounted = (read_domains << 16) | write_domain;
+      } else {
+         uint16_t old_read, old_write;
+         
+         old_read = bo->space_accounted >> 16;
+         old_write = bo->space_accounted & 0xffff;
+
+         if (write_domain && (old_read & write_domain)) {
+             bos[i].new_accounted = write_domain;
+             /* moving from read to a write domain */
+             if (write_domain == RADEON_GEM_DOMAIN_VRAM) {
+                 this_op_read -= bo->size;
+                 this_op_vram_write += bo->size;
+             } else if (write_domain == RADEON_GEM_DOMAIN_VRAM) {
+                 this_op_read -= bo->size;
+                 this_op_gart_write += bo->size;
+             }
+         } else if (read_domains & old_write) {
+             bos[i].new_accounted = bo->space_accounted & 0xffff;
+         } else {
+             /* rewrite the domains */
+             if (write_domain != old_write)
+                 fprintf(stderr,"WRITE DOMAIN RELOC FAILURE 0x%x %d %d\n", bo->handle, write_domain, old_write);
+             if (read_domains != old_read)
+                 fprintf(stderr,"READ DOMAIN RELOC FAILURE 0x%x %d %d\n", bo->handle, read_domains, old_read);
+             return RADEON_CS_SPACE_FLUSH;
+         }
+      }
+       }
+       
+       if (this_op_read < 0)
+               this_op_read = 0;
+
+       /* check sizes - operation first */
+       if ((this_op_read + this_op_gart_write > csm->gart_limit) ||
+           (this_op_vram_write > csm->vram_limit)) {
+           return RADEON_CS_SPACE_OP_TO_BIG;
+       }
+
+       if (((csm->vram_write_used + this_op_vram_write) > csm->vram_limit) ||
+           ((csm->read_used + csm->gart_write_used + this_op_gart_write + this_op_read) > csm->gart_limit)) {
+               return RADEON_CS_SPACE_FLUSH;
+       }
+
+       csm->gart_write_used += this_op_gart_write;
+       csm->vram_write_used += this_op_vram_write;
+       csm->read_used += this_op_read;
+       /* commit */
+       for (i = 0; i < num_bo; i++) {
+               bo = bos[i].bo;
+               bo->space_accounted = bos[i].new_accounted;
+       }
+
+       return RADEON_CS_SPACE_OK;
+}
+
+static struct radeon_cs_funcs  radeon_cs_legacy_funcs = {
+    cs_create,
+    cs_write_reloc,
+    cs_begin,
+    cs_end,
+    cs_emit,
+    cs_destroy,
+    cs_erase,
+    cs_need_flush,
+    cs_print,
+    cs_check_space
+};
+
+struct radeon_cs_manager *radeon_cs_manager_legacy_ctor(struct radeon_context *ctx)
+{
+    struct cs_manager_legacy *csm;
+
+    csm = (struct cs_manager_legacy*)
+          calloc(1, sizeof(struct cs_manager_legacy));
+    if (csm == NULL) {
+        return NULL;
+    }
+    csm->base.funcs = &radeon_cs_legacy_funcs;
+    csm->base.fd = ctx->dri.fd;
+    csm->ctx = ctx;
+    csm->pending_age = 1;
+    return (struct radeon_cs_manager*)csm;
+}
+
+void radeon_cs_manager_legacy_dtor(struct radeon_cs_manager *csm)
+{
+    free(csm);
+}
+
diff --git a/src/mesa/drivers/dri/radeon/radeon_cs_legacy.h b/src/mesa/drivers/dri/radeon/radeon_cs_legacy.h
new file mode 100644 (file)
index 0000000..e177b4b
--- /dev/null
@@ -0,0 +1,40 @@
+/* 
+ * Copyright Â© 2008 Nicolai Haehnle
+ * Copyright Â© 2008 Jérôme Glisse
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or 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:
+ *      Aapo Tahkola <aet@rasterburn.org>
+ *      Nicolai Haehnle <prefect_@gmx.net>
+ *      Jérôme Glisse <glisse@freedesktop.org>
+ */
+#ifndef RADEON_CS_LEGACY_H
+#define RADEON_CS_LEGACY_H
+
+#include "radeon_common.h"
+
+struct radeon_cs_manager *radeon_cs_manager_legacy_ctor(struct radeon_context *ctx);
+void radeon_cs_manager_legacy_dtor(struct radeon_cs_manager *csm);
+
+#endif
diff --git a/src/mesa/drivers/dri/radeon/radeon_dma.c b/src/mesa/drivers/dri/radeon/radeon_dma.c
new file mode 100644 (file)
index 0000000..48b0d63
--- /dev/null
@@ -0,0 +1,341 @@
+/**************************************************************************
+
+Copyright (C) 2004 Nicolai Haehnle.
+Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+on the rights to use, copy, modify, merge, publish, distribute, sub
+license, and/or sell copies of the Software, and to permit persons to whom
+the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ATI, VA LINUX SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#include "radeon_common.h"
+
+#if defined(USE_X86_ASM)
+#define COPY_DWORDS( dst, src, nr )                                    \
+do {                                                                   \
+       int __tmp;                                                      \
+       __asm__ __volatile__( "rep ; movsl"                             \
+                             : "=%c" (__tmp), "=D" (dst), "=S" (__tmp) \
+                             : "0" (nr),                               \
+                               "D" ((long)dst),                        \
+                               "S" ((long)src) );                      \
+} while (0)
+#else
+#define COPY_DWORDS( dst, src, nr )            \
+do {                                           \
+   int j;                                      \
+   for ( j = 0 ; j < nr ; j++ )                        \
+      dst[j] = ((int *)src)[j];                        \
+   dst += nr;                                  \
+} while (0)
+#endif
+
+static void radeonEmitVec4(uint32_t *out, GLvoid * data, int stride, int count)
+{
+       int i;
+
+       if (RADEON_DEBUG & DEBUG_VERTS)
+               fprintf(stderr, "%s count %d stride %d out %p data %p\n",
+                       __FUNCTION__, count, stride, (void *)out, (void *)data);
+
+       if (stride == 4)
+               COPY_DWORDS(out, data, count);
+       else
+               for (i = 0; i < count; i++) {
+                       out[0] = *(int *)data;
+                       out++;
+                       data += stride;
+               }
+}
+
+void radeonEmitVec8(uint32_t *out, GLvoid * data, int stride, int count)
+{
+       int i;
+
+       if (RADEON_DEBUG & DEBUG_VERTS)
+               fprintf(stderr, "%s count %d stride %d out %p data %p\n",
+                       __FUNCTION__, count, stride, (void *)out, (void *)data);
+
+       if (stride == 8)
+               COPY_DWORDS(out, data, count * 2);
+       else
+               for (i = 0; i < count; i++) {
+                       out[0] = *(int *)data;
+                       out[1] = *(int *)(data + 4);
+                       out += 2;
+                       data += stride;
+               }
+}
+
+void radeonEmitVec12(uint32_t *out, GLvoid * data, int stride, int count)
+{
+       int i;
+
+       if (RADEON_DEBUG & DEBUG_VERTS)
+               fprintf(stderr, "%s count %d stride %d out %p data %p\n",
+                       __FUNCTION__, count, stride, (void *)out, (void *)data);
+
+       if (stride == 12) {
+               COPY_DWORDS(out, data, count * 3);
+    }
+       else
+               for (i = 0; i < count; i++) {
+                       out[0] = *(int *)data;
+                       out[1] = *(int *)(data + 4);
+                       out[2] = *(int *)(data + 8);
+                       out += 3;
+                       data += stride;
+               }
+}
+
+static void radeonEmitVec16(uint32_t *out, GLvoid * data, int stride, int count)
+{
+       int i;
+
+       if (RADEON_DEBUG & DEBUG_VERTS)
+               fprintf(stderr, "%s count %d stride %d out %p data %p\n",
+                       __FUNCTION__, count, stride, (void *)out, (void *)data);
+
+       if (stride == 16)
+               COPY_DWORDS(out, data, count * 4);
+       else
+               for (i = 0; i < count; i++) {
+                       out[0] = *(int *)data;
+                       out[1] = *(int *)(data + 4);
+                       out[2] = *(int *)(data + 8);
+                       out[3] = *(int *)(data + 12);
+                       out += 4;
+                       data += stride;
+               }
+}
+
+void rcommon_emit_vector(GLcontext * ctx, struct radeon_aos *aos,
+                        GLvoid * data, int size, int stride, int count)
+{
+       radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+       uint32_t *out;
+
+       if (stride == 0) {
+               radeonAllocDmaRegion(rmesa, &aos->bo, &aos->offset, size * 4, 32);
+               count = 1;
+               aos->stride = 0;
+       } else {
+               radeonAllocDmaRegion(rmesa, &aos->bo, &aos->offset, size * count * 4, 32);
+               aos->stride = size;
+       }
+
+       aos->components = size;
+       aos->count = count;
+
+       out = (uint32_t*)((char*)aos->bo->ptr + aos->offset);
+       switch (size) {
+       case 1: radeonEmitVec4(out, data, stride, count); break;
+       case 2: radeonEmitVec8(out, data, stride, count); break;
+       case 3: radeonEmitVec12(out, data, stride, count); break;
+       case 4: radeonEmitVec16(out, data, stride, count); break;
+       default:
+               assert(0);
+               break;
+       }
+}
+
+void radeonRefillCurrentDmaRegion(radeonContextPtr rmesa, int size)
+{
+
+       size = MAX2(size, MAX_DMA_BUF_SZ);
+
+       if (RADEON_DEBUG & (DEBUG_IOCTL | DEBUG_DMA))
+               fprintf(stderr, "%s\n", __FUNCTION__);
+
+       if (rmesa->dma.flush) {
+               rmesa->dma.flush(rmesa->glCtx);
+       }
+
+       if (rmesa->dma.nr_released_bufs > 4) {
+               rcommonFlushCmdBuf(rmesa, __FUNCTION__);
+               rmesa->dma.nr_released_bufs = 0;
+       }
+
+       if (rmesa->dma.current) {
+               radeon_bo_unmap(rmesa->dma.current);
+               radeon_bo_unref(rmesa->dma.current);
+               rmesa->dma.current = 0;
+       }
+
+again_alloc:   
+       rmesa->dma.current = radeon_bo_open(rmesa->radeonScreen->bom,
+                                           0, size, 4, RADEON_GEM_DOMAIN_GTT,
+                                           0);
+
+       if (!rmesa->dma.current) {
+               rcommonFlushCmdBuf(rmesa, __FUNCTION__);
+               rmesa->dma.nr_released_bufs = 0;
+               goto again_alloc;
+       }
+
+       rmesa->dma.current_used = 0;
+       rmesa->dma.current_vertexptr = 0;
+       
+       radeon_validate_bo(rmesa, rmesa->dma.current, RADEON_GEM_DOMAIN_GTT, 0);
+
+       if (radeon_revalidate_bos(rmesa->glCtx) == GL_FALSE)
+         fprintf(stderr,"failure to revalidate BOs - badness\n");
+
+       if (!rmesa->dma.current) {
+        /* Cmd buff have been flushed in radeon_revalidate_bos */
+               rmesa->dma.nr_released_bufs = 0;
+               goto again_alloc;
+       }
+
+       radeon_bo_map(rmesa->dma.current, 1);
+}
+
+/* Allocates a region from rmesa->dma.current.  If there isn't enough
+ * space in current, grab a new buffer (and discard what was left of current)
+ */
+void radeonAllocDmaRegion(radeonContextPtr rmesa,
+                         struct radeon_bo **pbo, int *poffset,
+                         int bytes, int alignment)
+{
+       if (RADEON_DEBUG & DEBUG_IOCTL)
+               fprintf(stderr, "%s %d\n", __FUNCTION__, bytes);
+
+       if (rmesa->dma.flush)
+               rmesa->dma.flush(rmesa->glCtx);
+
+       assert(rmesa->dma.current_used == rmesa->dma.current_vertexptr);
+
+       alignment--;
+       rmesa->dma.current_used = (rmesa->dma.current_used + alignment) & ~alignment;
+
+       if (!rmesa->dma.current || rmesa->dma.current_used + bytes > rmesa->dma.current->size)
+               radeonRefillCurrentDmaRegion(rmesa, (bytes + 15) & ~15);
+
+       *poffset = rmesa->dma.current_used;
+       *pbo = rmesa->dma.current;
+       radeon_bo_ref(*pbo);
+
+       /* Always align to at least 16 bytes */
+       rmesa->dma.current_used = (rmesa->dma.current_used + bytes + 15) & ~15;
+       rmesa->dma.current_vertexptr = rmesa->dma.current_used;
+
+       assert(rmesa->dma.current_used <= rmesa->dma.current->size);
+}
+
+void radeonReleaseDmaRegion(radeonContextPtr rmesa)
+{
+       if (RADEON_DEBUG & DEBUG_IOCTL)
+               fprintf(stderr, "%s %p\n", __FUNCTION__, rmesa->dma.current);
+       if (rmesa->dma.current) {
+               rmesa->dma.nr_released_bufs++;
+               radeon_bo_unmap(rmesa->dma.current);
+               radeon_bo_unref(rmesa->dma.current);
+       }
+       rmesa->dma.current = NULL;
+}
+
+
+/* Flush vertices in the current dma region.
+ */
+void rcommon_flush_last_swtcl_prim( GLcontext *ctx  )
+{
+       radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+       struct radeon_dma *dma = &rmesa->dma;
+               
+
+       if (RADEON_DEBUG & DEBUG_IOCTL)
+               fprintf(stderr, "%s %p\n", __FUNCTION__, dma->current);
+       dma->flush = NULL;
+
+       if (dma->current) {
+           GLuint current_offset = dma->current_used;
+
+           assert (dma->current_used +
+                   rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 ==
+                   dma->current_vertexptr);
+
+           if (dma->current_used != dma->current_vertexptr) {
+                   dma->current_used = dma->current_vertexptr;
+
+                   rmesa->vtbl.swtcl_flush(ctx, current_offset);
+           }
+           rmesa->swtcl.numverts = 0;
+       }
+}
+/* Alloc space in the current dma region.
+ */
+void *
+rcommonAllocDmaLowVerts( radeonContextPtr rmesa, int nverts, int vsize )
+{
+       GLuint bytes = vsize * nverts;
+       void *head;
+restart:
+       if (!rmesa->dma.current || rmesa->dma.current_vertexptr + bytes > rmesa->dma.current->size) {
+                radeonRefillCurrentDmaRegion(rmesa, bytes);
+       }
+
+        if (!rmesa->dma.flush) {
+               /* make sure we have enough space to use this in cmdbuf */
+               rcommonEnsureCmdBufSpace(rmesa,
+                             rmesa->hw.max_state_size + (12*sizeof(int)),
+                             __FUNCTION__);
+               /* if cmdbuf flushed DMA restart */
+               if (!rmesa->dma.current)
+                       goto restart;
+                rmesa->glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
+                rmesa->dma.flush = rcommon_flush_last_swtcl_prim;
+        }
+
+       ASSERT( vsize == rmesa->swtcl.vertex_size * 4 );
+        ASSERT( rmesa->dma.flush == rcommon_flush_last_swtcl_prim );
+        ASSERT( rmesa->dma.current_used +
+                rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 ==
+                rmesa->dma.current_vertexptr );
+
+       head = (rmesa->dma.current->ptr + rmesa->dma.current_vertexptr);
+       rmesa->dma.current_vertexptr += bytes;
+       rmesa->swtcl.numverts += nverts;
+       return head;
+}
+
+void radeonReleaseArrays( GLcontext *ctx, GLuint newinputs )
+{
+   radeonContextPtr radeon = RADEON_CONTEXT( ctx );
+   int i;
+
+   if (radeon->dma.flush) {
+       radeon->dma.flush(radeon->glCtx);
+   }
+   if (radeon->tcl.elt_dma_bo) {
+          radeon_bo_unref(radeon->tcl.elt_dma_bo);
+          radeon->tcl.elt_dma_bo = NULL;
+   }
+   for (i = 0; i < radeon->tcl.aos_count; i++) {
+      if (radeon->tcl.aos[i].bo) {
+         radeon_bo_unref(radeon->tcl.aos[i].bo);
+         radeon->tcl.aos[i].bo = NULL;
+      }
+   }
+}
diff --git a/src/mesa/drivers/dri/radeon/radeon_dma.h b/src/mesa/drivers/dri/radeon/radeon_dma.h
new file mode 100644 (file)
index 0000000..06e388f
--- /dev/null
@@ -0,0 +1,52 @@
+/**************************************************************************
+
+Copyright (C) 2004 Nicolai Haehnle.
+Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+on the rights to use, copy, modify, merge, publish, distribute, sub
+license, and/or sell copies of the Software, and to permit persons to whom
+the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ATI, VA LINUX SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef RADEON_DMA_H
+#define RADEON_DMA_H
+
+void radeonEmitVec8(uint32_t *out, GLvoid * data, int stride, int count);
+void radeonEmitVec12(uint32_t *out, GLvoid * data, int stride, int count);
+
+void rcommon_emit_vector(GLcontext * ctx, struct radeon_aos *aos,
+                        GLvoid * data, int size, int stride, int count);
+
+void radeonRefillCurrentDmaRegion(radeonContextPtr rmesa, int size);
+void radeonAllocDmaRegion(radeonContextPtr rmesa,
+                         struct radeon_bo **pbo, int *poffset,
+                         int bytes, int alignment);
+void radeonReleaseDmaRegion(radeonContextPtr rmesa);
+
+void rcommon_flush_last_swtcl_prim(GLcontext *ctx);
+
+void *rcommonAllocDmaLowVerts(radeonContextPtr rmesa, int nverts, int vsize);
+void radeonReleaseArrays( GLcontext *ctx, GLuint newinputs );
+#endif
diff --git a/src/mesa/drivers/dri/radeon/radeon_fbo.c b/src/mesa/drivers/dri/radeon/radeon_fbo.c
new file mode 100644 (file)
index 0000000..f62ca7f
--- /dev/null
@@ -0,0 +1,588 @@
+/**************************************************************************
+ * 
+ * Copyright 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, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 "main/imports.h"
+#include "main/macros.h"
+#include "main/mtypes.h"
+#include "main/fbobject.h"
+#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
+#include "main/context.h"
+#include "main/texformat.h"
+#include "main/texrender.h"
+
+#include "radeon_common.h"
+#include "radeon_mipmap_tree.h"
+
+#define FILE_DEBUG_FLAG DEBUG_TEXTURE
+#define DBG(...) do {                                           \
+        if (RADEON_DEBUG & FILE_DEBUG_FLAG)                      \
+                _mesa_printf(__VA_ARGS__);                      \
+} while(0)
+
+static struct gl_framebuffer *
+radeon_new_framebuffer(GLcontext *ctx, GLuint name)
+{
+  return _mesa_new_framebuffer(ctx, name);
+}
+
+static void
+radeon_delete_renderbuffer(struct gl_renderbuffer *rb)
+{
+  struct radeon_renderbuffer *rrb = radeon_renderbuffer(rb);
+
+  ASSERT(rrb);
+
+  if (rrb && rrb->bo) {
+    radeon_bo_unref(rrb->bo);
+  }
+  _mesa_free(rrb);
+}
+
+static void *
+radeon_get_pointer(GLcontext *ctx, struct gl_renderbuffer *rb,
+                  GLint x, GLint y)
+{
+  return NULL;
+}
+
+/**
+ * Called via glRenderbufferStorageEXT() to set the format and allocate
+ * storage for a user-created renderbuffer.
+ */
+static GLboolean
+radeon_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
+                                 GLenum internalFormat,
+                                 GLuint width, GLuint height)
+{
+  struct radeon_context *radeon = RADEON_CONTEXT(ctx);
+  struct radeon_renderbuffer *rrb = radeon_renderbuffer(rb);
+  GLboolean software_buffer = 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;
+   }
+
+  radeonFlush(ctx);
+
+  if (rrb->bo)
+    radeon_bo_unref(rrb->bo);
+  
+    
+   if (software_buffer) {
+      return _mesa_soft_renderbuffer_storage(ctx, rb, internalFormat,
+                                             width, height);
+   }
+   else {
+     uint32_t size = width * height * cpp;
+     uint32_t pitch = ((cpp * width + 63) & ~63) / cpp;
+
+     fprintf(stderr,"Allocating %d x %d radeon RBO (pitch %d)\n", width,
+         height, pitch);
+
+     rrb->pitch = pitch * cpp;
+     rrb->cpp = cpp;
+     rrb->bo = radeon_bo_open(radeon->radeonScreen->bom,
+                             0,
+                             size,
+                             0,
+                             RADEON_GEM_DOMAIN_VRAM,
+                             0);
+     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
+radeon_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
+radeon_resize_buffers(GLcontext *ctx, struct gl_framebuffer *fb,
+                    GLuint width, GLuint height)
+{
+     struct radeon_framebuffer *radeon_fb = (struct radeon_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 < 2; i++) {
+      struct gl_renderbuffer *rb = &radeon_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);
+      }
+   }
+}
+
+
+/** Dummy function for gl_renderbuffer::AllocStorage() */
+static GLboolean
+radeon_nop_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
+                        GLenum internalFormat, GLuint width, GLuint height)
+{
+   _mesa_problem(ctx, "radeon_op_alloc_storage should never be called.");
+   return GL_FALSE;
+}
+
+struct radeon_renderbuffer *
+radeon_create_renderbuffer(GLenum format, __DRIdrawablePrivate *driDrawPriv)
+{
+    struct radeon_renderbuffer *rrb;
+
+    rrb = CALLOC_STRUCT(radeon_renderbuffer);
+    if (!rrb)
+       return NULL;
+
+    _mesa_init_renderbuffer(&rrb->base, 0);
+    rrb->base.ClassID = RADEON_RB_CLASS;
+
+    /* XXX format junk */
+    switch (format) {
+       case GL_RGB5:
+           rrb->base._ActualFormat = GL_RGB5;
+           rrb->base._BaseFormat = GL_RGBA;
+           rrb->base.RedBits = 5;
+           rrb->base.GreenBits = 6;
+           rrb->base.BlueBits = 5;
+           rrb->base.DataType = GL_UNSIGNED_BYTE;
+           break;
+       case GL_RGB8:
+           rrb->base._ActualFormat = GL_RGB8;
+           rrb->base._BaseFormat = GL_RGB;
+           rrb->base.RedBits = 8;
+           rrb->base.GreenBits = 8;
+           rrb->base.BlueBits = 8;
+           rrb->base.AlphaBits = 8;
+           rrb->base.DataType = GL_UNSIGNED_BYTE;
+           break;
+       case GL_RGBA8:
+           rrb->base._ActualFormat = GL_RGBA8;
+           rrb->base._BaseFormat = GL_RGBA;
+           rrb->base.RedBits = 8;
+           rrb->base.GreenBits = 8;
+           rrb->base.BlueBits = 8;
+           rrb->base.AlphaBits = 8;
+           rrb->base.DataType = GL_UNSIGNED_BYTE;
+           break;
+       case GL_STENCIL_INDEX8_EXT:
+           rrb->base._ActualFormat = GL_STENCIL_INDEX8_EXT;
+           rrb->base._BaseFormat = GL_STENCIL_INDEX;
+           rrb->base.StencilBits = 8;
+           rrb->base.DataType = GL_UNSIGNED_BYTE;
+           break;
+       case GL_DEPTH_COMPONENT16:
+           rrb->base._ActualFormat = GL_DEPTH_COMPONENT16;
+           rrb->base._BaseFormat = GL_DEPTH_COMPONENT;
+           rrb->base.DepthBits = 16;
+           rrb->base.DataType = GL_UNSIGNED_SHORT;
+           break;
+       case GL_DEPTH_COMPONENT24:
+           rrb->base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+           rrb->base._BaseFormat = GL_DEPTH_COMPONENT;
+           rrb->base.DepthBits = 24;
+           rrb->base.DataType = GL_UNSIGNED_INT;
+           break;
+       case GL_DEPTH24_STENCIL8_EXT:
+           rrb->base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+           rrb->base._BaseFormat = GL_DEPTH_STENCIL_EXT;
+           rrb->base.DepthBits = 24;
+           rrb->base.StencilBits = 8;
+           rrb->base.DataType = GL_UNSIGNED_INT_24_8_EXT;
+           break;
+       default:
+           fprintf(stderr, "%s: Unknown format 0x%04x\n", __FUNCTION__, format);
+           _mesa_delete_renderbuffer(&rrb->base);
+           return NULL;
+    }
+
+    rrb->dPriv = driDrawPriv;
+    rrb->base.InternalFormat = format;
+
+    rrb->base.Delete = radeon_delete_renderbuffer;
+    rrb->base.AllocStorage = radeon_alloc_window_storage;
+    rrb->base.GetPointer = radeon_get_pointer;
+
+    rrb->bo = NULL;
+    return rrb;
+}
+
+static struct gl_renderbuffer *
+radeon_new_renderbuffer(GLcontext * ctx, GLuint name)
+{
+  struct radeon_renderbuffer *rrb;
+
+  rrb = CALLOC_STRUCT(radeon_renderbuffer);
+  if (!rrb)
+    return NULL;
+
+  _mesa_init_renderbuffer(&rrb->base, name);
+  rrb->base.ClassID = RADEON_RB_CLASS;
+
+  rrb->base.Delete = radeon_delete_renderbuffer;
+  rrb->base.AllocStorage = radeon_alloc_renderbuffer_storage;
+  rrb->base.GetPointer = radeon_get_pointer;
+
+  return &rrb->base;
+}
+
+static void
+radeon_bind_framebuffer(GLcontext * ctx, GLenum target,
+                       struct gl_framebuffer *fb, struct gl_framebuffer *fbread)
+{
+   if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) {
+      radeon_draw_buffer(ctx, fb);
+   }
+   else {
+      /* don't need to do anything if target == GL_READ_FRAMEBUFFER_EXT */
+   }
+}
+
+static void
+radeon_framebuffer_renderbuffer(GLcontext * ctx,
+                               struct gl_framebuffer *fb,
+                               GLenum attachment, struct gl_renderbuffer *rb)
+{
+
+   radeonFlush(ctx);
+
+   _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
+   radeon_draw_buffer(ctx, fb);
+}
+
+
+static GLboolean
+radeon_update_wrapper(GLcontext *ctx, struct radeon_renderbuffer *rrb, 
+                    struct gl_texture_image *texImage)
+{
+       int retry = 0;
+restart:
+       if (texImage->TexFormat == &_mesa_texformat_argb8888) {
+               rrb->cpp = 4;
+               rrb->base._ActualFormat = GL_RGBA8;
+               rrb->base._BaseFormat = GL_RGBA;
+               rrb->base.DataType = GL_UNSIGNED_BYTE;
+               DBG("Render to RGBA8 texture OK\n");
+       }
+       else if (texImage->TexFormat == &_mesa_texformat_rgb565) {
+               rrb->cpp = 2;
+               rrb->base._ActualFormat = GL_RGB5;
+               rrb->base._BaseFormat = GL_RGB;
+               rrb->base.DataType = GL_UNSIGNED_SHORT;
+               DBG("Render to RGB5 texture OK\n");
+       }
+       else if (texImage->TexFormat == &_mesa_texformat_z16) {
+               rrb->cpp = 2;
+               rrb->base._ActualFormat = GL_DEPTH_COMPONENT16;
+               rrb->base._BaseFormat = GL_DEPTH_COMPONENT;
+               rrb->base.DataType = GL_UNSIGNED_SHORT;
+               DBG("Render to DEPTH16 texture OK\n");
+       }
+       else if (texImage->TexFormat == &_mesa_texformat_s8_z24) {
+               rrb->cpp = 4;
+               rrb->base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+               rrb->base._BaseFormat = GL_DEPTH_STENCIL_EXT;
+               rrb->base.DataType = GL_UNSIGNED_INT_24_8_EXT;
+               DBG("Render to DEPTH_STENCIL texture OK\n");
+       }
+       else {
+               /* try redoing the FBO */
+               if (retry == 1) {
+                       DBG("Render to texture BAD FORMAT %d\n",
+                           texImage->TexFormat->MesaFormat);
+                       return GL_FALSE;
+               }
+               texImage->TexFormat = radeonChooseTextureFormat(ctx, texImage->InternalFormat, 0,
+                                                               texImage->TexFormat->DataType,
+                                                               1);
+
+               retry++;
+               goto restart;
+       }
+       
+       rrb->pitch = texImage->Width * rrb->cpp;
+       rrb->base.InternalFormat = rrb->base._ActualFormat;
+       rrb->base.Width = texImage->Width;
+       rrb->base.Height = texImage->Height;
+       rrb->base.RedBits = texImage->TexFormat->RedBits;
+       rrb->base.GreenBits = texImage->TexFormat->GreenBits;
+       rrb->base.BlueBits = texImage->TexFormat->BlueBits;
+       rrb->base.AlphaBits = texImage->TexFormat->AlphaBits;
+       rrb->base.DepthBits = texImage->TexFormat->DepthBits;
+       
+       rrb->base.Delete = radeon_delete_renderbuffer;
+       rrb->base.AllocStorage = radeon_nop_alloc_storage;
+       
+       return GL_TRUE;
+}
+
+
+static struct radeon_renderbuffer *
+radeon_wrap_texture(GLcontext * ctx, struct gl_texture_image *texImage)
+{
+  const GLuint name = ~0;   /* not significant, but distinct for debugging */
+  struct radeon_renderbuffer *rrb;
+
+   /* make an radeon_renderbuffer to wrap the texture image */
+   rrb = CALLOC_STRUCT(radeon_renderbuffer);
+   if (!rrb) {
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glFramebufferTexture");
+      return NULL;
+   }
+
+   _mesa_init_renderbuffer(&rrb->base, name);
+   rrb->base.ClassID = RADEON_RB_CLASS;
+
+   if (!radeon_update_wrapper(ctx, rrb, texImage)) {
+      _mesa_free(rrb);
+      return NULL;
+   }
+
+   return rrb;
+  
+}
+static void
+radeon_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 radeon_renderbuffer *rrb = radeon_renderbuffer(att->Renderbuffer);
+   radeon_texture_image *radeon_image;
+   GLuint imageOffset;
+
+   (void) fb;
+
+   ASSERT(newImage);
+
+   if (newImage->Border != 0) {
+      /* Fallback on drawing to a texture with a border, which won't have a
+       * miptree.
+       */
+      _mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
+      _mesa_render_texture(ctx, fb, att);
+      return;
+   }
+   else if (!rrb) {
+      rrb = radeon_wrap_texture(ctx, newImage);
+      if (rrb) {
+         /* bind the wrapper to the attachment point */
+         _mesa_reference_renderbuffer(&att->Renderbuffer, &rrb->base);
+      }
+      else {
+         /* fallback to software rendering */
+         _mesa_render_texture(ctx, fb, att);
+         return;
+      }
+   }
+
+   if (!radeon_update_wrapper(ctx, rrb, 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,
+       rrb->base.RefCount);
+
+   /* point the renderbufer's region to the texture image region */
+   radeon_image = (radeon_texture_image *)newImage;
+   if (rrb->bo != radeon_image->mt->bo) {
+      if (rrb->bo)
+       radeon_bo_unref(rrb->bo);
+      rrb->bo = radeon_image->mt->bo;
+      radeon_bo_ref(rrb->bo);
+   }
+
+   /* compute offset of the particular 2D image within the texture region */
+   imageOffset = radeon_miptree_image_offset(radeon_image->mt,
+                                            att->CubeMapFace,
+                                            att->TextureLevel);
+
+   if (att->Texture->Target == GL_TEXTURE_3D) {
+      GLuint offsets[6];
+      radeon_miptree_depth_offsets(radeon_image->mt, att->TextureLevel,
+                                  offsets);
+      imageOffset += offsets[att->Zoffset];
+   }
+
+   /* store that offset in the region */
+   rrb->draw_offset = imageOffset;
+
+   /* update drawing region, etc */
+   radeon_draw_buffer(ctx, fb);
+}
+
+static void
+radeon_finish_render_texture(GLcontext * ctx,
+                            struct gl_renderbuffer_attachment *att)
+{
+
+}
+static void
+radeon_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
+{
+}
+
+static void
+radeon_blit_framebuffer(GLcontext *ctx,
+                       GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+                       GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+                       GLbitfield mask, GLenum filter)
+{
+}
+
+void radeon_fbo_init(struct radeon_context *radeon)
+{
+  radeon->glCtx->Driver.NewFramebuffer = radeon_new_framebuffer;
+  radeon->glCtx->Driver.NewRenderbuffer = radeon_new_renderbuffer;
+  radeon->glCtx->Driver.BindFramebuffer = radeon_bind_framebuffer;
+  radeon->glCtx->Driver.FramebufferRenderbuffer = radeon_framebuffer_renderbuffer;
+  radeon->glCtx->Driver.RenderTexture = radeon_render_texture;
+  radeon->glCtx->Driver.FinishRenderTexture = radeon_finish_render_texture;
+  radeon->glCtx->Driver.ResizeBuffers = radeon_resize_buffers;
+  radeon->glCtx->Driver.ValidateFramebuffer = radeon_validate_framebuffer;
+  radeon->glCtx->Driver.BlitFramebuffer = radeon_blit_framebuffer;
+}
+
+  
+void radeon_renderbuffer_set_bo(struct radeon_renderbuffer *rb,
+                               struct radeon_bo *bo)
+{
+  struct radeon_bo *old;
+  old = rb->bo;
+  rb->bo = bo;
+  radeon_bo_ref(bo);
+  if (old)
+    radeon_bo_unref(old);
+}
index 09acf6b4f85d9c31931928b2e488281cc49ff632..01c45df2dfa721379fa1ba77e0029a5fbfd20e4a 100644 (file)
@@ -35,7 +35,21 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
 #include <sched.h>
-#include <errno.h> 
+#include <errno.h>
+
+#include "main/attrib.h"
+#include "main/enable.h"
+#include "main/blend.h"
+#include "main/bufferobj.h"
+#include "main/buffers.h"
+#include "main/depth.h"
+#include "main/shaders.h"
+#include "main/texstate.h"
+#include "main/varray.h"
+#include "glapi/dispatch.h"
+#include "swrast/swrast.h"
+#include "main/stencil.h"
+#include "main/matrix.h"
 
 #include "main/glheader.h"
 #include "main/imports.h"
@@ -43,6 +57,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "swrast/swrast.h"
 
 #include "radeon_context.h"
+#include "radeon_common.h"
 #include "radeon_state.h"
 #include "radeon_ioctl.h"
 #include "radeon_tcl.h"
@@ -58,75 +73,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define RADEON_IDLE_RETRY           16
 
 
-static void radeonWaitForIdle( radeonContextPtr rmesa );
-static int radeonFlushCmdBufLocked( radeonContextPtr rmesa, 
-                                   const char * caller );
-
-static void print_state_atom( struct radeon_state_atom *state )
-{
-   int i;
-
-   fprintf(stderr, "emit %s/%d\n", state->name, state->cmd_size);
-
-   if (RADEON_DEBUG & DEBUG_VERBOSE) 
-      for (i = 0 ; i < state->cmd_size ; i++) 
-        fprintf(stderr, "\t%s[%d]: %x\n", state->name, i, state->cmd[i]);
-
-}
-
-static void radeonSaveHwState( radeonContextPtr rmesa )
-{
-   struct radeon_state_atom *atom;
-   char * dest = rmesa->backup_store.cmd_buf;
-
-   if (RADEON_DEBUG & DEBUG_STATE)
-      fprintf(stderr, "%s\n", __FUNCTION__);
-   
-   rmesa->backup_store.cmd_used = 0;
-
-   foreach( atom, &rmesa->hw.atomlist ) {
-      if ( atom->check( rmesa->glCtx ) ) {
-        int size = atom->cmd_size * 4;
-        memcpy( dest, atom->cmd, size);
-        dest += size;
-        rmesa->backup_store.cmd_used += size;
-        if (RADEON_DEBUG & DEBUG_STATE)
-           print_state_atom( atom );
-      }
-   }
-
-   assert( rmesa->backup_store.cmd_used <= RADEON_CMD_BUF_SZ );
-   if (RADEON_DEBUG & DEBUG_STATE)
-      fprintf(stderr, "Returning to radeonEmitState\n");
-}
-
-/* At this point we were in FlushCmdBufLocked but we had lost our context, so
- * we need to unwire our current cmdbuf, hook the one with the saved state in
- * it, flush it, and then put the current one back.  This is so commands at the
- * start of a cmdbuf can rely on the state being kept from the previous one.
- */
-static void radeonBackUpAndEmitLostStateLocked( radeonContextPtr rmesa )
-{
-   GLuint nr_released_bufs;
-   struct radeon_store saved_store;
-
-   if (rmesa->backup_store.cmd_used == 0)
-      return;
-
-   if (RADEON_DEBUG & DEBUG_STATE)
-      fprintf(stderr, "Emitting backup state on lost context\n");
-
-   rmesa->lost_context = GL_FALSE;
-
-   nr_released_bufs = rmesa->dma.nr_released_bufs;
-   saved_store = rmesa->store;
-   rmesa->dma.nr_released_bufs = 0;
-   rmesa->store = rmesa->backup_store;
-   radeonFlushCmdBufLocked( rmesa, __FUNCTION__ );
-   rmesa->dma.nr_released_bufs = nr_released_bufs;
-   rmesa->store = saved_store;
-}
-
 /* =============================================================
  * Kernel command buffer handling
  */
@@ -134,965 +80,386 @@ static void radeonBackUpAndEmitLostStateLocked( radeonContextPtr rmesa )
 /* The state atoms will be emitted in the order they appear in the atom list,
  * so this step is important.
  */
-void radeonSetUpAtomList( radeonContextPtr rmesa )
+void radeonSetUpAtomList( r100ContextPtr rmesa )
 {
-   int i, mtu = rmesa->glCtx->Const.MaxTextureUnits;
-
-   make_empty_list(&rmesa->hw.atomlist);
-   rmesa->hw.atomlist.name = "atom-list";
-
-   insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.ctx);
-   insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.set);
-   insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.lin);
-   insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.msk);
-   insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.vpt);
-   insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.tcl);
-   insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.msc);
+   int i, mtu = rmesa->radeon.glCtx->Const.MaxTextureUnits;
+
+   make_empty_list(&rmesa->radeon.hw.atomlist);
+   rmesa->radeon.hw.atomlist.name = "atom-list";
+
+   insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.ctx);
+   insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.set);
+   insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.lin);
+   insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.msk);
+   insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.vpt);
+   insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.tcl);
+   insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.msc);
    for (i = 0; i < mtu; ++i) {
-       insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.tex[i]);
-       insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.txr[i]);
-       insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.cube[i]);
+       insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.tex[i]);
+       insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.txr[i]);
+       insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.cube[i]);
    }
-   insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.zbs);
-   insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.mtl);
+   insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.zbs);
+   insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.mtl);
    for (i = 0; i < 3 + mtu; ++i)
-      insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.mat[i]);
+      insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.mat[i]);
    for (i = 0; i < 8; ++i)
-      insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.lit[i]);
+      insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.lit[i]);
    for (i = 0; i < 6; ++i)
-      insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.ucp[i]);
-   insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.eye);
-   insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.grd);
-   insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.fog);
-   insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.glt);
+      insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.ucp[i]);
+   insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.eye);
+   insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.grd);
+   insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.fog);
+   insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.glt);
 }
 
-void radeonEmitState( radeonContextPtr rmesa )
+void radeonEmitScissor(r100ContextPtr rmesa)
 {
-   struct radeon_state_atom *atom;
-   char *dest;
-
-   if (RADEON_DEBUG & (DEBUG_STATE|DEBUG_PRIMS))
-      fprintf(stderr, "%s\n", __FUNCTION__);
-
-   if (rmesa->save_on_next_emit) {
-      radeonSaveHwState(rmesa);
-      rmesa->save_on_next_emit = GL_FALSE;
-   }
-
-   /* this code used to return here but now it emits zbs */
-
-   /* To avoid going across the entire set of states multiple times, just check
-    * for enough space for the case of emitting all state, and inline the
-    * radeonAllocCmdBuf code here without all the checks.
-    */
-   radeonEnsureCmdBufSpace(rmesa, rmesa->hw.max_state_size);
-   dest = rmesa->store.cmd_buf + rmesa->store.cmd_used;
-
-   /* We always always emit zbs, this is due to a bug found by keithw in
-      the hardware and rediscovered after Erics changes by me.
-      if you ever touch this code make sure you emit zbs otherwise
-      you get tcl lockups on at least M7/7500 class of chips - airlied */
-   rmesa->hw.zbs.dirty=1;
-
-   if (RADEON_DEBUG & DEBUG_STATE) {
-      foreach(atom, &rmesa->hw.atomlist) {
-        if (atom->dirty || rmesa->hw.all_dirty) {
-           if (atom->check(rmesa->glCtx))
-              print_state_atom(atom);
-           else
-              fprintf(stderr, "skip state %s\n", atom->name);
-        }
-      }
-   }
-
-   foreach(atom, &rmesa->hw.atomlist) {
-      if (rmesa->hw.all_dirty)
-        atom->dirty = GL_TRUE;
-      if (!(rmesa->radeonScreen->chip_flags & RADEON_CHIPSET_TCL) &&
-          atom->is_tcl)
-        atom->dirty = GL_FALSE;
-      if (atom->dirty) {
-        if (atom->check(rmesa->glCtx)) {
-           int size = atom->cmd_size * 4;
-           memcpy(dest, atom->cmd, size);
-           dest += size;
-           rmesa->store.cmd_used += size;
-           atom->dirty = GL_FALSE;
-        }
-      }
-   }
-
-   assert(rmesa->store.cmd_used <= RADEON_CMD_BUF_SZ);
-   rmesa->hw.is_dirty = GL_FALSE;
-   rmesa->hw.all_dirty = GL_FALSE;
+    BATCH_LOCALS(&rmesa->radeon);
+    if (!rmesa->radeon.radeonScreen->kernel_mm) {
+       return;
+    }
+    if (rmesa->radeon.state.scissor.enabled) {
+        BEGIN_BATCH(6);
+        OUT_BATCH(CP_PACKET0(RADEON_PP_CNTL, 0));
+        OUT_BATCH(rmesa->hw.ctx.cmd[CTX_PP_CNTL] | RADEON_SCISSOR_ENABLE);
+        OUT_BATCH(CP_PACKET0(RADEON_RE_TOP_LEFT, 0));
+        OUT_BATCH((rmesa->radeon.state.scissor.rect.y1 << 16) |
+                  rmesa->radeon.state.scissor.rect.x1);
+        OUT_BATCH(CP_PACKET0(RADEON_RE_WIDTH_HEIGHT, 0));
+        OUT_BATCH(((rmesa->radeon.state.scissor.rect.y2 - 1) << 16) |
+                  (rmesa->radeon.state.scissor.rect.x2 - 1));
+        END_BATCH();
+    } else {
+        BEGIN_BATCH(2);
+        OUT_BATCH(CP_PACKET0(RADEON_PP_CNTL, 0));
+        OUT_BATCH(rmesa->hw.ctx.cmd[CTX_PP_CNTL] & ~RADEON_SCISSOR_ENABLE);
+        END_BATCH();
+    }
 }
 
 /* Fire a section of the retained (indexed_verts) buffer as a regular
- * primtive.  
+ * primtive.
  */
-extern void radeonEmitVbufPrim( radeonContextPtr rmesa,
+extern void radeonEmitVbufPrim( r100ContextPtr rmesa,
                                GLuint vertex_format,
                                GLuint primitive,
                                GLuint vertex_nr )
 {
-   drm_radeon_cmd_header_t *cmd;
-
+   BATCH_LOCALS(&rmesa->radeon);
 
    assert(!(primitive & RADEON_CP_VC_CNTL_PRIM_WALK_IND));
-   
-   radeonEmitState( rmesa );
 
-   if (RADEON_DEBUG & DEBUG_IOCTL)
-      fprintf(stderr, "%s cmd_used/4: %d\n", __FUNCTION__,
-             rmesa->store.cmd_used/4);
-   
-   cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, VBUF_BUFSZ,
-                                                      __FUNCTION__ );
+   radeonEmitState(&rmesa->radeon);
+   radeonEmitScissor(rmesa);
+
 #if RADEON_OLD_PACKETS
-   cmd[0].i = 0;
-   cmd[0].header.cmd_type = RADEON_CMD_PACKET3_CLIP;
-   cmd[1].i = RADEON_CP_PACKET3_3D_RNDR_GEN_INDX_PRIM | (3 << 16);
-   cmd[2].i = rmesa->ioctl.vertex_offset;
-   cmd[3].i = vertex_nr;
-   cmd[4].i = vertex_format;
-   cmd[5].i = (primitive | 
-              RADEON_CP_VC_CNTL_PRIM_WALK_LIST |
-              RADEON_CP_VC_CNTL_COLOR_ORDER_RGBA |
-              RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE |
-              (vertex_nr << RADEON_CP_VC_CNTL_NUM_SHIFT));
+   BEGIN_BATCH(8);
+   OUT_BATCH_PACKET3_CLIP(RADEON_CP_PACKET3_3D_RNDR_GEN_INDX_PRIM, 3);
+   if (!rmesa->radeon.radeonScreen->kernel_mm) {
+     OUT_BATCH_RELOC(rmesa->ioctl.vertex_offset, rmesa->ioctl.bo, rmesa->ioctl.vertex_offset, RADEON_GEM_DOMAIN_GTT, 0, 0);
+   } else {
+     OUT_BATCH(rmesa->ioctl.vertex_offset);
+   }
 
-   if (RADEON_DEBUG & DEBUG_PRIMS)
-      fprintf(stderr, "%s: header 0x%x offt 0x%x vfmt 0x%x vfcntl %x \n",
-             __FUNCTION__,
-             cmd[1].i, cmd[2].i, cmd[4].i, cmd[5].i);
-#else
-   cmd[0].i = 0;
-   cmd[0].header.cmd_type = RADEON_CMD_PACKET3_CLIP;
-   cmd[1].i = RADEON_CP_PACKET3_3D_DRAW_VBUF | (1 << 16);
-   cmd[2].i = vertex_format;
-   cmd[3].i = (primitive | 
-              RADEON_CP_VC_CNTL_PRIM_WALK_LIST |
-              RADEON_CP_VC_CNTL_COLOR_ORDER_RGBA |
-              RADEON_CP_VC_CNTL_MAOS_ENABLE |
-              RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE |
-              (vertex_nr << RADEON_CP_VC_CNTL_NUM_SHIFT));
+   OUT_BATCH(vertex_nr);
+   OUT_BATCH(vertex_format);
+   OUT_BATCH(primitive |  RADEON_CP_VC_CNTL_PRIM_WALK_LIST |
+            RADEON_CP_VC_CNTL_COLOR_ORDER_RGBA |
+            RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE |
+            (vertex_nr << RADEON_CP_VC_CNTL_NUM_SHIFT));
+
+   if (rmesa->radeon.radeonScreen->kernel_mm) {
+     radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
+                          rmesa->ioctl.bo,
+                          RADEON_GEM_DOMAIN_GTT,
+                          0, 0);
+   }
 
+   END_BATCH();
 
-   if (RADEON_DEBUG & DEBUG_PRIMS)
-      fprintf(stderr, "%s: header 0x%x vfmt 0x%x vfcntl %x \n",
-             __FUNCTION__,
-             cmd[1].i, cmd[2].i, cmd[3].i);
+#else
+   BEGIN_BATCH(4);
+   OUT_BATCH_PACKET3_CLIP(RADEON_CP_PACKET3_3D_DRAW_VBUF, 1);
+   OUT_BATCH(vertex_format);
+   OUT_BATCH(primitive |
+            RADEON_CP_VC_CNTL_PRIM_WALK_LIST |
+            RADEON_CP_VC_CNTL_COLOR_ORDER_RGBA |
+            RADEON_CP_VC_CNTL_MAOS_ENABLE |
+            RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE |
+            (vertex_nr << RADEON_CP_VC_CNTL_NUM_SHIFT));
+   END_BATCH();
 #endif
 }
 
-
-void radeonFlushElts( radeonContextPtr rmesa )
+void radeonFlushElts( GLcontext *ctx )
 {
-   int *cmd = (int *)(rmesa->store.cmd_buf + rmesa->store.elts_start);
-   int dwords;
-#if RADEON_OLD_PACKETS
-   int nr = (rmesa->store.cmd_used - (rmesa->store.elts_start + 24)) / 2;
-#else
-   int nr = (rmesa->store.cmd_used - (rmesa->store.elts_start + 16)) / 2;
-#endif
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
+   BATCH_LOCALS(&rmesa->radeon);
+   int nr;
+   uint32_t *cmd = (uint32_t *)(rmesa->radeon.cmdbuf.cs->packets + rmesa->tcl.elt_cmd_start);
+   int dwords = (rmesa->radeon.cmdbuf.cs->section_ndw - rmesa->radeon.cmdbuf.cs->section_cdw);
 
    if (RADEON_DEBUG & DEBUG_IOCTL)
       fprintf(stderr, "%s\n", __FUNCTION__);
 
-   assert( rmesa->dma.flush == radeonFlushElts );
-   rmesa->dma.flush = NULL;
+   assert( rmesa->radeon.dma.flush == radeonFlushElts );
+   rmesa->radeon.dma.flush = NULL;
 
-   /* Cope with odd number of elts:
-    */
-   rmesa->store.cmd_used = (rmesa->store.cmd_used + 2) & ~2;
-   dwords = (rmesa->store.cmd_used - rmesa->store.elts_start) / 4;
+   nr = rmesa->tcl.elt_used;
+
+#if RADEON_OLD_PACKETS
+   if (rmesa->radeon.radeonScreen->kernel_mm) {
+     dwords -= 2;
+   }
+#endif
 
 #if RADEON_OLD_PACKETS
-   cmd[1] |= (dwords - 3) << 16;
+   cmd[1] |= (dwords + 3) << 16;
    cmd[5] |= nr << RADEON_CP_VC_CNTL_NUM_SHIFT;
 #else
-   cmd[1] |= (dwords - 3) << 16;
+   cmd[1] |= (dwords + 2) << 16;
    cmd[3] |= nr << RADEON_CP_VC_CNTL_NUM_SHIFT;
 #endif
 
+   rmesa->radeon.cmdbuf.cs->cdw += dwords;
+   rmesa->radeon.cmdbuf.cs->section_cdw += dwords;
+
+#if RADEON_OLD_PACKETS
+   if (rmesa->radeon.radeonScreen->kernel_mm) {
+      radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
+                           rmesa->ioctl.bo,
+                           RADEON_GEM_DOMAIN_GTT,
+                           0, 0);
+   }
+#endif
+
+   END_BATCH();
+
    if (RADEON_DEBUG & DEBUG_SYNC) {
       fprintf(stderr, "%s: Syncing\n", __FUNCTION__);
-      radeonFinish( rmesa->glCtx );
+      radeonFinish( rmesa->radeon.glCtx );
    }
-}
 
+}
 
-GLushort *radeonAllocEltsOpenEnded( radeonContextPtr rmesa,
+GLushort *radeonAllocEltsOpenEnded( r100ContextPtr rmesa,
                                    GLuint vertex_format,
                                    GLuint primitive,
                                    GLuint min_nr )
 {
-   drm_radeon_cmd_header_t *cmd;
    GLushort *retval;
+   int align_min_nr;
+   BATCH_LOCALS(&rmesa->radeon);
 
    if (RADEON_DEBUG & DEBUG_IOCTL)
-      fprintf(stderr, "%s %d\n", __FUNCTION__, min_nr);
+      fprintf(stderr, "%s %d prim %x\n", __FUNCTION__, min_nr, primitive);
 
    assert((primitive & RADEON_CP_VC_CNTL_PRIM_WALK_IND));
-   
-   radeonEmitState( rmesa );
-   
-   cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa,
-                                                      ELTS_BUFSZ(min_nr),
-                                                      __FUNCTION__ );
+
+   radeonEmitState(&rmesa->radeon);
+   radeonEmitScissor(rmesa);
+
+   rmesa->tcl.elt_cmd_start = rmesa->radeon.cmdbuf.cs->cdw;
+
+   /* round up min_nr to align the state */
+   align_min_nr = (min_nr + 1) & ~1;
+
 #if RADEON_OLD_PACKETS
-   cmd[0].i = 0;
-   cmd[0].header.cmd_type = RADEON_CMD_PACKET3_CLIP;
-   cmd[1].i = RADEON_CP_PACKET3_3D_RNDR_GEN_INDX_PRIM;
-   cmd[2].i = rmesa->ioctl.vertex_offset;
-   cmd[3].i = 0xffff;
-   cmd[4].i = vertex_format;
-   cmd[5].i = (primitive | 
-              RADEON_CP_VC_CNTL_PRIM_WALK_IND |
-              RADEON_CP_VC_CNTL_COLOR_ORDER_RGBA |
-              RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE);
-
-   retval = (GLushort *)(cmd+6);
-#else   
-   cmd[0].i = 0;
-   cmd[0].header.cmd_type = RADEON_CMD_PACKET3_CLIP;
-   cmd[1].i = RADEON_CP_PACKET3_3D_DRAW_INDX;
-   cmd[2].i = vertex_format;
-   cmd[3].i = (primitive | 
-              RADEON_CP_VC_CNTL_PRIM_WALK_IND |
-              RADEON_CP_VC_CNTL_COLOR_ORDER_RGBA |
-              RADEON_CP_VC_CNTL_MAOS_ENABLE |
-              RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE);
-
-   retval = (GLushort *)(cmd+4);
+   BEGIN_BATCH_NO_AUTOSTATE(2+ELTS_BUFSZ(align_min_nr)/4);
+   OUT_BATCH_PACKET3_CLIP(RADEON_CP_PACKET3_3D_RNDR_GEN_INDX_PRIM, 0);
+   if (!rmesa->radeon.radeonScreen->kernel_mm) {
+     OUT_BATCH_RELOC(rmesa->ioctl.vertex_offset, rmesa->ioctl.bo, rmesa->ioctl.vertex_offset, RADEON_GEM_DOMAIN_GTT, 0, 0);
+   } else {
+     OUT_BATCH(rmesa->ioctl.vertex_offset);
+   }
+   OUT_BATCH(0xffff);
+   OUT_BATCH(vertex_format);
+   OUT_BATCH(primitive |
+            RADEON_CP_VC_CNTL_PRIM_WALK_IND |
+            RADEON_CP_VC_CNTL_COLOR_ORDER_RGBA |
+            RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE);
+#else
+   BEGIN_BATCH_NO_AUTOSTATE(ELTS_BUFSZ(align_min_nr)/4);
+   OUT_BATCH_PACKET3_CLIP(RADEON_CP_PACKET3_DRAW_INDX, 0);
+   OUT_BATCH(vertex_format);
+   OUT_BATCH(primitive |
+            RADEON_CP_VC_CNTL_PRIM_WALK_IND |
+            RADEON_CP_VC_CNTL_COLOR_ORDER_RGBA |
+            RADEON_CP_VC_CNTL_MAOS_ENABLE |
+            RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE);
 #endif
 
-   if (RADEON_DEBUG & DEBUG_PRIMS)
-      fprintf(stderr, "%s: header 0x%x vfmt 0x%x prim %x \n",
-             __FUNCTION__,
-             cmd[1].i, vertex_format, primitive);
 
-   assert(!rmesa->dma.flush);
-   rmesa->glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
-   rmesa->dma.flush = radeonFlushElts;
+   rmesa->tcl.elt_cmd_offset = rmesa->radeon.cmdbuf.cs->cdw;
+   rmesa->tcl.elt_used = min_nr;
 
-   rmesa->store.elts_start = ((char *)cmd) - rmesa->store.cmd_buf;
+   retval = (GLushort *)(rmesa->radeon.cmdbuf.cs->packets + rmesa->tcl.elt_cmd_offset);
 
-   return retval;
-}
+   if (RADEON_DEBUG & DEBUG_PRIMS)
+      fprintf(stderr, "%s: header prim %x \n",
+             __FUNCTION__, primitive);
 
+   assert(!rmesa->radeon.dma.flush);
+   rmesa->radeon.glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
+   rmesa->radeon.dma.flush = radeonFlushElts;
 
+   return retval;
+}
 
-void radeonEmitVertexAOS( radeonContextPtr rmesa,
+void radeonEmitVertexAOS( r100ContextPtr rmesa,
                          GLuint vertex_size,
+                         struct radeon_bo *bo,
                          GLuint offset )
 {
 #if RADEON_OLD_PACKETS
-   rmesa->ioctl.vertex_size = vertex_size;
    rmesa->ioctl.vertex_offset = offset;
+   rmesa->ioctl.bo = bo;
 #else
-   drm_radeon_cmd_header_t *cmd;
+   BATCH_LOCALS(&rmesa->radeon);
 
    if (RADEON_DEBUG & (DEBUG_PRIMS|DEBUG_IOCTL))
       fprintf(stderr, "%s:  vertex_size 0x%x offset 0x%x \n",
              __FUNCTION__, vertex_size, offset);
 
-   cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, VERT_AOS_BUFSZ,
-                                                 __FUNCTION__ );
+   BEGIN_BATCH(7);
+   OUT_BATCH_PACKET3(RADEON_CP_PACKET3_3D_LOAD_VBPNTR, 2);
+   OUT_BATCH(1);
+   OUT_BATCH(vertex_size | (vertex_size << 8));
+   OUT_BATCH_RELOC(offset, bo, offset, RADEON_GEM_DOMAIN_GTT, 0, 0);
+   END_BATCH();
 
-   cmd[0].i = 0;
-   cmd[0].header.cmd_type = RADEON_CMD_PACKET3;
-   cmd[1].i = RADEON_CP_PACKET3_3D_LOAD_VBPNTR | (2 << 16);
-   cmd[2].i = 1;
-   cmd[3].i = vertex_size | (vertex_size << 8);
-   cmd[4].i = offset;
 #endif
 }
-                      
 
-void radeonEmitAOS( radeonContextPtr rmesa,
-                   struct radeon_dma_region **component,
+
+void radeonEmitAOS( r100ContextPtr rmesa,
                    GLuint nr,
                    GLuint offset )
 {
 #if RADEON_OLD_PACKETS
    assert( nr == 1 );
-   assert( component[0]->aos_size == component[0]->aos_stride );
-   rmesa->ioctl.vertex_size = component[0]->aos_size;
-   rmesa->ioctl.vertex_offset = 
-      (component[0]->aos_start + offset * component[0]->aos_stride * 4);
+   rmesa->ioctl.bo = rmesa->radeon.tcl.aos[0].bo;
+   rmesa->ioctl.vertex_offset =
+     (rmesa->radeon.tcl.aos[0].offset + offset * rmesa->radeon.tcl.aos[0].stride * 4);
 #else
-   drm_radeon_cmd_header_t *cmd;
-   int sz = AOS_BUFSZ(nr);
+   BATCH_LOCALS(&rmesa->radeon);
+   uint32_t voffset;
+   //   int sz = AOS_BUFSZ(nr);
+   int sz = 1 + (nr >> 1) * 3 + (nr & 1) * 2;
    int i;
-   int *tmp;
 
    if (RADEON_DEBUG & DEBUG_IOCTL)
       fprintf(stderr, "%s\n", __FUNCTION__);
 
-
-   cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, sz,
-                                                 __FUNCTION__ );
-   cmd[0].i = 0;
-   cmd[0].header.cmd_type = RADEON_CMD_PACKET3;
-   cmd[1].i = RADEON_CP_PACKET3_3D_LOAD_VBPNTR | (((sz / sizeof(int))-3) << 16);
-   cmd[2].i = nr;
-   tmp = &cmd[0].i;
-   cmd += 3;
-
-   for (i = 0 ; i < nr ; i++) {
-      if (i & 1) {
-        cmd[0].i |= ((component[i]->aos_stride << 24) | 
-                     (component[i]->aos_size << 16));
-        cmd[2].i = (component[i]->aos_start + 
-                    offset * component[i]->aos_stride * 4);
-        cmd += 3;
+   BEGIN_BATCH(sz+2+(nr * 2));
+   OUT_BATCH_PACKET3(RADEON_CP_PACKET3_3D_LOAD_VBPNTR, sz - 1);
+   OUT_BATCH(nr);
+
+   if (!rmesa->radeon.radeonScreen->kernel_mm) {
+      for (i = 0; i + 1 < nr; i += 2) {
+        OUT_BATCH((rmesa->radeon.tcl.aos[i].components << 0) |
+                  (rmesa->radeon.tcl.aos[i].stride << 8) |
+                  (rmesa->radeon.tcl.aos[i + 1].components << 16) |
+                  (rmesa->radeon.tcl.aos[i + 1].stride << 24));
+
+        voffset =  rmesa->radeon.tcl.aos[i + 0].offset +
+           offset * 4 * rmesa->radeon.tcl.aos[i + 0].stride;
+        OUT_BATCH_RELOC(voffset,
+                        rmesa->radeon.tcl.aos[i].bo,
+                        voffset,
+                        RADEON_GEM_DOMAIN_GTT,
+                        0, 0);
+        voffset =  rmesa->radeon.tcl.aos[i + 1].offset +
+           offset * 4 * rmesa->radeon.tcl.aos[i + 1].stride;
+        OUT_BATCH_RELOC(voffset,
+                        rmesa->radeon.tcl.aos[i+1].bo,
+                        voffset,
+                        RADEON_GEM_DOMAIN_GTT,
+                        0, 0);
       }
-      else {
-        cmd[0].i = ((component[i]->aos_stride << 8) | 
-                    (component[i]->aos_size << 0));
-        cmd[1].i = (component[i]->aos_start + 
-                    offset * component[i]->aos_stride * 4);
-      }
-   }
-
-   if (RADEON_DEBUG & DEBUG_VERTS) {
-      fprintf(stderr, "%s:\n", __FUNCTION__);
-      for (i = 0 ; i < sz ; i++)
-        fprintf(stderr, "   %d: %x\n", i, tmp[i]);
-   }
-#endif
-}
-
-/* using already shifted color_fmt! */
-void radeonEmitBlit( radeonContextPtr rmesa, /* FIXME: which drmMinor is required? */
-                  GLuint color_fmt,
-                  GLuint src_pitch,
-                  GLuint src_offset,
-                  GLuint dst_pitch,
-                  GLuint dst_offset,
-                  GLint srcx, GLint srcy,
-                  GLint dstx, GLint dsty,
-                  GLuint w, GLuint h )
-{
-   drm_radeon_cmd_header_t *cmd;
-
-   if (RADEON_DEBUG & DEBUG_IOCTL)
-      fprintf(stderr, "%s src %x/%x %d,%d dst: %x/%x %d,%d sz: %dx%d\n",
-             __FUNCTION__, 
-             src_pitch, src_offset, srcx, srcy,
-             dst_pitch, dst_offset, dstx, dsty,
-             w, h);
-
-   assert( (src_pitch & 63) == 0 );
-   assert( (dst_pitch & 63) == 0 );
-   assert( (src_offset & 1023) == 0 ); 
-   assert( (dst_offset & 1023) == 0 ); 
-   assert( w < (1<<16) );
-   assert( h < (1<<16) );
-
-   cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, 8 * sizeof(int),
-                                                 __FUNCTION__ );
-
-
-   cmd[0].i = 0;
-   cmd[0].header.cmd_type = RADEON_CMD_PACKET3;
-   cmd[1].i = RADEON_CP_PACKET3_CNTL_BITBLT_MULTI | (5 << 16);
-   cmd[2].i = (RADEON_GMC_SRC_PITCH_OFFSET_CNTL |
-              RADEON_GMC_DST_PITCH_OFFSET_CNTL |
-              RADEON_GMC_BRUSH_NONE |
-              color_fmt |
-              RADEON_GMC_SRC_DATATYPE_COLOR |
-              RADEON_ROP3_S |
-              RADEON_DP_SRC_SOURCE_MEMORY |
-              RADEON_GMC_CLR_CMP_CNTL_DIS |
-              RADEON_GMC_WR_MSK_DIS );
-
-   cmd[3].i = ((src_pitch/64)<<22) | (src_offset >> 10);
-   cmd[4].i = ((dst_pitch/64)<<22) | (dst_offset >> 10);
-   cmd[5].i = (srcx << 16) | srcy;
-   cmd[6].i = (dstx << 16) | dsty; /* dst */
-   cmd[7].i = (w << 16) | h;
-}
-
-
-void radeonEmitWait( radeonContextPtr rmesa, GLuint flags )
-{
-   drm_radeon_cmd_header_t *cmd;
-
-   assert( !(flags & ~(RADEON_WAIT_2D|RADEON_WAIT_3D)) );
-
-   cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, 1 * sizeof(int),
-                                          __FUNCTION__ );
-   cmd[0].i = 0;
-   cmd[0].wait.cmd_type = RADEON_CMD_WAIT;
-   cmd[0].wait.flags = flags;
-}
 
-
-static int radeonFlushCmdBufLocked( radeonContextPtr rmesa, 
-                                   const char * caller )
-{
-   int ret, i;
-   drm_radeon_cmd_buffer_t cmd;
-
-   if (rmesa->lost_context)
-      radeonBackUpAndEmitLostStateLocked(rmesa);
-
-   if (RADEON_DEBUG & DEBUG_IOCTL) {
-      fprintf(stderr, "%s from %s\n", __FUNCTION__, caller); 
-
-      if (RADEON_DEBUG & DEBUG_VERBOSE) 
-        for (i = 0 ; i < rmesa->store.cmd_used ; i += 4 )
-           fprintf(stderr, "%d: %x\n", i/4, 
-                   *(int *)(&rmesa->store.cmd_buf[i]));
-   }
-
-   if (RADEON_DEBUG & DEBUG_DMA)
-      fprintf(stderr, "%s: Releasing %d buffers\n", __FUNCTION__,
-             rmesa->dma.nr_released_bufs);
-
-
-   if (RADEON_DEBUG & DEBUG_SANITY) {
-      if (rmesa->state.scissor.enabled) 
-        ret = radeonSanityCmdBuffer( rmesa, 
-                                     rmesa->state.scissor.numClipRects,
-                                     rmesa->state.scissor.pClipRects);
-      else
-        ret = radeonSanityCmdBuffer( rmesa, 
-                                     rmesa->numClipRects,
-                                     rmesa->pClipRects);
-      if (ret) {
-        fprintf(stderr, "drmSanityCommandWrite: %d\n", ret);    
-        goto out;
+      if (nr & 1) {
+        OUT_BATCH((rmesa->radeon.tcl.aos[nr - 1].components << 0) |
+                  (rmesa->radeon.tcl.aos[nr - 1].stride << 8));
+        voffset =  rmesa->radeon.tcl.aos[nr - 1].offset +
+           offset * 4 * rmesa->radeon.tcl.aos[nr - 1].stride;
+        OUT_BATCH_RELOC(voffset,
+                        rmesa->radeon.tcl.aos[nr - 1].bo,
+                        voffset,
+                        RADEON_GEM_DOMAIN_GTT,
+                        0, 0);
       }
-   }
-
-
-   cmd.bufsz = rmesa->store.cmd_used;
-   cmd.buf = rmesa->store.cmd_buf;
-
-   if (rmesa->state.scissor.enabled) {
-      cmd.nbox = rmesa->state.scissor.numClipRects;
-      cmd.boxes = rmesa->state.scissor.pClipRects;
    } else {
-      cmd.nbox = rmesa->numClipRects;
-      cmd.boxes = rmesa->pClipRects;
-   }
-
-   ret = drmCommandWrite( rmesa->dri.fd,
-                         DRM_RADEON_CMDBUF,
-                         &cmd, sizeof(cmd) );
-
-   if (ret)
-      fprintf(stderr, "drmCommandWrite: %d\n", ret);
-
-   if (RADEON_DEBUG & DEBUG_SYNC) {
-      fprintf(stderr, "\nSyncing in %s\n\n", __FUNCTION__);
-      radeonWaitForIdleLocked( rmesa );
-   }
-
- out:
-   rmesa->store.primnr = 0;
-   rmesa->store.statenr = 0;
-   rmesa->store.cmd_used = 0;
-   rmesa->dma.nr_released_bufs = 0;
-   rmesa->save_on_next_emit = 1;
-
-   return ret;
-}
-
-
-/* Note: does not emit any commands to avoid recursion on
- * radeonAllocCmdBuf.
- */
-void radeonFlushCmdBuf( radeonContextPtr rmesa, const char *caller )
-{
-   int ret;
-
-             
-   LOCK_HARDWARE( rmesa );
-
-   ret = radeonFlushCmdBufLocked( rmesa, caller );
-
-   UNLOCK_HARDWARE( rmesa );
-
-   if (ret) {
-      fprintf(stderr, "drm_radeon_cmd_buffer_t: %d (exiting)\n", ret);
-      exit(ret);
-   }
-}
-
-/* =============================================================
- * Hardware vertex buffer handling
- */
-
-
-void radeonRefillCurrentDmaRegion( radeonContextPtr rmesa )
-{
-   struct radeon_dma_buffer *dmabuf;
-   int fd = rmesa->dri.fd;
-   int index = 0;
-   int size = 0;
-   drmDMAReq dma;
-   int ret;
-
-   if (RADEON_DEBUG & (DEBUG_IOCTL|DEBUG_DMA))
-      fprintf(stderr, "%s\n", __FUNCTION__);  
-
-   if (rmesa->dma.flush) {
-      rmesa->dma.flush( rmesa );
-   }
-
-   if (rmesa->dma.current.buf)
-      radeonReleaseDmaRegion( rmesa, &rmesa->dma.current, __FUNCTION__ );
-
-   if (rmesa->dma.nr_released_bufs > 4)
-      radeonFlushCmdBuf( rmesa, __FUNCTION__ );
-
-   dma.context = rmesa->dri.hwContext;
-   dma.send_count = 0;
-   dma.send_list = NULL;
-   dma.send_sizes = NULL;
-   dma.flags = 0;
-   dma.request_count = 1;
-   dma.request_size = RADEON_BUFFER_SIZE;
-   dma.request_list = &index;
-   dma.request_sizes = &size;
-   dma.granted_count = 0;
-
-   LOCK_HARDWARE(rmesa);       /* no need to validate */
-
-   ret = drmDMA( fd, &dma );
-      
-   if (ret != 0) {
-      /* Free some up this way?
-       */
-      if (rmesa->dma.nr_released_bufs) {
-        radeonFlushCmdBufLocked( rmesa, __FUNCTION__ );
-      }
-      
-      if (RADEON_DEBUG & DEBUG_DMA)
-        fprintf(stderr, "Waiting for buffers\n");
-
-      radeonWaitForIdleLocked( rmesa );
-      ret = drmDMA( fd, &dma );
-
-      if ( ret != 0 ) {
-        UNLOCK_HARDWARE( rmesa );
-        fprintf( stderr, "Error: Could not get dma buffer... exiting\n" );
-        exit( -1 );
-      }
-   }
-
-   UNLOCK_HARDWARE(rmesa);
-
-   if (RADEON_DEBUG & DEBUG_DMA)
-      fprintf(stderr, "Allocated buffer %d\n", index);
-
-   dmabuf = CALLOC_STRUCT( radeon_dma_buffer );
-   dmabuf->buf = &rmesa->radeonScreen->buffers->list[index];
-   dmabuf->refcount = 1;
-
-   rmesa->dma.current.buf = dmabuf;
-   rmesa->dma.current.address = dmabuf->buf->address;
-   rmesa->dma.current.end = dmabuf->buf->total;
-   rmesa->dma.current.start = 0;
-   rmesa->dma.current.ptr = 0;
-
-   rmesa->c_vertexBuffers++;
-}
-
-void radeonReleaseDmaRegion( radeonContextPtr rmesa,
-                            struct radeon_dma_region *region,
-                            const char *caller )
-{
-   if (RADEON_DEBUG & DEBUG_IOCTL)
-      fprintf(stderr, "%s from %s\n", __FUNCTION__, caller); 
-   
-   if (!region->buf)
-      return;
-
-   if (rmesa->dma.flush)
-      rmesa->dma.flush( rmesa );
-
-   if (--region->buf->refcount == 0) {
-      drm_radeon_cmd_header_t *cmd;
-
-      if (RADEON_DEBUG & (DEBUG_IOCTL|DEBUG_DMA))
-        fprintf(stderr, "%s -- DISCARD BUF %d\n", __FUNCTION__,
-                region->buf->buf->idx);  
-      
-      cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, sizeof(*cmd), 
-                                                    __FUNCTION__ );
-      cmd->dma.cmd_type = RADEON_CMD_DMA_DISCARD;
-      cmd->dma.buf_idx = region->buf->buf->idx;
-      FREE(region->buf);
-      rmesa->dma.nr_released_bufs++;
-   }
-
-   region->buf = NULL;
-   region->start = 0;
-}
-
-/* Allocates a region from rmesa->dma.current.  If there isn't enough
- * space in current, grab a new buffer (and discard what was left of current)
- */
-void radeonAllocDmaRegion( radeonContextPtr rmesa, 
-                          struct radeon_dma_region *region,
-                          int bytes,
-                          int alignment )
-{
-   if (RADEON_DEBUG & DEBUG_IOCTL)
-      fprintf(stderr, "%s %d\n", __FUNCTION__, bytes);
-
-   if (rmesa->dma.flush)
-      rmesa->dma.flush( rmesa );
-
-   if (region->buf)
-      radeonReleaseDmaRegion( rmesa, region, __FUNCTION__ );
-
-   alignment--;
-   rmesa->dma.current.start = rmesa->dma.current.ptr = 
-      (rmesa->dma.current.ptr + alignment) & ~alignment;
-
-   if ( rmesa->dma.current.ptr + bytes > rmesa->dma.current.end ) 
-      radeonRefillCurrentDmaRegion( rmesa );
-
-   region->start = rmesa->dma.current.start;
-   region->ptr = rmesa->dma.current.start;
-   region->end = rmesa->dma.current.start + bytes;
-   region->address = rmesa->dma.current.address;
-   region->buf = rmesa->dma.current.buf;
-   region->buf->refcount++;
-
-   rmesa->dma.current.ptr += bytes; /* bug - if alignment > 7 */
-   rmesa->dma.current.start = 
-      rmesa->dma.current.ptr = (rmesa->dma.current.ptr + 0x7) & ~0x7;  
-}
-
-/* ================================================================
- * SwapBuffers with client-side throttling
- */
-
-static uint32_t radeonGetLastFrame (radeonContextPtr rmesa) 
-{
-   drm_radeon_getparam_t gp;
-   int ret;
-   uint32_t frame;
-
-   gp.param = RADEON_PARAM_LAST_FRAME;
-   gp.value = (int *)&frame;
-   ret = drmCommandWriteRead( rmesa->dri.fd, DRM_RADEON_GETPARAM,
-                             &gp, sizeof(gp) );
-
-   if ( ret ) {
-      fprintf( stderr, "%s: drm_radeon_getparam_t: %d\n", __FUNCTION__, ret );
-      exit(1);
-   }
-
-   return frame;
-}
-
-static void radeonEmitIrqLocked( radeonContextPtr rmesa )
-{
-   drm_radeon_irq_emit_t ie;
-   int ret;
-
-   ie.irq_seq = &rmesa->iw.irq_seq;
-   ret = drmCommandWriteRead( rmesa->dri.fd, DRM_RADEON_IRQ_EMIT, 
-                             &ie, sizeof(ie) );
-   if ( ret ) {
-      fprintf( stderr, "%s: drm_radeon_irq_emit_t: %d\n", __FUNCTION__, ret );
-      exit(1);
-   }
-}
-
-
-static void radeonWaitIrq( radeonContextPtr rmesa )
-{
-   int ret;
-
-   do {
-      ret = drmCommandWrite( rmesa->dri.fd, DRM_RADEON_IRQ_WAIT,
-                            &rmesa->iw, sizeof(rmesa->iw) );
-   } while (ret && (errno == EINTR || errno == EBUSY));
-
-   if ( ret ) {
-      fprintf( stderr, "%s: drmRadeonIrqWait: %d\n", __FUNCTION__, ret );
-      exit(1);
-   }
-}
-
-
-static void radeonWaitForFrameCompletion( radeonContextPtr rmesa )
-{
-   drm_radeon_sarea_t *sarea = rmesa->sarea;
-
-   if (rmesa->do_irqs) {
-      if (radeonGetLastFrame(rmesa) < sarea->last_frame) {
-        if (!rmesa->irqsEmitted) {
-           while (radeonGetLastFrame (rmesa) < sarea->last_frame)
-              ;
-        }
-        else {
-           UNLOCK_HARDWARE( rmesa ); 
-           radeonWaitIrq( rmesa );     
-           LOCK_HARDWARE( rmesa ); 
-        }
-        rmesa->irqsEmitted = 10;
+      for (i = 0; i + 1 < nr; i += 2) {
+        OUT_BATCH((rmesa->radeon.tcl.aos[i].components << 0) |
+                  (rmesa->radeon.tcl.aos[i].stride << 8) |
+                  (rmesa->radeon.tcl.aos[i + 1].components << 16) |
+                  (rmesa->radeon.tcl.aos[i + 1].stride << 24));
+
+        voffset =  rmesa->radeon.tcl.aos[i + 0].offset +
+           offset * 4 * rmesa->radeon.tcl.aos[i + 0].stride;
+        OUT_BATCH(voffset);
+        voffset =  rmesa->radeon.tcl.aos[i + 1].offset +
+           offset * 4 * rmesa->radeon.tcl.aos[i + 1].stride;
+        OUT_BATCH(voffset);
       }
 
-      if (rmesa->irqsEmitted) {
-        radeonEmitIrqLocked( rmesa );
-        rmesa->irqsEmitted--;
+      if (nr & 1) {
+        OUT_BATCH((rmesa->radeon.tcl.aos[nr - 1].components << 0) |
+                  (rmesa->radeon.tcl.aos[nr - 1].stride << 8));
+        voffset =  rmesa->radeon.tcl.aos[nr - 1].offset +
+           offset * 4 * rmesa->radeon.tcl.aos[nr - 1].stride;
+        OUT_BATCH(voffset);
       }
-   } 
-   else {
-      while (radeonGetLastFrame (rmesa) < sarea->last_frame) {
-        UNLOCK_HARDWARE( rmesa ); 
-        if (rmesa->do_usleeps) 
-           DO_USLEEP( 1 );
-        LOCK_HARDWARE( rmesa ); 
+      for (i = 0; i + 1 < nr; i += 2) {
+        voffset =  rmesa->radeon.tcl.aos[i + 0].offset +
+           offset * 4 * rmesa->radeon.tcl.aos[i + 0].stride;
+        radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
+                              rmesa->radeon.tcl.aos[i+0].bo,
+                              RADEON_GEM_DOMAIN_GTT,
+                              0, 0);
+        voffset =  rmesa->radeon.tcl.aos[i + 1].offset +
+           offset * 4 * rmesa->radeon.tcl.aos[i + 1].stride;
+        radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
+                              rmesa->radeon.tcl.aos[i+1].bo,
+                              RADEON_GEM_DOMAIN_GTT,
+                              0, 0);
       }
-   }
-}
-
-/* Copy the back color buffer to the front color buffer.
- */
-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);
-   assert(dPriv->driContextPriv->driverPrivate);
-
-   rmesa = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
-
-   if ( RADEON_DEBUG & DEBUG_IOCTL ) {
-      fprintf( stderr, "\n%s( %p )\n\n", __FUNCTION__, (void *) rmesa->glCtx );
-   }
-
-   RADEON_FIREVERTICES( rmesa );
-   LOCK_HARDWARE( rmesa );
-
-   /* Throttle the frame rate -- only allow one pending swap buffers
-    * request at a time.
-    */
-   radeonWaitForFrameCompletion( rmesa );
-   if (!rect)
-   {
-       UNLOCK_HARDWARE( rmesa );
-       driWaitForVBlank( dPriv, & missed_target );
-       LOCK_HARDWARE( rmesa );
-   }
-
-   nbox = dPriv->numClipRects; /* must be in locked region */
-
-   for ( i = 0 ; i < nbox ; ) {
-      GLint nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS , nbox );
-      drm_clip_rect_t *box = dPriv->pClipRects;
-      drm_clip_rect_t *b = rmesa->sarea->boxes;
-      GLint n = 0;
-
-      for ( ; i < nr ; i++ ) {
-
-         *b = box[i];
-
-         if (rect)
-         {
-             if (rect->x1 > b->x1)
-                 b->x1 = rect->x1;
-             if (rect->y1 > b->y1)
-                 b->y1 = rect->y1;
-             if (rect->x2 < b->x2)
-                 b->x2 = rect->x2;
-             if (rect->y2 < b->y2)
-                 b->y2 = rect->y2;
-
-             if (b->x1 >= b->x2 || b->y1 >= b->y2)
-                 continue;
-         }
-
-         b++;
-         n++;
-      }
-      rmesa->sarea->nbox = n;
-
-      if (!n)
-        continue;
-
-      ret = drmCommandNone( rmesa->dri.fd, DRM_RADEON_SWAP );
-
-      if ( ret ) {
-        fprintf( stderr, "DRM_RADEON_SWAP_BUFFERS: return = %d\n", ret );
-        UNLOCK_HARDWARE( rmesa );
-        exit( 1 );
+      if (nr & 1) {
+        voffset =  rmesa->radeon.tcl.aos[nr - 1].offset +
+           offset * 4 * rmesa->radeon.tcl.aos[nr - 1].stride;
+        radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
+                              rmesa->radeon.tcl.aos[nr-1].bo,
+                              RADEON_GEM_DOMAIN_GTT,
+                              0, 0);
       }
    }
+   END_BATCH();
 
-   UNLOCK_HARDWARE( rmesa );
-   if (!rect)
-   {
-       psp = dPriv->driScreenPriv;
-       rmesa->swap_count++;
-       (*psp->systemTime->getUST)( & ust );
-       if ( missed_target ) {
-          rmesa->swap_missed_count++;
-          rmesa->swap_missed_ust = ust - rmesa->swap_ust;
-       }
-
-       rmesa->swap_ust = ust;
-       rmesa->hw.all_dirty = GL_TRUE;
-   }
-}
-
-void radeonPageFlip( __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__,
-             rmesa->sarea->pfCurrentPage);
-   }
-
-   RADEON_FIREVERTICES( rmesa );
-   LOCK_HARDWARE( rmesa );
-
-   /* Need to do this for the perf box placement:
-    */
-   if (dPriv->numClipRects)
-   {
-      drm_clip_rect_t *box = dPriv->pClipRects;
-      drm_clip_rect_t *b = rmesa->sarea->boxes;
-      b[0] = box[0];
-      rmesa->sarea->nbox = 1;
-   }
-
-   /* Throttle the frame rate -- only allow a few pending swap buffers
-    * request at a time.
-    */
-   radeonWaitForFrameCompletion( rmesa );
-   UNLOCK_HARDWARE( rmesa );
-   driWaitForVBlank( dPriv, & missed_target );
-   if ( missed_target ) {
-      rmesa->swap_missed_count++;
-      (void) (*psp->systemTime->getUST)( & rmesa->swap_missed_ust );
-   }
-   LOCK_HARDWARE( rmesa );
-
-   ret = drmCommandNone( rmesa->dri.fd, DRM_RADEON_FLIP );
-
-   UNLOCK_HARDWARE( rmesa );
-
-   if ( ret ) {
-      fprintf( stderr, "DRM_RADEON_FLIP: return = %d\n", ret );
-      exit( 1 );
-   }
-
-   rmesa->swap_count++;
-   (void) (*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.
-    */
-   driFlipRenderbuffers(rmesa->glCtx->WinSysDrawBuffer,
-                        rmesa->sarea->pfCurrentPage);
-
-   radeonUpdateDrawBuffer(rmesa->glCtx);
+#endif
 }
 
-
 /* ================================================================
  * Buffer clear
  */
 #define RADEON_MAX_CLEARS      256
 
-static void radeonClear( GLcontext *ctx, GLbitfield mask )
+static void radeonUserClear(GLcontext *ctx, GLuint mask)
+{
+   radeon_clear_tris(ctx, mask);
+}
+
+static void radeonKernelClear(GLcontext *ctx, GLuint flags)
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
-   drm_radeon_sarea_t *sarea = rmesa->sarea;
+     r100ContextPtr rmesa = R100_CONTEXT(ctx);
+   __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
+   drm_radeon_sarea_t *sarea = rmesa->radeon.sarea;
    uint32_t clear;
-   GLuint flags = 0;
-   GLuint color_mask = 0;
    GLint ret, i;
    GLint cx, cy, cw, ch;
 
-   if ( RADEON_DEBUG & DEBUG_IOCTL ) {
-      fprintf( stderr, "radeonClear\n");
-   }
-
-   {
-      LOCK_HARDWARE( rmesa );
-      UNLOCK_HARDWARE( rmesa );
-      if ( dPriv->numClipRects == 0 ) 
-        return;
-   }
-   
-   radeonFlush( ctx ); 
-
-   if ( mask & BUFFER_BIT_FRONT_LEFT ) {
-      flags |= RADEON_FRONT;
-      color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
-      mask &= ~BUFFER_BIT_FRONT_LEFT;
-   }
-
-   if ( mask & BUFFER_BIT_BACK_LEFT ) {
-      flags |= RADEON_BACK;
-      color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
-      mask &= ~BUFFER_BIT_BACK_LEFT;
-   }
-
-   if ( mask & BUFFER_BIT_DEPTH ) {
-      flags |= RADEON_DEPTH;
-      mask &= ~BUFFER_BIT_DEPTH;
-   }
-
-   if ( (mask & BUFFER_BIT_STENCIL) && rmesa->state.stencil.hwBuffer ) {
-      flags |= RADEON_STENCIL;
-      mask &= ~BUFFER_BIT_STENCIL;
-   }
-
-   if ( mask ) {
-      if (RADEON_DEBUG & DEBUG_FALLBACKS)
-        fprintf(stderr, "%s: swrast clear, mask: %x\n", __FUNCTION__, mask);
-      _swrast_Clear( ctx, mask );
-   }
-
-   if ( !flags ) 
-      return;
-
-   if (rmesa->using_hyperz) {
-      flags |= RADEON_USE_COMP_ZBUF;
-/*      if (rmesa->radeonScreen->chipset & RADEON_CHIPSET_TCL) 
-         flags |= RADEON_USE_HIERZ; */
-      if (!(rmesa->state.stencil.hwBuffer) ||
-        ((flags & RADEON_DEPTH) && (flags & RADEON_STENCIL) &&
-           ((rmesa->state.stencil.clear & RADEON_STENCIL_WRITE_MASK) == RADEON_STENCIL_WRITE_MASK))) {
-         flags |= RADEON_CLEAR_FASTZ;
-      }
-   }
-
-   LOCK_HARDWARE( rmesa );
+   LOCK_HARDWARE( &rmesa->radeon );
 
    /* compute region after locking: */
    cx = ctx->DrawBuffer->_Xmin;
@@ -1112,7 +479,7 @@ static void radeonClear( GLcontext *ctx, GLbitfield mask )
 
       gp.param = RADEON_PARAM_LAST_CLEAR;
       gp.value = (int *)&clear;
-      ret = drmCommandWriteRead( rmesa->dri.fd,
+      ret = drmCommandWriteRead( rmesa->radeon.dri.fd,
                                 DRM_RADEON_GETPARAM, &gp, sizeof(gp) );
 
       if ( ret ) {
@@ -1124,20 +491,20 @@ static void radeonClear( GLcontext *ctx, GLbitfield mask )
         break;
       }
 
-      if ( rmesa->do_usleeps ) {
-        UNLOCK_HARDWARE( rmesa );
+      if ( rmesa->radeon.do_usleeps ) {
+        UNLOCK_HARDWARE( &rmesa->radeon );
         DO_USLEEP( 1 );
-        LOCK_HARDWARE( rmesa );
+        LOCK_HARDWARE( &rmesa->radeon );
       }
    }
 
    /* Send current state to the hardware */
-   radeonFlushCmdBufLocked( rmesa, __FUNCTION__ );
+   rcommonFlushCmdBufLocked( &rmesa->radeon, __FUNCTION__ );
 
    for ( i = 0 ; i < dPriv->numClipRects ; ) {
       GLint nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS, dPriv->numClipRects );
       drm_clip_rect_t *box = dPriv->pClipRects;
-      drm_clip_rect_t *b = rmesa->sarea->boxes;
+      drm_clip_rect_t *b = rmesa->radeon.sarea->boxes;
       drm_radeon_clear_t clear;
       drm_radeon_clear_rect_t depth_boxes[RADEON_NR_SAREA_CLIPRECTS];
       GLint n = 0;
@@ -1172,105 +539,107 @@ static void radeonClear( GLcontext *ctx, GLbitfield mask )
         }
       }
 
-      rmesa->sarea->nbox = n;
+      rmesa->radeon.sarea->nbox = n;
 
       clear.flags       = flags;
-      clear.clear_color = rmesa->state.color.clear;
-      clear.clear_depth = rmesa->state.depth.clear;
+      clear.clear_color = rmesa->radeon.state.color.clear;
+      clear.clear_depth = rmesa->radeon.state.depth.clear;
       clear.color_mask  = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
-      clear.depth_mask  = rmesa->state.stencil.clear;
+      clear.depth_mask  = rmesa->radeon.state.stencil.clear;
       clear.depth_boxes = depth_boxes;
 
       n--;
-      b = rmesa->sarea->boxes;
+      b = rmesa->radeon.sarea->boxes;
       for ( ; n >= 0 ; n-- ) {
         depth_boxes[n].f[CLEAR_X1] = (float)b[n].x1;
         depth_boxes[n].f[CLEAR_Y1] = (float)b[n].y1;
         depth_boxes[n].f[CLEAR_X2] = (float)b[n].x2;
         depth_boxes[n].f[CLEAR_Y2] = (float)b[n].y2;
-        depth_boxes[n].f[CLEAR_DEPTH] = 
-           (float)rmesa->state.depth.clear;
+        depth_boxes[n].f[CLEAR_DEPTH] =
+           (float)rmesa->radeon.state.depth.clear;
       }
 
-      ret = drmCommandWrite( rmesa->dri.fd, DRM_RADEON_CLEAR,
+      ret = drmCommandWrite( rmesa->radeon.dri.fd, DRM_RADEON_CLEAR,
                             &clear, sizeof(drm_radeon_clear_t));
 
       if ( ret ) {
-        UNLOCK_HARDWARE( rmesa );
+        UNLOCK_HARDWARE( &rmesa->radeon );
         fprintf( stderr, "DRM_RADEON_CLEAR: return = %d\n", ret );
         exit( 1 );
       }
    }
-
-   UNLOCK_HARDWARE( rmesa );
-   rmesa->hw.all_dirty = GL_TRUE;
+   UNLOCK_HARDWARE( &rmesa->radeon );
 }
 
-
-void radeonWaitForIdleLocked( radeonContextPtr rmesa )
+static void radeonClear( GLcontext *ctx, GLbitfield mask )
 {
-    int fd = rmesa->dri.fd;
-    int to = 0;
-    int ret, i = 0;
-
-    rmesa->c_drawWaits++;
-
-    do {
-        do {
-            ret = drmCommandNone( fd, DRM_RADEON_CP_IDLE);
-        } while ( ret && errno == EBUSY && i++ < RADEON_IDLE_RETRY );
-    } while ( ( ret == -EBUSY ) && ( to++ < RADEON_TIMEOUT ) );
-
-    if ( ret < 0 ) {
-       UNLOCK_HARDWARE( rmesa );
-       fprintf( stderr, "Error: Radeon timed out... exiting\n" );
-       exit( -1 );
-    }
-}
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
+   __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
+   GLuint flags = 0;
+   GLuint color_mask = 0;
+   GLuint orig_mask = mask;
+
+   if ( RADEON_DEBUG & DEBUG_IOCTL ) {
+      fprintf( stderr, "radeonClear\n");
+   }
 
+   {
+      LOCK_HARDWARE( &rmesa->radeon );
+      UNLOCK_HARDWARE( &rmesa->radeon );
+      if ( dPriv->numClipRects == 0 )
+        return;
+   }
 
-static void radeonWaitForIdle( radeonContextPtr rmesa )
-{
-   LOCK_HARDWARE(rmesa);
-   radeonWaitForIdleLocked( rmesa );
-   UNLOCK_HARDWARE(rmesa);
-}
+   radeon_firevertices(&rmesa->radeon);
 
+   if ( mask & BUFFER_BIT_FRONT_LEFT ) {
+      flags |= RADEON_FRONT;
+      color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
+      mask &= ~BUFFER_BIT_FRONT_LEFT;
+   }
 
-void radeonFlush( GLcontext *ctx )
-{
-   radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+   if ( mask & BUFFER_BIT_BACK_LEFT ) {
+      flags |= RADEON_BACK;
+      color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
+      mask &= ~BUFFER_BIT_BACK_LEFT;
+   }
 
-   if (RADEON_DEBUG & DEBUG_IOCTL)
-      fprintf(stderr, "%s\n", __FUNCTION__);
+   if ( mask & BUFFER_BIT_DEPTH ) {
+      flags |= RADEON_DEPTH;
+      mask &= ~BUFFER_BIT_DEPTH;
+   }
 
-   if (rmesa->dma.flush)
-      rmesa->dma.flush( rmesa );
+   if ( (mask & BUFFER_BIT_STENCIL) ) {
+      flags |= RADEON_STENCIL;
+      mask &= ~BUFFER_BIT_STENCIL;
+   }
 
-   radeonEmitState( rmesa );
-   
-   if (rmesa->store.cmd_used)
-      radeonFlushCmdBuf( rmesa, __FUNCTION__ );
-}
+   if ( mask ) {
+      if (RADEON_DEBUG & DEBUG_FALLBACKS)
+        fprintf(stderr, "%s: swrast clear, mask: %x\n", __FUNCTION__, mask);
+      _swrast_Clear( ctx, mask );
+   }
 
-/* Make sure all commands have been sent to the hardware and have
- * completed processing.
- */
-void radeonFinish( GLcontext *ctx )
-{
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-   radeonFlush( ctx );
-
-   if (rmesa->do_irqs) {
-      LOCK_HARDWARE( rmesa );
-      radeonEmitIrqLocked( rmesa );
-      UNLOCK_HARDWARE( rmesa );
-      radeonWaitIrq( rmesa );
+   if ( !flags )
+      return;
+
+   if (rmesa->using_hyperz) {
+      flags |= RADEON_USE_COMP_ZBUF;
+/*      if (rmesa->radeon.radeonScreen->chipset & RADEON_CHIPSET_TCL)
+         flags |= RADEON_USE_HIERZ; */
+      if (((flags & RADEON_DEPTH) && (flags & RADEON_STENCIL) &&
+           ((rmesa->radeon.state.stencil.clear & RADEON_STENCIL_WRITE_MASK) == RADEON_STENCIL_WRITE_MASK))) {
+         flags |= RADEON_CLEAR_FASTZ;
+      }
    }
-   else
-      radeonWaitForIdle( rmesa );
-}
 
+   if (rmesa->radeon.radeonScreen->kernel_mm)
+     radeonUserClear(ctx, orig_mask);
+   else {
+      radeonKernelClear(ctx, flags);
+      rmesa->radeon.hw.all_dirty = GL_TRUE;
+   }
+}
 
 void radeonInitIoctlFuncs( GLcontext *ctx )
 {
index 4e3a44df075be574f5aea51075e3ec6e666bb8da..18805d4c571ff8ffc022b54a227b41ef580f6353 100644 (file)
@@ -38,31 +38,32 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "main/simple_list.h"
 #include "radeon_lock.h"
+#include "radeon_bocs_wrapper.h"
 
-
-extern void radeonEmitState( radeonContextPtr rmesa );
-extern void radeonEmitVertexAOS( radeonContextPtr rmesa,
+extern void radeonEmitVertexAOS( r100ContextPtr rmesa,
                                 GLuint vertex_size,
+                                struct radeon_bo *bo,
                                 GLuint offset );
 
-extern void radeonEmitVbufPrim( radeonContextPtr rmesa,
+extern void radeonEmitVbufPrim( r100ContextPtr rmesa,
                                GLuint vertex_format,
                                GLuint primitive,
                                GLuint vertex_nr );
 
-extern void radeonFlushElts( radeonContextPtr rmesa );
+extern void radeonFlushElts( GLcontext *ctx );
+                           
 
-extern GLushort *radeonAllocEltsOpenEnded( radeonContextPtr rmesa,
+extern GLushort *radeonAllocEltsOpenEnded( r100ContextPtr rmesa,
                                           GLuint vertex_format,
                                           GLuint primitive,
                                           GLuint min_nr );
 
-extern void radeonEmitAOS( radeonContextPtr rmesa,
-                          struct radeon_dma_region **regions,
+
+extern void radeonEmitAOS( r100ContextPtr rmesa,
                           GLuint n,
                           GLuint offset );
 
-extern void radeonEmitBlit( radeonContextPtr rmesa,
+extern void radeonEmitBlit( r100ContextPtr rmesa,
                            GLuint color_fmt,
                            GLuint src_pitch,
                            GLuint src_offset,
@@ -72,30 +73,15 @@ extern void radeonEmitBlit( radeonContextPtr rmesa,
                            GLint dstx, GLint dsty,
                            GLuint w, GLuint h );
 
-extern void radeonEmitWait( radeonContextPtr rmesa, GLuint flags );
-
-extern void radeonFlushCmdBuf( radeonContextPtr rmesa, const char * );
-extern void radeonRefillCurrentDmaRegion( radeonContextPtr rmesa );
+extern void radeonEmitWait( r100ContextPtr rmesa, GLuint flags );
 
-extern void radeonAllocDmaRegion( radeonContextPtr rmesa,
-                                 struct radeon_dma_region *region,
-                                 int bytes, 
-                                 int alignment );
+extern void radeonFlushCmdBuf( r100ContextPtr rmesa, const char * );
 
-extern void radeonReleaseDmaRegion( radeonContextPtr rmesa,
-                                   struct radeon_dma_region *region,
-                                   const char *caller );
-
-extern void radeonCopyBuffer( __DRIdrawablePrivate *drawable,
-                             const drm_clip_rect_t      *rect);
-extern void radeonPageFlip( __DRIdrawablePrivate *drawable );
 extern void radeonFlush( GLcontext *ctx );
 extern void radeonFinish( GLcontext *ctx );
-extern void radeonWaitForIdleLocked( radeonContextPtr rmesa );
-extern void radeonWaitForVBlank( radeonContextPtr rmesa );
 extern void radeonInitIoctlFuncs( GLcontext *ctx );
-extern void radeonGetAllParams( radeonContextPtr rmesa );
-extern void radeonSetUpAtomList( radeonContextPtr rmesa );
+extern void radeonGetAllParams( r100ContextPtr rmesa );
+extern void radeonSetUpAtomList( r100ContextPtr rmesa );
 
 /* ================================================================
  * Helper macros:
@@ -105,33 +91,33 @@ extern void radeonSetUpAtomList( radeonContextPtr rmesa );
  */
 #define RADEON_NEWPRIM( rmesa )                        \
 do {                                           \
-   if ( rmesa->dma.flush )                     \
-      rmesa->dma.flush( rmesa );       \
+   if ( rmesa->radeon.dma.flush )                      \
+      rmesa->radeon.dma.flush( rmesa->radeon.glCtx );  \
 } while (0)
 
 /* Can accomodate several state changes and primitive changes without
  * actually firing the buffer.
  */
+
 #define RADEON_STATECHANGE( rmesa, ATOM )                      \
 do {                                                           \
    RADEON_NEWPRIM( rmesa );                                    \
    rmesa->hw.ATOM.dirty = GL_TRUE;                             \
-   rmesa->hw.is_dirty = GL_TRUE;                               \
+   rmesa->radeon.hw.is_dirty = GL_TRUE;                                \
 } while (0)
 
-#define RADEON_DB_STATE( ATOM )                                \
+#define RADEON_DB_STATE( ATOM )                                \
    memcpy( rmesa->hw.ATOM.lastcmd, rmesa->hw.ATOM.cmd, \
           rmesa->hw.ATOM.cmd_size * 4)
 
-static INLINE int RADEON_DB_STATECHANGE( 
-   radeonContextPtr rmesa,
-   struct radeon_state_atom *atom )
+static INLINE int RADEON_DB_STATECHANGE(r100ContextPtr rmesa,
+                                       struct radeon_state_atom *atom )
 {
    if (memcmp(atom->cmd, atom->lastcmd, atom->cmd_size*4)) {
-      int *tmp;
+      GLuint *tmp;
       RADEON_NEWPRIM( rmesa );
       atom->dirty = GL_TRUE;
-      rmesa->hw.is_dirty = GL_TRUE;
+      rmesa->radeon.hw.is_dirty = GL_TRUE;
       tmp = atom->cmd; 
       atom->cmd = atom->lastcmd;
       atom->lastcmd = tmp;
@@ -141,16 +127,6 @@ static INLINE int RADEON_DB_STATECHANGE(
       return 0;
 }
 
-
-/* Fire the buffered vertices no matter what.
- */
-#define RADEON_FIREVERTICES( rmesa )                   \
-do {                                                   \
-   if ( rmesa->store.cmd_used || rmesa->dma.flush ) {  \
-      radeonFlush( rmesa->glCtx );                     \
-   }                                                   \
-} while (0)
-
 /* Command lengths.  Note that any time you ensure ELTS_BUFSZ or VBUF_BUFSZ
  * are available, you will also be adding an rmesa->state.max_state_size because
  * r200EmitState is called from within r200EmitVbufPrim and r200FlushElts.
@@ -167,36 +143,37 @@ do {                                                      \
 #define VBUF_BUFSZ     (4 * sizeof(int))
 #endif
 
-/* Ensure that a minimum amount of space is available in the command buffer.
- * This is used to ensure atomicity of state updates with the rendering requests
- * that rely on them.
- *
- * An alternative would be to implement a "soft lock" such that when the buffer
- * wraps at an inopportune time, we grab the lock, flush the current buffer,
- * and hang on to the lock until the critical section is finished and we flush
- * the buffer again and unlock.
- */
-static INLINE void radeonEnsureCmdBufSpace( radeonContextPtr rmesa,
-                                             int bytes )
-{
-   if (rmesa->store.cmd_used + bytes > RADEON_CMD_BUF_SZ)
-      radeonFlushCmdBuf( rmesa, __FUNCTION__ );
-   assert( bytes <= RADEON_CMD_BUF_SZ );
-}
 
-/* Alloc space in the command buffer
- */
-static INLINE char *radeonAllocCmdBuf( radeonContextPtr rmesa,
-                                        int bytes, const char *where )
+static inline uint32_t cmdpacket3(int cmd_type)
 {
-   if (rmesa->store.cmd_used + bytes > RADEON_CMD_BUF_SZ)
-      radeonFlushCmdBuf( rmesa, __FUNCTION__ );
+  drm_radeon_cmd_header_t cmd;
+
+  cmd.i = 0;
+  cmd.header.cmd_type = cmd_type;
+
+  return (uint32_t)cmd.i;
 
-   {
-      char *head = rmesa->store.cmd_buf + rmesa->store.cmd_used;
-      rmesa->store.cmd_used += bytes;
-      return head;
-   }
 }
 
+#define OUT_BATCH_PACKET3(packet, num_extra) do {            \
+    if (!b_l_rmesa->radeonScreen->kernel_mm) {               \
+      OUT_BATCH(cmdpacket3(RADEON_CMD_PACKET3));                                     \
+      OUT_BATCH(CP_PACKET3((packet), (num_extra)));          \
+    } else {                                                 \
+      OUT_BATCH(CP_PACKET2);                                 \
+      OUT_BATCH(CP_PACKET3((packet), (num_extra)));          \
+    }                                                        \
+  } while(0)
+
+#define OUT_BATCH_PACKET3_CLIP(packet, num_extra) do {       \
+    if (!b_l_rmesa->radeonScreen->kernel_mm) {               \
+      OUT_BATCH(cmdpacket3(RADEON_CMD_PACKET3_CLIP));        \
+      OUT_BATCH(CP_PACKET3((packet), (num_extra)));          \
+    } else {                                                 \
+      OUT_BATCH(CP_PACKET2);                                 \
+      OUT_BATCH(CP_PACKET3((packet), (num_extra)));          \
+    }                                                        \
+  } while(0)
+
+
 #endif /* __RADEON_IOCTL_H__ */
index 64bb3ca103fe7d964338710d6caff9a5f7f113c3..5774f7ebcf7ec3d275d874cc0ba93f6265d8efd8 100644 (file)
@@ -41,30 +41,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "main/glheader.h"
 #include "main/mtypes.h"
-#include "radeon_context.h"
+#include "main/colormac.h"
+#include "dri_util.h"
+#include "radeon_screen.h"
+#include "radeon_common.h"
 #include "radeon_lock.h"
-#include "radeon_tex.h"
-#include "radeon_state.h"
-#include "radeon_ioctl.h"
-
 #include "drirenderbuffer.h"
 
-#if DEBUG_LOCKING
-char *prevLockFile = NULL;
-int prevLockLine = 0;
-#endif
-
-/* Turn on/off page flipping according to the flags in the sarea:
- */
-static void radeonUpdatePageFlipping(radeonContextPtr rmesa)
-{
-       rmesa->doPageFlip = rmesa->sarea->pfState;
-       if (rmesa->glCtx->WinSysDrawBuffer) {
-               driFlipRenderbuffers(rmesa->glCtx->WinSysDrawBuffer,
-                                    rmesa->sarea->pfCurrentPage);
-       }
-}
-
 /* 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
@@ -75,10 +58,11 @@ static void radeonUpdatePageFlipping(radeonContextPtr rmesa)
  */
 void radeonGetLock(radeonContextPtr rmesa, GLuint flags)
 {
-       __DRIdrawablePrivate *const drawable = rmesa->dri.drawable;
-       __DRIdrawablePrivate *const readable = rmesa->dri.readable;
+       __DRIdrawablePrivate *const drawable = radeon_get_drawable(rmesa);
+       __DRIdrawablePrivate *const readable = radeon_get_readable(rmesa);
        __DRIscreenPrivate *sPriv = rmesa->dri.screen;
-       drm_radeon_sarea_t *sarea = rmesa->sarea;
+
+       assert(drawable != NULL);
 
        drmGetLock(rmesa->dri.fd, rmesa->dri.hwContext, flags);
 
@@ -96,29 +80,42 @@ void radeonGetLock(radeonContextPtr rmesa, GLuint flags)
        }
 
        if (rmesa->lastStamp != drawable->lastStamp) {
-               radeonUpdatePageFlipping(rmesa);
-               radeonSetCliprects(rmesa);
-               radeonUpdateViewportOffset(rmesa->glCtx);
-               driUpdateFramebufferSize(rmesa->glCtx, drawable);
+               radeon_window_moved(rmesa);
+               rmesa->lastStamp = drawable->lastStamp;
        }
 
-       RADEON_STATECHANGE(rmesa, ctx);
-       if (rmesa->sarea->tiling_enabled) {
-               rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |=
-                   RADEON_COLOR_TILE_ENABLE;
-       } else {
-               rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] &=
-                   ~RADEON_COLOR_TILE_ENABLE;
-       }
+       rmesa->vtbl.get_lock(rmesa);
+
+       rmesa->lost_context = GL_TRUE;
+}
 
-       if (sarea->ctx_owner != rmesa->dri.hwContext) {
-               int i;
-               sarea->ctx_owner = rmesa->dri.hwContext;
+void radeon_lock_hardware(radeonContextPtr radeon)
+{
+       char ret = 0;
+       struct radeon_framebuffer *rfb = NULL;
+       struct radeon_renderbuffer *rrb = NULL;
 
-               for (i = 0; i < rmesa->nr_heaps; i++) {
-                       DRI_AGE_TEXTURES(rmesa->texture_heaps[i]);
-               }
+       if (radeon_get_drawable(radeon)) {
+               rfb = radeon_get_drawable(radeon)->driverPrivate;
+
+               if (rfb)
+                       rrb = radeon_get_renderbuffer(&rfb->base,
+                                                     rfb->base._ColorDrawBufferIndexes[0]);
        }
 
-       rmesa->lost_context = GL_TRUE;
+       if (!radeon->radeonScreen->driScreen->dri2.enabled) {
+               DRM_CAS(radeon->dri.hwLock, radeon->dri.hwContext,
+                        (DRM_LOCK_HELD | radeon->dri.hwContext), ret );
+               if (ret)
+                       radeonGetLock(radeon, 0);
+       }
+}
+
+void radeon_unlock_hardware(radeonContextPtr radeon)
+{
+       if (!radeon->radeonScreen->driScreen->dri2.enabled) {
+               DRM_UNLOCK( radeon->dri.fd,
+                           radeon->dri.hwLock,
+                           radeon->dri.hwContext );
+       }
 }
index 86e96aa7d2c614bf3bbcf6f658b6a179039773ad..2817709eed6a3a8f8c2456bfa9948445230668be 100644 (file)
@@ -39,74 +39,21 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *   Kevin E. Martin <martin@valinux.com>
  */
 
-#ifndef __RADEON_LOCK_H__
-#define __RADEON_LOCK_H__
+#ifndef COMMON_LOCK_H
+#define COMMON_LOCK_H
 
-extern void radeonGetLock(radeonContextPtr rmesa, GLuint flags);
-
-/* Turn DEBUG_LOCKING on to find locking conflicts.
- */
-#define DEBUG_LOCKING  0
-
-#if DEBUG_LOCKING
-extern char *prevLockFile;
-extern int prevLockLine;
-
-#define DEBUG_LOCK()                                                   \
-   do {                                                                        \
-      prevLockFile = (__FILE__);                                       \
-      prevLockLine = (__LINE__);                                       \
-   } while (0)
-
-#define DEBUG_RESET()                                                  \
-   do {                                                                        \
-      prevLockFile = 0;                                                        \
-      prevLockLine = 0;                                                        \
-   } while (0)
-
-#define DEBUG_CHECK_LOCK()                                             \
-   do {                                                                        \
-      if ( prevLockFile ) {                                            \
-        fprintf( stderr,                                               \
-                 "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n",    \
-                 prevLockFile, prevLockLine, __FILE__, __LINE__ );     \
-        exit( 1 );                                                     \
-      }                                                                        \
-   } while (0)
-
-#else
+#include "main/colormac.h"
+#include "radeon_screen.h"
+#include "radeon_common.h"
 
-#define DEBUG_LOCK()
-#define DEBUG_RESET()
-#define DEBUG_CHECK_LOCK()
+extern void radeonGetLock(radeonContextPtr rmesa, GLuint flags);
 
-#endif
-
-/*
- * !!! We may want to separate locks from locks with validation.  This
- * could be used to improve performance for those things commands that
- * do not do any drawing !!!
- */
+void radeon_lock_hardware(radeonContextPtr rmesa);
+void radeon_unlock_hardware(radeonContextPtr rmesa);
 
 /* Lock the hardware and validate our state.
  */
-#define LOCK_HARDWARE( rmesa )                                 \
-   do {                                                                \
-      char __ret = 0;                                          \
-      DEBUG_CHECK_LOCK();                                      \
-      DRM_CAS( (rmesa)->dri.hwLock, (rmesa)->dri.hwContext,            \
-              (DRM_LOCK_HELD | (rmesa)->dri.hwContext), __ret );       \
-      if ( __ret )                                             \
-        radeonGetLock( (rmesa), 0 );                           \
-      DEBUG_LOCK();                                            \
-   } while (0)
-
-#define UNLOCK_HARDWARE( rmesa )                                       \
-   do {                                                                        \
-      DRM_UNLOCK( (rmesa)->dri.fd,                                     \
-                 (rmesa)->dri.hwLock,                                  \
-                 (rmesa)->dri.hwContext );                             \
-      DEBUG_RESET();                                                   \
-   } while (0)
+#define LOCK_HARDWARE( rmesa ) radeon_lock_hardware(rmesa)
+#define UNLOCK_HARDWARE( rmesa )  radeon_unlock_hardware(rmesa)
 
-#endif                         /* __RADEON_LOCK_H__ */
+#endif
index b8935e84a050d2a0aa4e2862957770e4d8dd436e..b88eb198d578aa939b282f3cfdae8bd10bd037c8 100644 (file)
@@ -38,6 +38,5 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "radeon_context.h"
 
 extern void radeonEmitArrays( GLcontext *ctx, GLuint inputs );
-extern void radeonReleaseArrays( GLcontext *ctx, GLuint newinputs );
 
 #endif
index 31eea13f4eff6fdd1a95be574eda79a58eef778d..7c6ea0530e0363eb8bfd55e92590278a2513e41b 100644 (file)
@@ -48,160 +48,35 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "radeon_maos.h"
 #include "radeon_tcl.h"
 
-#if 0
-/* Usage:
- *   - from radeon_tcl_render
- *   - call radeonEmitArrays to ensure uptodate arrays in dma
- *   - emit primitives (new type?) which reference the data
- *       -- need to use elts for lineloop, quads, quadstrip/flat
- *       -- other primitives are all well-formed (need tristrip-1,fake-poly)
- *
- */
-static void emit_ubyte_rgba3( GLcontext *ctx,
-                      struct radeon_dma_region *rvb,
-                      char *data,
-                      int stride,
-                      int count )
+static void emit_vecfog(GLcontext *ctx, struct radeon_aos *aos,
+                       GLvoid *data, int stride, int count)
 {
    int i;
-   radeon_color_t *out = (radeon_color_t *)(rvb->start + rvb->address);
-
-   if (RADEON_DEBUG & DEBUG_VERTS)
-      fprintf(stderr, "%s count %d stride %d out %p\n",
-             __FUNCTION__, count, stride, (void *)out);
-
-   for (i = 0; i < count; i++) {
-      out->red   = *data;
-      out->green = *(data+1);
-      out->blue  = *(data+2);
-      out->alpha = 0xFF;
-      out++;
-      data += stride;
-   }
-}
-
-static void emit_ubyte_rgba4( GLcontext *ctx,
-                             struct radeon_dma_region *rvb,
-                             char *data,
-                             int stride,
-                             int count )
-{
-   int i;
-   int *out = (int *)(rvb->address + rvb->start);
+   uint32_t *out;
+   int size = 1;
+   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
 
    if (RADEON_DEBUG & DEBUG_VERTS)
       fprintf(stderr, "%s count %d stride %d\n",
              __FUNCTION__, count, stride);
 
-   if (stride == 4)
-       COPY_DWORDS( out, data, count );
-   else
-      for (i = 0; i < count; i++) {
-        *out++ = LE32_TO_CPU(*(int *)data);
-        data += stride;
-      }
-}
-
-
-static void emit_ubyte_rgba( GLcontext *ctx,
-                            struct radeon_dma_region *rvb,
-                            char *data,
-                            int size,
-                            int stride,
-                            int count )
-{
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
-   if (RADEON_DEBUG & DEBUG_VERTS)
-      fprintf(stderr, "%s %d/%d\n", __FUNCTION__, count, size);
-
-   assert (!rvb->buf);
-
    if (stride == 0) {
-      radeonAllocDmaRegion( rmesa, rvb, 4, 4 );
+      radeonAllocDmaRegion( rmesa, &aos->bo, &aos->offset, size * 4, 32 );
       count = 1;
-      rvb->aos_start = GET_START(rvb);
-      rvb->aos_stride = 0;
-      rvb->aos_size = 1;
+      aos->stride = 0;
    }
    else {
-      radeonAllocDmaRegion( rmesa, rvb, 4 * count, 4 );        /* alignment? */
-      rvb->aos_start = GET_START(rvb);
-      rvb->aos_stride = 1;
-      rvb->aos_size = 1;
+      radeonAllocDmaRegion(rmesa, &aos->bo, &aos->offset, size * 4, 32);
+      aos->stride = size;
    }
 
-   /* Emit the data
-    */
-   switch (size) {
-   case 3:
-      emit_ubyte_rgba3( ctx, rvb, data, stride, count );
-      break;
-   case 4:
-      emit_ubyte_rgba4( ctx, rvb, data, stride, count );
-      break;
-   default:
-      assert(0);
-      exit(1);
-      break;
-   }
-}
-#endif
-
-#if defined(USE_X86_ASM)
-#define COPY_DWORDS( dst, src, nr )                                    \
-do {                                                                   \
-       int __tmp;                                                      \
-       __asm__ __volatile__( "rep ; movsl"                             \
-                             : "=%c" (__tmp), "=D" (dst), "=S" (__tmp) \
-                             : "0" (nr),                               \
-                               "D" ((long)dst),                        \
-                               "S" ((long)src) );                      \
-} while (0)
-#else
-#define COPY_DWORDS( dst, src, nr )            \
-do {                                           \
-   int j;                                      \
-   for ( j = 0 ; j < nr ; j++ )                        \
-      dst[j] = ((int *)src)[j];                        \
-   dst += nr;                                  \
-} while (0)
-#endif
-
-static void emit_vecfog( GLcontext *ctx,
-                        struct radeon_dma_region *rvb,
-                        char *data,
-                        int stride,
-                        int count )
-{
-   int i;
-   GLfloat *out;
+   aos->components = size;
+   aos->count = count;
 
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
-   if (RADEON_DEBUG & DEBUG_VERTS)
-      fprintf(stderr, "%s count %d stride %d\n",
-             __FUNCTION__, count, stride);
-
-   assert (!rvb->buf);
-
-   if (stride == 0) {
-      radeonAllocDmaRegion( rmesa, rvb, 4, 4 );
-      count = 1;
-      rvb->aos_start = GET_START(rvb);
-      rvb->aos_stride = 0;
-      rvb->aos_size = 1;
-   }
-   else {
-      radeonAllocDmaRegion( rmesa, rvb, count * 4, 4 );        /* alignment? */
-      rvb->aos_start = GET_START(rvb);
-      rvb->aos_stride = 1;
-      rvb->aos_size = 1;
-   }
 
    /* Emit the data
     */
-   out = (GLfloat *)(rvb->address + rvb->start);
+   out = (uint32_t*)((char*)aos->bo->ptr + aos->offset);
    for (i = 0; i < count; i++) {
       out[0] = radeonComputeFogBlendFactor( ctx, *(GLfloat *)data );
       out++;
@@ -209,169 +84,9 @@ static void emit_vecfog( GLcontext *ctx,
    }
 }
 
-static void emit_vec4( GLcontext *ctx,
-                      struct radeon_dma_region *rvb,
-                      char *data,
-                      int stride,
-                      int count )
-{
-   int i;
-   int *out = (int *)(rvb->address + rvb->start);
-
-   if (RADEON_DEBUG & DEBUG_VERTS)
-      fprintf(stderr, "%s count %d stride %d\n",
-             __FUNCTION__, count, stride);
-
-   if (stride == 4)
-      COPY_DWORDS( out, data, count );
-   else
-      for (i = 0; i < count; i++) {
-        out[0] = *(int *)data;
-        out++;
-        data += stride;
-      }
-}
-
-
-static void emit_vec8( GLcontext *ctx,
-                      struct radeon_dma_region *rvb,
-                      char *data,
-                      int stride,
-                      int count )
-{
-   int i;
-   int *out = (int *)(rvb->address + rvb->start);
-
-   if (RADEON_DEBUG & DEBUG_VERTS)
-      fprintf(stderr, "%s count %d stride %d\n",
-             __FUNCTION__, count, stride);
-
-   if (stride == 8)
-      COPY_DWORDS( out, data, count*2 );
-   else
-      for (i = 0; i < count; i++) {
-        out[0] = *(int *)data;
-        out[1] = *(int *)(data+4);
-        out += 2;
-        data += stride;
-      }
-}
-
-static void emit_vec12( GLcontext *ctx,
-                      struct radeon_dma_region *rvb,
-                      char *data,
-                      int stride,
-                      int count )
-{
-   int i;
-   int *out = (int *)(rvb->address + rvb->start);
-
-   if (RADEON_DEBUG & DEBUG_VERTS)
-      fprintf(stderr, "%s count %d stride %d out %p data %p\n",
-             __FUNCTION__, count, stride, (void *)out, (void *)data);
-
-   if (stride == 12)
-      COPY_DWORDS( out, data, count*3 );
-   else
-      for (i = 0; i < count; i++) {
-        out[0] = *(int *)data;
-        out[1] = *(int *)(data+4);
-        out[2] = *(int *)(data+8);
-        out += 3;
-        data += stride;
-      }
-}
-
-static void emit_vec16( GLcontext *ctx,
-                       struct radeon_dma_region *rvb,
-                       char *data,
-                       int stride,
-                       int count )
-{
-   int i;
-   int *out = (int *)(rvb->address + rvb->start);
-
-   if (RADEON_DEBUG & DEBUG_VERTS)
-      fprintf(stderr, "%s count %d stride %d\n",
-             __FUNCTION__, count, stride);
-
-   if (stride == 16)
-      COPY_DWORDS( out, data, count*4 );
-   else
-      for (i = 0; i < count; i++) {
-        out[0] = *(int *)data;
-        out[1] = *(int *)(data+4);
-        out[2] = *(int *)(data+8);
-        out[3] = *(int *)(data+12);
-        out += 4;
-        data += stride;
-      }
-}
-
-
-static void emit_vector( GLcontext *ctx,
-                        struct radeon_dma_region *rvb,
-                        char *data,
-                        int size,
-                        int stride,
-                        int count )
-{
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
-   if (RADEON_DEBUG & DEBUG_VERTS)
-      fprintf(stderr, "%s count %d size %d stride %d\n",
-             __FUNCTION__, count, size, stride);
-
-   assert (!rvb->buf);
-
-   if (stride == 0) {
-      radeonAllocDmaRegion( rmesa, rvb, size * 4, 4 );
-      count = 1;
-      rvb->aos_start = GET_START(rvb);
-      rvb->aos_stride = 0;
-      rvb->aos_size = size;
-   }
-   else {
-      radeonAllocDmaRegion( rmesa, rvb, size * count * 4, 4 ); /* alignment? */
-      rvb->aos_start = GET_START(rvb);
-      rvb->aos_stride = size;
-      rvb->aos_size = size;
-   }
-
-   /* Emit the data
-    */
-   switch (size) {
-   case 1:
-      emit_vec4( ctx, rvb, data, stride, count );
-      break;
-   case 2:
-      emit_vec8( ctx, rvb, data, stride, count );
-      break;
-   case 3:
-      emit_vec12( ctx, rvb, data, stride, count );
-      break;
-   case 4:
-      emit_vec16( ctx, rvb, data, stride, count );
-      break;
-   default:
-      assert(0);
-      exit(1);
-      break;
-   }
-
-}
-
-
-
-static void emit_s0_vec( GLcontext *ctx,
-                        struct radeon_dma_region *rvb,
-                        char *data,
-                        int stride,
-                        int count )
+static void emit_s0_vec(uint32_t *out, GLvoid *data, int stride, int count)
 {
    int i;
-   int *out = (int *)(rvb->address + rvb->start);
-
    if (RADEON_DEBUG & DEBUG_VERTS)
       fprintf(stderr, "%s count %d stride %d\n",
              __FUNCTION__, count, stride);
@@ -384,14 +99,9 @@ static void emit_s0_vec( GLcontext *ctx,
    }
 }
 
-static void emit_stq_vec( GLcontext *ctx,
-                        struct radeon_dma_region *rvb,
-                        char *data,
-                        int stride,
-                        int count )
+static void emit_stq_vec(uint32_t *out, GLvoid *data, int stride, int count)
 {
    int i;
-   int *out = (int *)(rvb->address + rvb->start);
 
    if (RADEON_DEBUG & DEBUG_VERTS)
       fprintf(stderr, "%s count %d stride %d\n",
@@ -409,21 +119,16 @@ static void emit_stq_vec( GLcontext *ctx,
 
 
 
-static void emit_tex_vector( GLcontext *ctx,
-                            struct radeon_dma_region *rvb,
-                            char *data,
-                            int size,
-                            int stride,
-                            int count )
+static void emit_tex_vector(GLcontext *ctx, struct radeon_aos *aos,
+                           GLvoid *data, int size, int stride, int count)
 {
    radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
    int emitsize;
+   uint32_t *out;
 
    if (RADEON_DEBUG & DEBUG_VERTS)
       fprintf(stderr, "%s %d/%d\n", __FUNCTION__, count, size);
 
-   assert (!rvb->buf);
-
    switch (size) {
    case 4: emitsize = 3; break;
    case 3: emitsize = 3; break;
@@ -432,34 +137,33 @@ static void emit_tex_vector( GLcontext *ctx,
 
 
    if (stride == 0) {
-      radeonAllocDmaRegion( rmesa, rvb, 4 * emitsize, 4 );
+      radeonAllocDmaRegion(rmesa, &aos->bo, &aos->offset, emitsize * 4, 32);
       count = 1;
-      rvb->aos_start = GET_START(rvb);
-      rvb->aos_stride = 0;
-      rvb->aos_size = emitsize;
+      aos->stride = 0;
    }
    else {
-      radeonAllocDmaRegion( rmesa, rvb, 4 * emitsize * count, 4 );
-      rvb->aos_start = GET_START(rvb);
-      rvb->aos_stride = emitsize;
-      rvb->aos_size = emitsize;
+      radeonAllocDmaRegion(rmesa, &aos->bo, &aos->offset, emitsize * count * 4, 32);
+      aos->stride = emitsize;
    }
 
+   aos->components = emitsize;
+   aos->count = count;
 
    /* Emit the data
     */
+   out = (uint32_t*)((char*)aos->bo->ptr + aos->offset);
    switch (size) {
    case 1:
-      emit_s0_vec( ctx, rvb, data, stride, count ); 
+      emit_s0_vec( out, data, stride, count );
       break;
    case 2:
-      emit_vec8( ctx, rvb, data, stride, count );
+      radeonEmitVec8( out, data, stride, count );
       break;
    case 3:
-      emit_vec12( ctx, rvb, data, stride, count );
+      radeonEmitVec12( out, data, stride, count );
       break;
    case 4:
-      emit_stq_vec( ctx, rvb, data, stride, count );
+      emit_stq_vec( out, data, stride, count );
       break;
    default:
       assert(0);
@@ -476,9 +180,8 @@ static void emit_tex_vector( GLcontext *ctx,
  */
 void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+   r100ContextPtr rmesa = R100_CONTEXT( ctx );
    struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
-   struct radeon_dma_region **component = rmesa->tcl.aos_components;
    GLuint nr = 0;
    GLuint vfmt = 0;
    GLuint count = VB->Count;
@@ -491,12 +194,12 @@ void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
 
    if (1) {
       if (!rmesa->tcl.obj.buf) 
-        emit_vector( ctx, 
-                     &rmesa->tcl.obj, 
-                     (char *)VB->ObjPtr->data,
-                     VB->ObjPtr->size,
-                     VB->ObjPtr->stride,
-                     count);
+       rcommon_emit_vector( ctx, 
+                            &(rmesa->tcl.aos[nr]),
+                            (char *)VB->ObjPtr->data,
+                            VB->ObjPtr->size,
+                            VB->ObjPtr->stride,
+                            count);
 
       switch( VB->ObjPtr->size ) {
       case 4: vfmt |= RADEON_CP_VC_FRMT_W0;
@@ -505,21 +208,21 @@ void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
       default:
          break;
       }
-      component[nr++] = &rmesa->tcl.obj;
+      nr++;
    }
    
 
    if (inputs & VERT_BIT_NORMAL) {
       if (!rmesa->tcl.norm.buf)
-        emit_vector( ctx, 
-                     &(rmesa->tcl.norm), 
-                     (char *)VB->NormalPtr->data,
-                     3,
-                     VB->NormalPtr->stride,
-                     count);
+        rcommon_emit_vector( ctx, 
+                             &(rmesa->tcl.aos[nr]),
+                             (char *)VB->NormalPtr->data,
+                             3,
+                             VB->NormalPtr->stride,
+                             count);
 
       vfmt |= RADEON_CP_VC_FRMT_N0;
-      component[nr++] = &rmesa->tcl.norm;
+      nr++;
    }
 
    if (inputs & VERT_BIT_COLOR0) {
@@ -537,31 +240,30 @@ void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
       }
 
       if (!rmesa->tcl.rgba.buf)
-        emit_vector( ctx,
-                     &(rmesa->tcl.rgba),
-                     (char *)VB->ColorPtr[0]->data,
-                     emitsize,
-                     VB->ColorPtr[0]->stride,
-                     count);
-
-
-      component[nr++] = &rmesa->tcl.rgba;
+       rcommon_emit_vector( ctx,
+                            &(rmesa->tcl.aos[nr]),
+                            (char *)VB->ColorPtr[0]->data,
+                            emitsize,
+                            VB->ColorPtr[0]->stride,
+                            count);
+
+      nr++;
    }
 
 
    if (inputs & VERT_BIT_COLOR1) {
       if (!rmesa->tcl.spec.buf) {
 
-        emit_vector( ctx,
-                     &rmesa->tcl.spec,
-                     (char *)VB->SecondaryColorPtr[0]->data,
-                     3,
-                     VB->SecondaryColorPtr[0]->stride,
-                     count);
+       rcommon_emit_vector( ctx,
+                            &(rmesa->tcl.aos[nr]),
+                            (char *)VB->SecondaryColorPtr[0]->data,
+                            3,
+                            VB->SecondaryColorPtr[0]->stride,
+                            count);
       }
 
       vfmt |= RADEON_CP_VC_FRMT_FPSPEC;
-      component[nr++] = &rmesa->tcl.spec;
+      nr++;
    }
 
 /* FIXME: not sure if this is correct. May need to stitch this together with
@@ -570,13 +272,13 @@ void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
    if (inputs & VERT_BIT_FOG) {
       if (!rmesa->tcl.fog.buf)
         emit_vecfog( ctx,
-                     &(rmesa->tcl.fog),
+                     &(rmesa->tcl.aos[nr]),
                      (char *)VB->FogCoordPtr->data,
                      VB->FogCoordPtr->stride,
                      count);
 
       vfmt |= RADEON_CP_VC_FRMT_FPFOG;
-      component[nr++] = &rmesa->tcl.fog;
+      nr++;
    }
 
 
@@ -587,11 +289,12 @@ void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
       if (inputs & VERT_BIT_TEX(unit)) {
         if (!rmesa->tcl.tex[unit].buf)
            emit_tex_vector( ctx,
-                            &(rmesa->tcl.tex[unit]),
+                            &(rmesa->tcl.aos[nr]),
                             (char *)VB->TexCoordPtr[unit]->data,
                             VB->TexCoordPtr[unit]->size,
                             VB->TexCoordPtr[unit]->stride,
                             count );
+        nr++;
 
         vfmt |= RADEON_ST_BIT(unit);
          /* assume we need the 3rd coord if texgen is active for r/q OR at least
@@ -609,7 +312,6 @@ void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
                 (swaptexmatcol != ((rmesa->TexMatColSwap >> unit) & 1)))
               radeonUploadTexMatrix( rmesa, unit, swaptexmatcol ) ;
         }
-        component[nr++] = &rmesa->tcl.tex[unit];
       }
    }
 
@@ -622,34 +324,3 @@ void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
    rmesa->tcl.vertex_format = vfmt;
 }
 
-
-void radeonReleaseArrays( GLcontext *ctx, GLuint newinputs )
-{
-   radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
-   GLuint unit;
-
-#if 0
-   if (RADEON_DEBUG & DEBUG_VERTS) 
-      _tnl_print_vert_flags( __FUNCTION__, newinputs );
-#endif
-
-   if (newinputs & VERT_BIT_POS) 
-     radeonReleaseDmaRegion( rmesa, &rmesa->tcl.obj, __FUNCTION__ );
-
-   if (newinputs & VERT_BIT_NORMAL) 
-      radeonReleaseDmaRegion( rmesa, &rmesa->tcl.norm, __FUNCTION__ );
-
-   if (newinputs & VERT_BIT_COLOR0) 
-      radeonReleaseDmaRegion( rmesa, &rmesa->tcl.rgba, __FUNCTION__ );
-
-   if (newinputs & VERT_BIT_COLOR1) 
-      radeonReleaseDmaRegion( rmesa, &rmesa->tcl.spec, __FUNCTION__ );
-      
-   if (newinputs & VERT_BIT_FOG)
-      radeonReleaseDmaRegion( rmesa, &rmesa->tcl.fog, __FUNCTION__ );
-
-   for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++) {
-      if (newinputs & VERT_BIT_TEX(unit))
-         radeonReleaseDmaRegion( rmesa, &rmesa->tcl.tex[unit], __FUNCTION__ );
-   }
-}
index 126d0727c637e90c9c07465386845bc5f090ffaf..78ec1193026bb0e26171803b70c69c7daa1f82a7 100644 (file)
@@ -310,7 +310,7 @@ static void init_tcl_verts( void )
 
 void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
    GLuint req = 0;
    GLuint unit;
@@ -374,14 +374,15 @@ void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
         break;
 
    if (rmesa->tcl.vertex_format == setup_tab[i].vertex_format &&
-       rmesa->tcl.indexed_verts.buf)
+       rmesa->radeon.tcl.aos[0].bo)
       return;
 
-   if (rmesa->tcl.indexed_verts.buf)
+   if (rmesa->radeon.tcl.aos[0].bo)
       radeonReleaseArrays( ctx, ~0 );
 
-   radeonAllocDmaRegion( rmesa,
-                        &rmesa->tcl.indexed_verts, 
+   radeonAllocDmaRegion( &rmesa->radeon,
+                        &rmesa->radeon.tcl.aos[0].bo,
+                        &rmesa->radeon.tcl.aos[0].offset,
                         VB->Count * setup_tab[i].vertex_size * 4, 
                         4);
 
@@ -421,29 +422,12 @@ void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
 
 
    setup_tab[i].emit( ctx, 0, VB->Count, 
-                     rmesa->tcl.indexed_verts.address + 
-                     rmesa->tcl.indexed_verts.start );
+                     rmesa->radeon.tcl.aos[0].bo->ptr + rmesa->radeon.tcl.aos[0].offset);
 
+   //   rmesa->radeon.tcl.aos[0].size = setup_tab[i].vertex_size;
+   rmesa->radeon.tcl.aos[0].stride = setup_tab[i].vertex_size;
    rmesa->tcl.vertex_format = setup_tab[i].vertex_format;
-   rmesa->tcl.indexed_verts.aos_start = GET_START( &rmesa->tcl.indexed_verts );
-   rmesa->tcl.indexed_verts.aos_size = setup_tab[i].vertex_size;
-   rmesa->tcl.indexed_verts.aos_stride = setup_tab[i].vertex_size;
-
-   rmesa->tcl.aos_components[0] = &rmesa->tcl.indexed_verts;
-   rmesa->tcl.nr_aos_components = 1;
+   rmesa->radeon.tcl.aos_count = 1;
 }
 
 
-
-void radeonReleaseArrays( GLcontext *ctx, GLuint newinputs )
-{
-   radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
-
-#if 0
-   if (RADEON_DEBUG & DEBUG_VERTS) 
-      _tnl_print_vert_flags( __FUNCTION__, newinputs );
-#endif
-
-   if (newinputs) 
-     radeonReleaseDmaRegion( rmesa, &rmesa->tcl.indexed_verts, __FUNCTION__ );
-}
diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
new file mode 100644 (file)
index 0000000..55aa450
--- /dev/null
@@ -0,0 +1,415 @@
+/*
+ * 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_mipmap_tree.h"
+
+#include <errno.h>
+#include <unistd.h>
+
+#include "main/simple_list.h"
+#include "main/texcompress.h"
+#include "main/texformat.h"
+
+static GLuint radeon_compressed_texture_size(GLcontext *ctx,
+               GLsizei width, GLsizei height, GLsizei depth,
+               GLuint mesaFormat)
+{
+       GLuint size = _mesa_compressed_texture_size(ctx, width, height, depth, mesaFormat);
+
+       if (mesaFormat == MESA_FORMAT_RGB_DXT1 ||
+           mesaFormat == MESA_FORMAT_RGBA_DXT1) {
+               if (width + 3 < 8)      /* width one block */
+                       size = size * 4;
+               else if (width + 3 < 16)
+                       size = size * 2;
+       } else {
+               /* DXT3/5, 16 bytes per block */
+         //            WARN_ONCE("DXT 3/5 suffers from multitexturing problems!\n");
+               if (width + 3 < 8)
+                       size = size * 2;
+       }
+
+       return size;
+}
+
+
+static int radeon_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;
+}
+
+/**
+ * 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(radeonContextPtr rmesa, radeon_mipmap_tree *mt,
+       GLuint face, GLuint level, GLuint* curOffset)
+{
+       radeon_mipmap_level *lvl = &mt->levels[level];
+       uint32_t row_align = rmesa->texture_row_align - 1;
+
+       /* Find image size in bytes */
+       if (mt->compressed) {
+               /* TODO: Is this correct? Need test cases for compressed textures! */
+               lvl->rowstride = (lvl->width * mt->bpp + 63) & ~63;
+               lvl->size = radeon_compressed_texture_size(mt->radeon->glCtx,
+                                                          lvl->width, lvl->height, lvl->depth, mt->compressed);
+       } else if (mt->target == GL_TEXTURE_RECTANGLE_NV) {
+               lvl->rowstride = (lvl->width * mt->bpp + 63) & ~63;
+               lvl->size = lvl->rowstride * lvl->height;
+       } else if (mt->tilebits & RADEON_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 */
+               lvl->rowstride = (lvl->width * mt->bpp * 2 + 31) & ~31;
+               lvl->size = lvl->rowstride * ((lvl->height + 1) / 2) * lvl->depth;
+       } else {
+               lvl->rowstride = (lvl->width * mt->bpp + row_align) & ~row_align;
+               lvl->size = lvl->rowstride * lvl->height * lvl->depth;
+       }
+       assert(lvl->size > 0);
+
+       /* All images are aligned to a 32-byte offset */
+       *curOffset = (*curOffset + 0x1f) & ~0x1f;
+       lvl->faces[face].offset = *curOffset;
+       *curOffset += lvl->size;
+
+       if (RADEON_DEBUG & DEBUG_TEXTURE)
+         fprintf(stderr,
+                 "level %d, face %d: rs:%d %dx%d at %d\n",
+                 level, face, lvl->rowstride, lvl->width, lvl->height, lvl->faces[face].offset);
+}
+
+static GLuint minify(GLuint size, GLuint levels)
+{
+       size = size >> levels;
+       if (size < 1)
+               size = 1;
+       return size;
+}
+
+
+static void calculate_miptree_layout_r100(radeonContextPtr rmesa, radeon_mipmap_tree *mt)
+{
+       GLuint curOffset;
+       GLuint numLevels;
+       GLuint i;
+       GLuint face;
+
+       numLevels = mt->lastLevel - mt->firstLevel + 1;
+       assert(numLevels <= rmesa->glCtx->Const.MaxTextureLevels);
+
+       curOffset = 0;
+       for(face = 0; face < mt->faces; face++) {
+
+               for(i = 0; i < numLevels; i++) {
+                       mt->levels[i].width = minify(mt->width0, i);
+                       mt->levels[i].height = minify(mt->height0, i);
+                       mt->levels[i].depth = minify(mt->depth0, i);
+                       compute_tex_image_offset(rmesa, mt, face, i, &curOffset);
+               }
+       }
+
+       /* Note the required size in memory */
+       mt->totalsize = (curOffset + RADEON_OFFSET_MASK) & ~RADEON_OFFSET_MASK;
+}
+
+static void calculate_miptree_layout_r300(radeonContextPtr rmesa, radeon_mipmap_tree *mt)
+{
+       GLuint curOffset;
+       GLuint numLevels;
+       GLuint i;
+
+       numLevels = mt->lastLevel - mt->firstLevel + 1;
+       assert(numLevels <= rmesa->glCtx->Const.MaxTextureLevels);
+
+       curOffset = 0;
+       for(i = 0; i < numLevels; i++) {
+               GLuint face;
+
+               mt->levels[i].width = minify(mt->width0, i);
+               mt->levels[i].height = minify(mt->height0, i);
+               mt->levels[i].depth = minify(mt->depth0, i);
+
+               for(face = 0; face < mt->faces; face++)
+                       compute_tex_image_offset(rmesa, mt, face, i, &curOffset);
+       }
+
+       /* Note the required size in memory */
+       mt->totalsize = (curOffset + RADEON_OFFSET_MASK) & ~RADEON_OFFSET_MASK;
+}
+
+/**
+ * Create a new mipmap tree, calculate its layout and allocate memory.
+ */
+radeon_mipmap_tree* radeon_miptree_create(radeonContextPtr rmesa, radeonTexObj *t,
+               GLenum target, GLuint firstLevel, GLuint lastLevel,
+               GLuint width0, GLuint height0, GLuint depth0,
+               GLuint bpp, GLuint tilebits, GLuint compressed)
+{
+       radeon_mipmap_tree *mt = CALLOC_STRUCT(_radeon_mipmap_tree);
+
+       mt->radeon = rmesa;
+       mt->refcount = 1;
+       mt->t = t;
+       mt->target = target;
+       mt->faces = (target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
+       mt->firstLevel = firstLevel;
+       mt->lastLevel = lastLevel;
+       mt->width0 = width0;
+       mt->height0 = height0;
+       mt->depth0 = depth0;
+       mt->bpp = compressed ? radeon_compressed_num_bytes(compressed) : bpp;
+       mt->tilebits = tilebits;
+       mt->compressed = compressed;
+
+       if (rmesa->radeonScreen->chip_family >= CHIP_FAMILY_R300)
+               calculate_miptree_layout_r300(rmesa, mt);
+       else
+               calculate_miptree_layout_r100(rmesa, mt);
+
+       mt->bo = radeon_bo_open(rmesa->radeonScreen->bom,
+                            0, mt->totalsize, 1024,
+                            RADEON_GEM_DOMAIN_VRAM,
+                            0);
+
+       return mt;
+}
+
+void radeon_miptree_reference(radeon_mipmap_tree *mt)
+{
+       mt->refcount++;
+       assert(mt->refcount > 0);
+}
+
+void radeon_miptree_unreference(radeon_mipmap_tree *mt)
+{
+       if (!mt)
+               return;
+
+       assert(mt->refcount > 0);
+       mt->refcount--;
+       if (!mt->refcount) {
+               radeon_bo_unref(mt->bo);
+               free(mt);
+       }
+}
+
+
+/**
+ * Calculate first and last mip levels for the given texture object,
+ * where the dimensions are taken from the given texture image at
+ * the given level.
+ *
+ * Note: level is the OpenGL level number, which is not necessarily the same
+ * as the first level that is actually present.
+ *
+ * The base level image of the given texture face must be non-null,
+ * or this will fail.
+ */
+static void calculate_first_last_level(struct gl_texture_object *tObj,
+                                      GLuint *pfirstLevel, GLuint *plastLevel,
+                                      GLuint face, GLuint level)
+{
+       const struct gl_texture_image * const baseImage =
+               tObj->Image[face][level];
+
+       assert(baseImage);
+       
+       /* These must be signed values.  MinLod and MaxLod can be negative numbers,
+       * and having firstLevel and lastLevel as signed prevents the need for
+       * extra sign checks.
+       */
+       int   firstLevel;
+       int   lastLevel;
+
+       /* Yes, this looks overly complicated, but it's all needed.
+       */
+       switch (tObj->Target) {
+       case GL_TEXTURE_1D:
+       case GL_TEXTURE_2D:
+       case GL_TEXTURE_3D:
+       case GL_TEXTURE_CUBE_MAP:
+               if (tObj->MinFilter == GL_NEAREST || tObj->MinFilter == GL_LINEAR) {
+                       /* GL_NEAREST and GL_LINEAR only care about GL_TEXTURE_BASE_LEVEL.
+                       */
+                       firstLevel = lastLevel = tObj->BaseLevel;
+               } else {
+                       firstLevel = tObj->BaseLevel + (GLint)(tObj->MinLod + 0.5);
+                       firstLevel = MAX2(firstLevel, tObj->BaseLevel);
+                       firstLevel = MIN2(firstLevel, level + baseImage->MaxLog2);
+                       lastLevel = tObj->BaseLevel + (GLint)(tObj->MaxLod + 0.5);
+                       lastLevel = MAX2(lastLevel, tObj->BaseLevel);
+                       lastLevel = MIN2(lastLevel, level + baseImage->MaxLog2);
+                       lastLevel = MIN2(lastLevel, 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 */
+       *pfirstLevel = firstLevel;
+       *plastLevel = lastLevel;
+}
+
+
+/**
+ * Checks whether the given miptree can hold the given texture image at the
+ * given face and level.
+ */
+GLboolean radeon_miptree_matches_image(radeon_mipmap_tree *mt,
+               struct gl_texture_image *texImage, GLuint face, GLuint level)
+{
+       radeon_mipmap_level *lvl;
+
+       if (face >= mt->faces || level < mt->firstLevel || level > mt->lastLevel)
+               return GL_FALSE;
+
+       if (texImage->IsCompressed != mt->compressed)
+               return GL_FALSE;
+
+       if (!texImage->IsCompressed &&
+           !mt->compressed &&
+           texImage->TexFormat->TexelBytes != mt->bpp)
+               return GL_FALSE;
+
+       lvl = &mt->levels[level - mt->firstLevel];
+       if (lvl->width != texImage->Width ||
+           lvl->height != texImage->Height ||
+           lvl->depth != texImage->Depth)
+               return GL_FALSE;
+
+       return GL_TRUE;
+}
+
+
+/**
+ * Checks whether the given miptree has the right format to store the given texture object.
+ */
+GLboolean radeon_miptree_matches_texture(radeon_mipmap_tree *mt, struct gl_texture_object *texObj)
+{
+       struct gl_texture_image *firstImage;
+       GLuint compressed;
+       GLuint numfaces = 1;
+       GLuint firstLevel, lastLevel;
+
+       calculate_first_last_level(texObj, &firstLevel, &lastLevel, 0, texObj->BaseLevel);
+       if (texObj->Target == GL_TEXTURE_CUBE_MAP)
+               numfaces = 6;
+
+       firstImage = texObj->Image[0][firstLevel];
+       compressed = firstImage->IsCompressed ? firstImage->TexFormat->MesaFormat : 0;
+
+       return (mt->firstLevel == firstLevel &&
+               mt->lastLevel == lastLevel &&
+               mt->width0 == firstImage->Width &&
+               mt->height0 == firstImage->Height &&
+               mt->depth0 == firstImage->Depth &&
+               mt->bpp == firstImage->TexFormat->TexelBytes &&
+               mt->compressed == compressed);
+}
+
+
+/**
+ * Try to allocate a mipmap tree for the given texture that will fit the
+ * given image in the given position.
+ */
+void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t,
+               struct gl_texture_image *texImage, GLuint face, GLuint level)
+{
+       GLuint compressed = texImage->IsCompressed ? texImage->TexFormat->MesaFormat : 0;
+       GLuint numfaces = 1;
+       GLuint firstLevel, lastLevel;
+
+       assert(!t->mt);
+
+       calculate_first_last_level(&t->base, &firstLevel, &lastLevel, face, level);
+       if (t->base.Target == GL_TEXTURE_CUBE_MAP)
+               numfaces = 6;
+
+       if (level != firstLevel || face >= numfaces)
+               return;
+
+       t->mt = radeon_miptree_create(rmesa, t, t->base.Target,
+               firstLevel, lastLevel,
+               texImage->Width, texImage->Height, texImage->Depth,
+               texImage->TexFormat->TexelBytes, t->tile_bits, compressed);
+}
+
+/* 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:
+ */
+void
+radeon_miptree_depth_offsets(radeon_mipmap_tree *mt, GLuint level, GLuint *offsets)
+{
+     if (mt->target != GL_TEXTURE_3D || mt->faces == 1)
+        offsets[0] = 0;
+     else {
+       int i;
+       for (i = 0; i < 6; i++)
+               offsets[i] = mt->levels[level].faces[i].offset;
+     }
+}
+
+GLuint
+radeon_miptree_image_offset(radeon_mipmap_tree *mt,
+                           GLuint face, GLuint level)
+{
+   if (mt->target == GL_TEXTURE_CUBE_MAP_ARB)
+      return (mt->levels[level].faces[face].offset);
+   else
+      return mt->levels[level].faces[0].offset;
+}
diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h
new file mode 100644 (file)
index 0000000..7ece688
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * 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_MIPMAP_TREE_H_
+#define __RADEON_MIPMAP_TREE_H_
+
+#include "radeon_common.h"
+
+typedef struct _radeon_mipmap_tree radeon_mipmap_tree;
+typedef struct _radeon_mipmap_level radeon_mipmap_level;
+typedef struct _radeon_mipmap_image radeon_mipmap_image;
+
+struct _radeon_mipmap_image {
+       GLuint offset; /** Offset of this image from the start of mipmap tree buffer, in bytes */
+};
+
+struct _radeon_mipmap_level {
+       GLuint width;
+       GLuint height;
+       GLuint depth;
+       GLuint size; /** Size of each image, in bytes */
+       GLuint rowstride; /** in bytes */
+       radeon_mipmap_image faces[6];
+};
+
+/* store the max possible in the miptree */
+#define RADEON_MIPTREE_MAX_TEXTURE_LEVELS 13
+
+/**
+ * A mipmap tree contains texture images in the layout that the hardware
+ * expects.
+ *
+ * The meta-data of mipmap trees is immutable, i.e. you cannot change the
+ * layout on-the-fly; however, the texture contents (i.e. texels) can be
+ * changed.
+ */
+struct _radeon_mipmap_tree {
+       radeonContextPtr radeon;
+       radeonTexObj *t;
+       struct radeon_bo *bo;
+       GLuint refcount;
+
+       GLuint totalsize; /** total size of the miptree, in bytes */
+
+       GLenum target; /** GL_TEXTURE_xxx */
+       GLuint faces; /** # of faces: 6 for cubemaps, 1 otherwise */
+       GLuint firstLevel; /** First mip level stored in this mipmap tree */
+       GLuint lastLevel; /** Last mip level stored in this mipmap tree */
+
+       GLuint width0; /** Width of firstLevel image */
+       GLuint height0; /** Height of firstLevel image */
+       GLuint depth0; /** Depth of firstLevel image */
+
+       GLuint bpp; /** Bytes per texel */
+       GLuint tilebits; /** RADEON_TXO_xxx_TILE */
+       GLuint compressed; /** MESA_FORMAT_xxx indicating a compressed format, or 0 if uncompressed */
+
+       radeon_mipmap_level levels[RADEON_MIPTREE_MAX_TEXTURE_LEVELS];
+};
+
+radeon_mipmap_tree* radeon_miptree_create(radeonContextPtr rmesa, radeonTexObj *t,
+               GLenum target, GLuint firstLevel, GLuint lastLevel,
+               GLuint width0, GLuint height0, GLuint depth0,
+               GLuint bpp, GLuint tilebits, GLuint compressed);
+void radeon_miptree_reference(radeon_mipmap_tree *mt);
+void radeon_miptree_unreference(radeon_mipmap_tree *mt);
+
+GLboolean radeon_miptree_matches_image(radeon_mipmap_tree *mt,
+               struct gl_texture_image *texImage, GLuint face, GLuint level);
+GLboolean radeon_miptree_matches_texture(radeon_mipmap_tree *mt, struct gl_texture_object *texObj);
+void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t,
+                             struct gl_texture_image *texImage, GLuint face, GLuint level);
+GLuint radeon_miptree_image_offset(radeon_mipmap_tree *mt,
+                                  GLuint face, GLuint level);
+void radeon_miptree_depth_offsets(radeon_mipmap_tree *mt, GLuint level, GLuint *offsets);
+#endif /* __RADEON_MIPMAP_TREE_H_ */
index 6613757fceaade82fb45b64af32729233f54d255..bbed838b592dcff737e2182f495cf171ff144a31 100644 (file)
@@ -973,7 +973,7 @@ static int radeon_emit_packet3_cliprect( drm_radeon_cmd_buffer_t *cmdbuf )
 }
 
 
-int radeonSanityCmdBuffer( radeonContextPtr rmesa,
+int radeonSanityCmdBuffer( r100ContextPtr rmesa,
                           int nbox,
                           drm_clip_rect_t *boxes )
 {
index 1ec06bc586bf8d5000cf092ccb545ec87123dfc0..f30eb1c4f15621f9a77dda7f18e35762ef756faa 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef RADEON_SANITY_H
 #define RADEON_SANITY_H
 
-extern int radeonSanityCmdBuffer( radeonContextPtr rmesa,
+extern int radeonSanityCmdBuffer( r100ContextPtr rmesa,
                                  int nbox,
                                  drm_clip_rect_t *boxes );
 
index 791f59826bd5418ccf9d582b6eefd11733a6313e..12ae4ada5db4898a808f1446aa4c74cba4809271 100644 (file)
@@ -35,6 +35,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  * \author  Gareth Hughes <gareth@valinux.com>
  */
 
+#include <errno.h>
 #include "main/glheader.h"
 #include "main/imports.h"
 #include "main/mtypes.h"
@@ -45,32 +46,39 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "radeon_chipset.h"
 #include "radeon_macros.h"
 #include "radeon_screen.h"
+#include "radeon_common.h"
+#include "radeon_span.h"
 #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"
 #include "r300_tex.h"
-#include "radeon_span.h"
 #endif
 
 #include "utils.h"
 #include "vblank.h"
 #include "drirenderbuffer.h"
 
+#include "radeon_bocs_wrapper.h"
+
 #include "GL/internal/dri_interface.h"
 
 /* Radeon configuration
  */
 #include "xmlpool.h"
 
+#define DRI_CONF_COMMAND_BUFFER_SIZE(def,min,max) \
+DRI_CONF_OPT_BEGIN_V(command_buffer_size,int,def, # min ":" # max ) \
+        DRI_CONF_DESC(en,"Size of command buffer (in KB)") \
+        DRI_CONF_DESC(de,"Grösse des Befehlspuffers (in KB)") \
+DRI_CONF_OPT_END
+
 #if !RADEON_COMMON     /* R100 */
 PUBLIC const char __driConfigOptions[] =
 DRI_CONF_BEGIN
@@ -80,6 +88,7 @@ DRI_CONF_BEGIN
         DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
         DRI_CONF_MAX_TEXTURE_UNITS(3,2,3)
         DRI_CONF_HYPERZ(false)
+        DRI_CONF_COMMAND_BUFFER_SIZE(8, 8, 32)
     DRI_CONF_SECTION_END
     DRI_CONF_SECTION_QUALITY
         DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
@@ -95,7 +104,7 @@ DRI_CONF_BEGIN
         DRI_CONF_NO_RAST(false)
     DRI_CONF_SECTION_END
 DRI_CONF_END;
-static const GLuint __driNConfigOptions = 14;
+static const GLuint __driNConfigOptions = 15;
 
 #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
 
@@ -107,6 +116,7 @@ DRI_CONF_BEGIN
         DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
         DRI_CONF_MAX_TEXTURE_UNITS(6,2,6)
         DRI_CONF_HYPERZ(false)
+        DRI_CONF_COMMAND_BUFFER_SIZE(8, 8, 32)
     DRI_CONF_SECTION_END
     DRI_CONF_SECTION_QUALITY
         DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
@@ -126,7 +136,7 @@ DRI_CONF_BEGIN
         DRI_CONF_NV_VERTEX_PROGRAM(false)
     DRI_CONF_SECTION_END
 DRI_CONF_END;
-static const GLuint __driNConfigOptions = 16;
+static const GLuint __driNConfigOptions = 17;
 
 extern const struct dri_extension blend_extensions[];
 extern const struct dri_extension ARB_vp_extension[];
@@ -149,11 +159,7 @@ DRI_CONF_OPT_BEGIN_V(texture_coord_units,int,def, # min ":" # max ) \
         DRI_CONF_DESC(de,"Anzahl der Texturkoordinateneinheiten") \
 DRI_CONF_OPT_END
 
-#define DRI_CONF_COMMAND_BUFFER_SIZE(def,min,max) \
-DRI_CONF_OPT_BEGIN_V(command_buffer_size,int,def, # min ":" # max ) \
-        DRI_CONF_DESC(en,"Size of command buffer (in KB)") \
-        DRI_CONF_DESC(de,"Grösse des Befehlspuffers (in KB)") \
-DRI_CONF_OPT_END
+
 
 #define DRI_CONF_DISABLE_S3TC(def) \
 DRI_CONF_OPT_BEGIN(disable_s3tc,bool,def) \
@@ -209,7 +215,6 @@ static const GLuint __driNConfigOptions = 17;
 extern const struct dri_extension gl_20_extension[];
 
 #ifndef RADEON_DEBUG
-int RADEON_DEBUG = 0;
 
 static const struct dri_debug_control debug_control[] = {
        {"fall", DEBUG_FALLBACKS},
@@ -236,19 +241,36 @@ static const struct dri_debug_control debug_control[] = {
 #endif /* RADEON_COMMON && defined(RADEON_COMMON_FOR_R300) */
 
 extern const struct dri_extension card_extensions[];
+extern const struct dri_extension mm_extensions[];
 
 static int getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo );
 
 static int
-radeonGetParam(int fd, int param, void *value)
+radeonGetParam(__DRIscreenPrivate *sPriv, int param, void *value)
 {
   int ret;
-  drm_radeon_getparam_t gp;
-
-  gp.param = param;
-  gp.value = value;
+  drm_radeon_getparam_t gp = { 0 };
+  struct drm_radeon_info info = { 0 };
+
+  if (sPriv->drm_version.major >= 2) {
+      info.value = (uint64_t)value;
+      switch (param) {
+      case RADEON_PARAM_DEVICE_ID:
+          info.request = RADEON_INFO_DEVICE_ID;
+          break;
+      case RADEON_PARAM_NUM_GB_PIPES:
+          info.request = RADEON_INFO_NUM_GB_PIPES;
+          break;
+      default:
+          return -EINVAL;
+      }
+      ret = drmCommandWriteRead(sPriv->fd, DRM_RADEON_INFO, &info, sizeof(info));
+  } else {
+      gp.param = param;
+      gp.value = value;
 
-  ret = drmCommandWriteRead( fd, DRM_RADEON_GETPARAM, &gp, sizeof(gp));
+      ret = drmCommandWriteRead(sPriv->fd, DRM_RADEON_GETPARAM, &gp, sizeof(gp));
+  }
   return ret;
 }
 
@@ -335,6 +357,12 @@ static const __DRItexOffsetExtension radeonTexOffsetExtension = {
     { __DRI_TEX_OFFSET, __DRI_TEX_OFFSET_VERSION },
     radeonSetTexOffset,
 };
+
+static const __DRItexBufferExtension radeonTexBufferExtension = {
+    { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
+   radeonSetTexBuffer,
+   radeonSetTexBuffer2,
+};
 #endif
 
 #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
@@ -349,6 +377,12 @@ static const __DRItexOffsetExtension r200texOffsetExtension = {
     { __DRI_TEX_OFFSET, __DRI_TEX_OFFSET_VERSION },
    r200SetTexOffset,
 };
+
+static const __DRItexBufferExtension r200TexBufferExtension = {
+    { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
+   r200SetTexBuffer,
+   r200SetTexBuffer2,
+};
 #endif
 
 #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
@@ -356,137 +390,19 @@ static const __DRItexOffsetExtension r300texOffsetExtension = {
     { __DRI_TEX_OFFSET, __DRI_TEX_OFFSET_VERSION },
    r300SetTexOffset,
 };
-#endif
 
-/* Create the device specific screen private data struct.
- */
-static radeonScreenPtr
-radeonCreateScreen( __DRIscreenPrivate *sPriv )
-{
-   radeonScreenPtr screen;
-   RADEONDRIPtr dri_priv = (RADEONDRIPtr)sPriv->pDevPriv;
-   unsigned char *RADEONMMIO;
-   int i;
-   int ret;
-   uint32_t temp = 0;
-
-   if (sPriv->devPrivSize != sizeof(RADEONDRIRec)) {
-      fprintf(stderr,"\nERROR!  sizeof(RADEONDRIRec) does not match passed size from device driver\n");
-      return GL_FALSE;
-   }
-
-   /* Allocate the private area */
-   screen = (radeonScreenPtr) CALLOC( sizeof(*screen) );
-   if ( !screen ) {
-      __driUtilMessage("%s: Could not allocate memory for screen structure",
-                      __FUNCTION__);
-      return NULL;
-   }
-
-#if DO_DEBUG && RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
-       RADEON_DEBUG = driParseDebugString(getenv("RADEON_DEBUG"), debug_control);
+static const __DRItexBufferExtension r300TexBufferExtension = {
+    { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
+   r300SetTexBuffer,
+   r300SetTexBuffer2,
+};
 #endif
 
-   /* parse information in __driConfigOptions */
-   driParseOptionInfo (&screen->optionCache,
-                      __driConfigOptions, __driNConfigOptions);
-
-   /* This is first since which regions we map depends on whether or
-    * not we are using a PCI card.
-    */
-   screen->card_type = (dri_priv->IsPCI ? RADEON_CARD_PCI : RADEON_CARD_AGP);
-   {
-      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);
-        return NULL;
-      }
-
-      ret = radeonGetParam( sPriv->fd, RADEON_PARAM_GART_BASE,
-                           &screen->gart_base);
-      if (ret) {
-        FREE( screen );
-        fprintf(stderr, "drm_radeon_getparam_t (RADEON_PARAM_GART_BASE): %d\n", ret);
-        return NULL;
-      }
-
-      ret = radeonGetParam( sPriv->fd, RADEON_PARAM_IRQ_NR,
-                           &screen->irq);
-      if (ret) {
-        FREE( screen );
-        fprintf(stderr, "drm_radeon_getparam_t (RADEON_PARAM_IRQ_NR): %d\n", ret);
-        return NULL;
-      }
-      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;
-   screen->mmio.size   = dri_priv->registerSize;
-   if ( drmMap( sPriv->fd,
-               screen->mmio.handle,
-               screen->mmio.size,
-               &screen->mmio.map ) ) {
-      FREE( screen );
-      __driUtilMessage("%s: drmMap failed\n", __FUNCTION__ );
-      return NULL;
-   }
-
-   RADEONMMIO = screen->mmio.map;
-
-   screen->status.handle = dri_priv->statusHandle;
-   screen->status.size   = dri_priv->statusSize;
-   if ( drmMap( sPriv->fd,
-               screen->status.handle,
-               screen->status.size,
-               &screen->status.map ) ) {
-      drmUnmap( screen->mmio.map, screen->mmio.size );
-      FREE( screen );
-      __driUtilMessage("%s: drmMap (2) failed\n", __FUNCTION__ );
-      return NULL;
-   }
-   screen->scratch = (__volatile__ uint32_t *)
-      ((GLubyte *)screen->status.map + RADEON_SCRATCH_REG_OFFSET);
-
-   screen->buffers = drmMapBufs( sPriv->fd );
-   if ( !screen->buffers ) {
-      drmUnmap( screen->status.map, screen->status.size );
-      drmUnmap( screen->mmio.map, screen->mmio.size );
-      FREE( screen );
-      __driUtilMessage("%s: drmMapBufs failed\n", __FUNCTION__ );
-      return NULL;
-   }
-
-   if ( dri_priv->gartTexHandle && dri_priv->gartTexMapSize ) {
-      screen->gartTextures.handle = dri_priv->gartTexHandle;
-      screen->gartTextures.size   = dri_priv->gartTexMapSize;
-      if ( drmMap( sPriv->fd,
-                  screen->gartTextures.handle,
-                  screen->gartTextures.size,
-                  (drmAddressPtr)&screen->gartTextures.map ) ) {
-        drmUnmapBufs( screen->buffers );
-        drmUnmap( screen->status.map, screen->status.size );
-        drmUnmap( screen->mmio.map, screen->mmio.size );
-        FREE( screen );
-        __driUtilMessage("%s: drmMap failed for GART texture area\n", __FUNCTION__);
-        return NULL;
-      }
-
-      screen->gart_texture_offset = dri_priv->gartTexOffset + screen->gart_base;
-   }
-
+static int radeon_set_screen_flags(radeonScreenPtr screen, int device_id)
+{
+   screen->device_id = device_id;
    screen->chip_flags = 0;
-   /* XXX: add more chipsets */
-   switch ( dri_priv->deviceID ) {
+   switch ( device_id ) {
    case PCI_CHIP_RADEON_LY:
    case PCI_CHIP_RADEON_LZ:
    case PCI_CHIP_RADEON_QY:
@@ -561,7 +477,6 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
       screen->chip_family = CHIP_FAMILY_RS300;
       break;
 
-
    case PCI_CHIP_R300_AD:
    case PCI_CHIP_R300_AE:
    case PCI_CHIP_R300_AF:
@@ -821,9 +736,145 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
 
    default:
       fprintf(stderr, "unknown chip id 0x%x, can't guess.\n",
-             dri_priv->deviceID);
+             device_id);
+      return -1;
+   }
+
+   return 0;
+}
+
+
+/* Create the device specific screen private data struct.
+ */
+static radeonScreenPtr
+radeonCreateScreen( __DRIscreenPrivate *sPriv )
+{
+   radeonScreenPtr screen;
+   RADEONDRIPtr dri_priv = (RADEONDRIPtr)sPriv->pDevPriv;
+   unsigned char *RADEONMMIO = NULL;
+   int i;
+   int ret;
+   uint32_t temp = 0;
+
+   if (sPriv->devPrivSize != sizeof(RADEONDRIRec)) {
+      fprintf(stderr,"\nERROR!  sizeof(RADEONDRIRec) does not match passed size from device driver\n");
+      return GL_FALSE;
+   }
+
+   /* Allocate the private area */
+   screen = (radeonScreenPtr) CALLOC( sizeof(*screen) );
+   if ( !screen ) {
+      __driUtilMessage("%s: Could not allocate memory for screen structure",
+                      __FUNCTION__);
       return NULL;
    }
+
+#if DO_DEBUG && RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
+       RADEON_DEBUG = driParseDebugString(getenv("RADEON_DEBUG"), debug_control);
+#endif
+
+   /* parse information in __driConfigOptions */
+   driParseOptionInfo (&screen->optionCache,
+                      __driConfigOptions, __driNConfigOptions);
+
+   /* This is first since which regions we map depends on whether or
+    * not we are using a PCI card.
+    */
+   screen->card_type = (dri_priv->IsPCI ? RADEON_CARD_PCI : RADEON_CARD_AGP);
+   {
+      int ret;
+
+      ret = radeonGetParam(sPriv, 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);
+        return NULL;
+      }
+
+      ret = radeonGetParam(sPriv, RADEON_PARAM_GART_BASE,
+                           &screen->gart_base);
+      if (ret) {
+        FREE( screen );
+        fprintf(stderr, "drm_radeon_getparam_t (RADEON_PARAM_GART_BASE): %d\n", ret);
+        return NULL;
+      }
+
+      ret = radeonGetParam(sPriv, RADEON_PARAM_IRQ_NR,
+                           &screen->irq);
+      if (ret) {
+        FREE( screen );
+        fprintf(stderr, "drm_radeon_getparam_t (RADEON_PARAM_IRQ_NR): %d\n", ret);
+        return NULL;
+      }
+      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;
+   screen->mmio.size   = dri_priv->registerSize;
+   if ( drmMap( sPriv->fd,
+               screen->mmio.handle,
+               screen->mmio.size,
+               &screen->mmio.map ) ) {
+     FREE( screen );
+     __driUtilMessage("%s: drmMap failed\n", __FUNCTION__ );
+     return NULL;
+   }
+
+   RADEONMMIO = screen->mmio.map;
+
+   screen->status.handle = dri_priv->statusHandle;
+   screen->status.size   = dri_priv->statusSize;
+   if ( drmMap( sPriv->fd,
+               screen->status.handle,
+               screen->status.size,
+               &screen->status.map ) ) {
+     drmUnmap( screen->mmio.map, screen->mmio.size );
+     FREE( screen );
+     __driUtilMessage("%s: drmMap (2) failed\n", __FUNCTION__ );
+     return NULL;
+   }
+   screen->scratch = (__volatile__ uint32_t *)
+     ((GLubyte *)screen->status.map + RADEON_SCRATCH_REG_OFFSET);
+
+   screen->buffers = drmMapBufs( sPriv->fd );
+   if ( !screen->buffers ) {
+     drmUnmap( screen->status.map, screen->status.size );
+     drmUnmap( screen->mmio.map, screen->mmio.size );
+     FREE( screen );
+     __driUtilMessage("%s: drmMapBufs failed\n", __FUNCTION__ );
+     return NULL;
+   }
+
+   if ( dri_priv->gartTexHandle && dri_priv->gartTexMapSize ) {
+     screen->gartTextures.handle = dri_priv->gartTexHandle;
+     screen->gartTextures.size   = dri_priv->gartTexMapSize;
+     if ( drmMap( sPriv->fd,
+                 screen->gartTextures.handle,
+                 screen->gartTextures.size,
+                 (drmAddressPtr)&screen->gartTextures.map ) ) {
+       drmUnmapBufs( screen->buffers );
+       drmUnmap( screen->status.map, screen->status.size );
+       drmUnmap( screen->mmio.map, screen->mmio.size );
+       FREE( screen );
+       __driUtilMessage("%s: drmMap failed for GART texture area\n", __FUNCTION__);
+       return NULL;
+    }
+
+     screen->gart_texture_offset = dri_priv->gartTexOffset + screen->gart_base;
+   }
+
+   ret = radeon_set_screen_flags(screen, dri_priv->deviceID);
+   if (ret == -1)
+     return NULL;
+
    if ((screen->chip_family == CHIP_FAMILY_R350 || screen->chip_family == CHIP_FAMILY_R300) &&
        sPriv->ddx_version.minor < 2) {
       fprintf(stderr, "xf86-video-ati-6.6.2 or newer needed for Radeon 9500/9700/9800 cards.\n");
@@ -848,8 +899,7 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
    screen->cpp = dri_priv->bpp / 8;
    screen->AGPMode = dri_priv->AGPMode;
 
-   ret = radeonGetParam( sPriv->fd, RADEON_PARAM_FB_LOCATION,
-                         &temp);
+   ret = radeonGetParam(sPriv, RADEON_PARAM_FB_LOCATION, &temp);
    if (ret) {
        if (screen->chip_family < CHIP_FAMILY_RS600)
           screen->fbLocation      = ( INREG( RADEON_MC_FB_LOCATION ) & 0xffff) << 16;
@@ -863,8 +913,7 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
    }
 
    if (screen->chip_family >= CHIP_FAMILY_R300) {
-       ret = radeonGetParam( sPriv->fd, RADEON_PARAM_NUM_GB_PIPES,
-                            &temp);
+       ret = radeonGetParam(sPriv, RADEON_PARAM_NUM_GB_PIPES, &temp);
        if (ret) {
           fprintf(stderr, "Unable to get num_pipes, need newer drm\n");
           switch (screen->chip_family) {
@@ -901,7 +950,6 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
        default:
           break;
        }
-
    }
 
    if ( sPriv->drm_version.minor >= 10 ) {
@@ -971,7 +1019,7 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
 
 #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
    if (IS_R200_CLASS(screen))
-       screen->extensions[i++] = &r200AllocateExtension.base;
+      screen->extensions[i++] = &r200AllocateExtension.base;
 
    screen->extensions[i++] = &r200texOffsetExtension.base;
 #endif
@@ -985,6 +1033,153 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
 
    screen->driScreen = sPriv;
    screen->sarea_priv_offset = dri_priv->sarea_priv_offset;
+   screen->sarea = (drm_radeon_sarea_t *) ((GLubyte *) sPriv->pSAREA +
+                                              screen->sarea_priv_offset);
+
+   screen->bom = radeon_bo_manager_legacy_ctor(screen);
+   if (screen->bom == NULL) {
+     free(screen);
+     return NULL;
+   }
+
+   return screen;
+}
+
+static radeonScreenPtr
+radeonCreateScreen2(__DRIscreenPrivate *sPriv)
+{
+   radeonScreenPtr screen;
+   int i;
+   int ret;
+   uint32_t device_id = 0;
+   uint32_t temp = 0;
+
+   /* Allocate the private area */
+   screen = (radeonScreenPtr) CALLOC( sizeof(*screen) );
+   if ( !screen ) {
+      __driUtilMessage("%s: Could not allocate memory for screen structure",
+                      __FUNCTION__);
+      fprintf(stderr, "leaving here\n");
+      return NULL;
+   }
+
+#if DO_DEBUG && RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
+       RADEON_DEBUG = driParseDebugString(getenv("RADEON_DEBUG"), debug_control);
+#endif
+
+   /* parse information in __driConfigOptions */
+   driParseOptionInfo (&screen->optionCache,
+                      __driConfigOptions, __driNConfigOptions);
+
+   screen->kernel_mm = 1;
+   screen->chip_flags = 0;
+
+   /* if we have kms we can support all of these */
+   screen->drmSupportsCubeMapsR200 = 1;
+   screen->drmSupportsBlendColor = 1;
+   screen->drmSupportsTriPerf = 1;
+   screen->drmSupportsFragShader = 1;
+   screen->drmSupportsPointSprites = 1;
+   screen->drmSupportsCubeMapsR100 = 1;
+   screen->drmSupportsVertexProgram = 1;
+   screen->irq = 1;
+
+   ret = radeonGetParam(sPriv, RADEON_PARAM_DEVICE_ID, &device_id);
+   if (ret) {
+     FREE( screen );
+     fprintf(stderr, "drm_radeon_getparam_t (RADEON_PARAM_DEVICE_ID): %d\n", ret);
+     return NULL;
+   }
+
+   ret = radeon_set_screen_flags(screen, device_id);
+   if (ret == -1)
+     return NULL;
+
+   if (screen->chip_family >= CHIP_FAMILY_R300) {
+       ret = radeonGetParam(sPriv, 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;
+       }
+
+       /* pipe overrides */
+       switch (device_id) {
+       case PCI_CHIP_R300_AD: /* 9500 with 1 quadpipe verified by: Reid Linnemann <lreid@cs.okstate.edu> */
+       case PCI_CHIP_RV410_5E4C: /* RV410 SE only have 1 quadpipe */
+       case PCI_CHIP_RV410_5E4F: /* RV410 SE only have 1 quadpipe */
+          screen->num_gb_pipes = 1;
+          break;
+       default:
+          break;
+       }
+
+   }
+
+   if (screen->chip_family <= CHIP_FAMILY_RS200)
+      screen->chip_flags |= RADEON_CLASS_R100;
+   else if (screen->chip_family <= CHIP_FAMILY_RV280)
+      screen->chip_flags |= RADEON_CLASS_R200;
+   else
+      screen->chip_flags |= RADEON_CLASS_R300;
+
+   if (getenv("R300_NO_TCL"))
+     screen->chip_flags &= ~RADEON_CHIPSET_TCL;
+
+   i = 0;
+   screen->extensions[i++] = &driCopySubBufferExtension.base;
+   screen->extensions[i++] = &driFrameTrackingExtension.base;
+   screen->extensions[i++] = &driReadDrawableExtension;
+
+   if ( screen->irq != 0 ) {
+       screen->extensions[i++] = &driSwapControlExtension.base;
+       screen->extensions[i++] = &driMediaStreamCounterExtension.base;
+   }
+
+#if !RADEON_COMMON
+   screen->extensions[i++] = &radeonTexBufferExtension.base;
+#endif
+
+#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
+   if (IS_R200_CLASS(screen))
+       screen->extensions[i++] = &r200AllocateExtension.base;
+
+   screen->extensions[i++] = &r200TexBufferExtension.base;
+#endif
+
+#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
+   screen->extensions[i++] = &r300TexBufferExtension.base;
+#endif
+
+   screen->extensions[i++] = NULL;
+   sPriv->extensions = screen->extensions;
+
+   screen->driScreen = sPriv;
+   screen->bom = radeon_bo_manager_gem_ctor(sPriv->fd);
+   if (screen->bom == NULL) {
+       free(screen);
+       return NULL;
+   }
    return screen;
 }
 
@@ -993,23 +1188,32 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
 static void
 radeonDestroyScreen( __DRIscreenPrivate *sPriv )
 {
-   radeonScreenPtr screen = (radeonScreenPtr)sPriv->private;
+    radeonScreenPtr screen = (radeonScreenPtr)sPriv->private;
 
-   if (!screen)
-      return;
+    if (!screen)
+        return;
 
-   if ( screen->gartTextures.map ) {
-      drmUnmap( screen->gartTextures.map, screen->gartTextures.size );
-   }
-   drmUnmapBufs( screen->buffers );
-   drmUnmap( screen->status.map, screen->status.size );
-   drmUnmap( screen->mmio.map, screen->mmio.size );
+    if (screen->kernel_mm) {
+#ifdef RADEON_BO_TRACK
+        radeon_tracker_print(&screen->bom->tracker, stderr);
+#endif
+        radeon_bo_manager_gem_dtor(screen->bom);
+    } else {
+        radeon_bo_manager_legacy_dtor(screen->bom);
+
+        if ( screen->gartTextures.map ) {
+            drmUnmap( screen->gartTextures.map, screen->gartTextures.size );
+        }
+        drmUnmapBufs( screen->buffers );
+        drmUnmap( screen->status.map, screen->status.size );
+        drmUnmap( screen->mmio.map, screen->mmio.size );
+    }
 
-   /* free all option information */
-   driDestroyOptionInfo (&screen->optionCache);
+    /* free all option information */
+    driDestroyOptionInfo (&screen->optionCache);
 
-   FREE( screen );
-   sPriv->private = NULL;
+    FREE( screen );
+    sPriv->private = NULL;
 }
 
 
@@ -1018,16 +1222,21 @@ radeonDestroyScreen( __DRIscreenPrivate *sPriv )
 static GLboolean
 radeonInitDriver( __DRIscreenPrivate *sPriv )
 {
-   sPriv->private = (void *) radeonCreateScreen( sPriv );
-   if ( !sPriv->private ) {
-      radeonDestroyScreen( sPriv );
-      return GL_FALSE;
-   }
+    if (sPriv->dri2.enabled) {
+        sPriv->private = (void *) radeonCreateScreen2( sPriv );
+    } else {
+        sPriv->private = (void *) radeonCreateScreen( sPriv );
+    }
+    if ( !sPriv->private ) {
+        radeonDestroyScreen( sPriv );
+        return GL_FALSE;
+    }
 
-   return GL_TRUE;
+    return GL_TRUE;
 }
 
 
+
 /**
  * Create the Mesa framebuffer and renderbuffers for a given window/drawable.
  *
@@ -1040,101 +1249,111 @@ radeonCreateBuffer( __DRIscreenPrivate *driScrnPriv,
                     const __GLcontextModes *mesaVis,
                     GLboolean isPixmap )
 {
-   radeonScreenPtr screen = (radeonScreenPtr) driScrnPriv->private;
+    radeonScreenPtr screen = (radeonScreenPtr) driScrnPriv->private;
+
+    const GLboolean swDepth = GL_FALSE;
+    const GLboolean swAlpha = GL_FALSE;
+    const GLboolean swAccum = mesaVis->accumRedBits > 0;
+    const GLboolean swStencil = mesaVis->stencilBits > 0 &&
+       mesaVis->depthBits != 24;
+    GLenum rgbFormat;
+    struct radeon_framebuffer *rfb;
 
-   if (isPixmap) {
+    if (isPixmap)
       return GL_FALSE; /* not implemented */
-   }
-   else {
-      const GLboolean swDepth = GL_FALSE;
-      const GLboolean swAlpha = GL_FALSE;
-      const GLboolean swAccum = mesaVis->accumRedBits > 0;
-      const GLboolean swStencil = mesaVis->stencilBits > 0 &&
-         mesaVis->depthBits != 24;
-      struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
-
-      /* front color renderbuffer */
-      {
-         driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA,
-                                 driScrnPriv->pFB + screen->frontOffset,
-                                 screen->cpp,
-                                 screen->frontOffset, screen->frontPitch,
-                                 driDrawPriv);
-         radeonSetSpanFunctions(frontRb, mesaVis);
-         _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
-      }
 
-      /* back color renderbuffer */
-      if (mesaVis->doubleBufferMode) {
-         driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA,
-                                 driScrnPriv->pFB + screen->backOffset,
-                                 screen->cpp,
-                                 screen->backOffset, screen->backPitch,
-                                 driDrawPriv);
-         radeonSetSpanFunctions(backRb, mesaVis);
-         _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
-      }
+    rfb = CALLOC_STRUCT(radeon_framebuffer);
+    if (!rfb)
+      return GL_FALSE;
 
-      /* depth renderbuffer */
-      if (mesaVis->depthBits == 16) {
-         driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16,
-                                 driScrnPriv->pFB + screen->depthOffset,
-                                 screen->cpp,
-                                 screen->depthOffset, screen->depthPitch,
-                                 driDrawPriv);
-         radeonSetSpanFunctions(depthRb, mesaVis);
-         _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
-        depthRb->depthHasSurface = screen->depthHasSurface;
-      }
-      else if (mesaVis->depthBits == 24) {
-         driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT24,
-                                 driScrnPriv->pFB + screen->depthOffset,
-                                 screen->cpp,
-                                 screen->depthOffset, screen->depthPitch,
-                                 driDrawPriv);
-         radeonSetSpanFunctions(depthRb, mesaVis);
-         _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
-        depthRb->depthHasSurface = screen->depthHasSurface;
-      }
+    _mesa_initialize_framebuffer(&rfb->base, mesaVis);
+
+    if (mesaVis->redBits == 5)
+        rgbFormat = GL_RGB5;
+    else if (mesaVis->alphaBits == 0)
+        rgbFormat = GL_RGB8;
+    else
+        rgbFormat = GL_RGBA8;
+
+    /* front color renderbuffer */
+    rfb->color_rb[0] = radeon_create_renderbuffer(rgbFormat, driDrawPriv);
+    _mesa_add_renderbuffer(&rfb->base, BUFFER_FRONT_LEFT, &rfb->color_rb[0]->base);
+    rfb->color_rb[0]->has_surface = 1;
+
+    /* back color renderbuffer */
+    if (mesaVis->doubleBufferMode) {
+      rfb->color_rb[1] = radeon_create_renderbuffer(rgbFormat, driDrawPriv);
+       _mesa_add_renderbuffer(&rfb->base, BUFFER_BACK_LEFT, &rfb->color_rb[1]->base);
+       rfb->color_rb[1]->has_surface = 1;
+    }
 
-      /* stencil renderbuffer */
-      if (mesaVis->stencilBits > 0 && !swStencil) {
-         driRenderbuffer *stencilRb
-            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT,
-                                 driScrnPriv->pFB + screen->depthOffset,
-                                 screen->cpp,
-                                 screen->depthOffset, screen->depthPitch,
-                                 driDrawPriv);
-         radeonSetSpanFunctions(stencilRb, mesaVis);
-         _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
-        stencilRb->depthHasSurface = screen->depthHasSurface;
+    if (mesaVis->depthBits == 24) {
+      if (mesaVis->stencilBits == 8) {
+       struct radeon_renderbuffer *depthStencilRb = radeon_create_renderbuffer(GL_DEPTH24_STENCIL8_EXT, driDrawPriv);
+       _mesa_add_renderbuffer(&rfb->base, BUFFER_DEPTH, &depthStencilRb->base);
+       _mesa_add_renderbuffer(&rfb->base, BUFFER_STENCIL, &depthStencilRb->base);
+       depthStencilRb->has_surface = screen->depthHasSurface;
+      } else {
+       /* depth renderbuffer */
+       struct radeon_renderbuffer *depth = radeon_create_renderbuffer(GL_DEPTH_COMPONENT24, driDrawPriv);
+       _mesa_add_renderbuffer(&rfb->base, BUFFER_DEPTH, &depth->base);
+       depth->has_surface = screen->depthHasSurface;
       }
+    } else if (mesaVis->depthBits == 16) {
+      /* just 16-bit depth buffer, no hw stencil */
+       struct radeon_renderbuffer *depth = radeon_create_renderbuffer(GL_DEPTH_COMPONENT16, driDrawPriv);
+       _mesa_add_renderbuffer(&rfb->base, BUFFER_DEPTH, &depth->base);
+       depth->has_surface = screen->depthHasSurface;
+    }
 
-      _mesa_add_soft_renderbuffers(fb,
-                                   GL_FALSE, /* color */
-                                   swDepth,
-                                   swStencil,
-                                   swAccum,
-                                   swAlpha,
-                                   GL_FALSE /* aux */);
-      driDrawPriv->driverPrivate = (void *) fb;
+    _mesa_add_soft_renderbuffers(&rfb->base,
+           GL_FALSE, /* color */
+           swDepth,
+           swStencil,
+           swAccum,
+           swAlpha,
+           GL_FALSE /* aux */);
+    driDrawPriv->driverPrivate = (void *) rfb;
 
-      return (driDrawPriv->driverPrivate != NULL);
-   }
+    return (driDrawPriv->driverPrivate != NULL);
 }
 
 
-static void
+static void radeon_cleanup_renderbuffers(struct radeon_framebuffer *rfb)
+{
+       struct radeon_renderbuffer *rb;
+
+       rb = rfb->color_rb[0];
+       if (rb && rb->bo) {
+               radeon_bo_unref(rb->bo);
+               rb->bo = NULL;
+       }
+       rb = rfb->color_rb[1];
+       if (rb && rb->bo) {
+               radeon_bo_unref(rb->bo);
+               rb->bo = NULL;
+       }
+       rb = radeon_get_renderbuffer(&rfb->base, BUFFER_DEPTH);
+       if (rb && rb->bo) {
+               radeon_bo_unref(rb->bo);
+               rb->bo = NULL;
+       }
+}
+
+void
 radeonDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
 {
-   _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
+    struct radeon_framebuffer *rfb;
+    if (!driDrawPriv)
+       return;
+
+    rfb = (void*)driDrawPriv->driverPrivate;
+    if (!rfb)
+       return;
+    radeon_cleanup_renderbuffers(rfb);
+    _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
 }
 
-#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
 /**
  * Choose the appropriate CreateContext function based on the chipset.
  * Eventually, all drivers will go through this process.
@@ -1145,25 +1364,22 @@ static GLboolean radeonCreateContext(const __GLcontextModes * glVisual,
 {
        __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
        radeonScreenPtr screen = (radeonScreenPtr) (sPriv->private);
-
+#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
        if (IS_R300_CLASS(screen))
                return r300CreateContext(glVisual, driContextPriv, sharedContextPriv);
-        return GL_FALSE;
-}
-
-/**
- * Choose the appropriate DestroyContext function based on the chipset.
- */
-static void radeonDestroyContext(__DRIcontextPrivate * driContextPriv)
-{
-       radeonContextPtr radeon = (radeonContextPtr) driContextPriv->driverPrivate;
-
-       if (IS_R300_CLASS(radeon->radeonScreen))
-               return r300DestroyContext(driContextPriv);
-}
+#endif
 
+#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
+       if (IS_R200_CLASS(screen))
+               return r200CreateContext(glVisual, driContextPriv, sharedContextPriv);
+#endif
 
+#if !RADEON_COMMON
+       (void)screen;
+       return r100CreateContext(glVisual, driContextPriv, sharedContextPriv);
 #endif
+       return GL_FALSE;
+}
 
 
 /**
@@ -1225,13 +1441,103 @@ radeonInitScreen(__DRIscreenPrivate *psp)
    if (!radeonInitDriver(psp))
        return NULL;
 
+   /* for now fill in all modes */
    return radeonFillInModes( psp,
                             dri_priv->bpp,
                             (dri_priv->bpp == 16) ? 16 : 24,
-                            (dri_priv->bpp == 16) ? 0  : 8,
-                            (dri_priv->backOffset != dri_priv->depthOffset) );
+                            (dri_priv->bpp == 16) ? 0  : 8, 1);
 }
+#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
+
+/**
+ * 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 **radeonInitScreen2(__DRIscreenPrivate *psp)
+{
+   GLenum fb_format[3];
+   GLenum fb_type[3];
+   /* 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*/
+   };
+   uint8_t depth_bits[4], stencil_bits[4], msaa_samples_array[1];
+   int color;
+   __DRIconfig **configs = 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 );
+   driInitExtensions( NULL, mm_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 );
+#endif
+
+   if (!radeonInitDriver(psp)) {
+       return NULL;
+    }
+   depth_bits[0] = 0;
+   stencil_bits[0] = 0;
+   depth_bits[1] = 16;
+   stencil_bits[1] = 0;
+   depth_bits[2] = 24;
+   stencil_bits[2] = 0;
+   depth_bits[3] = 24;
+   stencil_bits[3] = 8;
+
+   msaa_samples_array[0] = 0;
+
+   fb_format[0] = GL_RGB;
+   fb_type[0] = GL_UNSIGNED_SHORT_5_6_5;
+
+   fb_format[1] = GL_BGR;
+   fb_type[1] = GL_UNSIGNED_INT_8_8_8_8_REV;
+
+   fb_format[2] = GL_BGRA;
+   fb_type[2] = GL_UNSIGNED_INT_8_8_8_8_REV;
+
+   for (color = 0; color < ARRAY_SIZE(fb_format); color++) {
+      __DRIconfig **new_configs;
+
+      new_configs = driCreateConfigs(fb_format[color], fb_type[color],
+                                    depth_bits,
+                                    stencil_bits,
+                                    ARRAY_SIZE(depth_bits),
+                                    back_buffer_modes,
+                                    ARRAY_SIZE(back_buffer_modes),
+                                    msaa_samples_array,
+                                    ARRAY_SIZE(msaa_samples_array));
+      if (configs == NULL)
+        configs = new_configs;
+      else
+        configs = driConcatConfigs(configs, new_configs);
+   }
 
+   if (configs == NULL) {
+      fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
+              __LINE__);
+      return NULL;
+   }
+
+   return (const __DRIconfig **)configs;
+}
 
 /**
  * Get information about previous buffer swaps.
@@ -1239,31 +1545,26 @@ radeonInitScreen(__DRIscreenPrivate *psp)
 static int
 getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo )
 {
-#if !RADEON_COMMON || (RADEON_COMMON && defined(RADEON_COMMON_FOR_R300))
-   radeonContextPtr  rmesa;
-#elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
-   r200ContextPtr  rmesa;
-#endif
+    struct radeon_framebuffer *rfb;
 
-   if ( (dPriv == NULL) || (dPriv->driContextPriv == NULL)
-       || (dPriv->driContextPriv->driverPrivate == NULL)
-       || (sInfo == NULL) ) {
-      return -1;
+    if ( (dPriv == NULL) || (dPriv->driContextPriv == NULL)
+        || (dPriv->driContextPriv->driverPrivate == NULL)
+        || (sInfo == NULL) ) {
+       return -1;
    }
 
-   rmesa = dPriv->driContextPriv->driverPrivate;
-   sInfo->swap_count = rmesa->swap_count;
-   sInfo->swap_ust = rmesa->swap_ust;
-   sInfo->swap_missed_count = rmesa->swap_missed_count;
+    rfb = dPriv->driverPrivate;
+    sInfo->swap_count = rfb->swap_count;
+    sInfo->swap_ust = rfb->swap_ust;
+    sInfo->swap_missed_count = rfb->swap_missed_count;
 
    sInfo->swap_missed_usage = (sInfo->swap_missed_count != 0)
-       ? driCalculateSwapUsage( dPriv, 0, rmesa->swap_missed_ust )
+       ? driCalculateSwapUsage( dPriv, 0, rfb->swap_missed_ust )
        : 0.0;
 
    return 0;
 }
 
-#if !RADEON_COMMON || (RADEON_COMMON && defined(RADEON_COMMON_FOR_R300))
 const struct __DriverAPIRec driDriverAPI = {
    .InitScreen      = radeonInitScreen,
    .DestroyScreen   = radeonDestroyScreen,
@@ -1280,23 +1581,7 @@ const struct __DriverAPIRec driDriverAPI = {
    .WaitForSBC      = NULL,
    .SwapBuffersMSC  = NULL,
    .CopySubBuffer   = radeonCopySubBuffer,
+    /* DRI2 */
+   .InitScreen2     = radeonInitScreen2,
 };
-#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 b84c70bfae9c429144d77c94a0877f9bc3dc7608..fe5c7d875a0577f772037f0f455fcc458bd91eaa 100644 (file)
@@ -54,11 +54,12 @@ typedef struct {
    drmAddress map;                     /* Mapping of the DRM region */
 } radeonRegionRec, *radeonRegionPtr;
 
-typedef struct {
+typedef struct radeon_screen {
    int chip_family;
    int chip_flags;
    int cpp;
    int card_type;
+   int device_id; /* PCI ID */
    int AGPMode;
    unsigned int irq;                   /* IRQ number (0 means none) */
 
@@ -103,9 +104,12 @@ typedef struct {
    /* Configuration cache with default values for all contexts */
    driOptionCache optionCache;
 
-   const __DRIextension *extensions[8];
+   const __DRIextension *extensions[16];
 
    int num_gb_pipes;
+   int kernel_mm;
+   drm_radeon_sarea_t *sarea;  /* Private SAREA data */
+   struct radeon_bo_manager *bom;
 } radeonScreenRec, *radeonScreenPtr;
 
 #define IS_R100_CLASS(screen) \
@@ -115,4 +119,5 @@ typedef struct {
 #define IS_R300_CLASS(screen) \
        ((screen->chip_flags & RADEON_CLASS_MASK) == RADEON_CLASS_R300)
 
+extern void radeonDestroyBuffer(__DRIdrawablePrivate *driDrawPriv);
 #endif /* __RADEON_SCREEN_H__ */
index 12051ff1c8110d99e11373989fafeff4c09e4144..e28f28662b458da7b15a587e8862e2f965236c7f 100644 (file)
@@ -43,46 +43,203 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/glheader.h"
 #include "swrast/swrast.h"
 
-#include "radeon_context.h"
-#include "radeon_ioctl.h"
-#include "radeon_state.h"
+#include "radeon_common.h"
+#include "radeon_lock.h"
 #include "radeon_span.h"
-#include "radeon_tex.h"
-
-#include "drirenderbuffer.h"
 
 #define DBG 0
 
+static void radeonSetSpanFunctions(struct radeon_renderbuffer *rrb);
+
+static GLubyte *radeon_ptr32(const struct radeon_renderbuffer * rrb,
+                            GLint x, GLint y)
+{
+    GLubyte *ptr = rrb->bo->ptr;
+    uint32_t mask = RADEON_BO_FLAGS_MACRO_TILE | RADEON_BO_FLAGS_MICRO_TILE;
+    GLint offset;
+    GLint nmacroblkpl;
+    GLint nmicroblkpl;
+
+    if (rrb->has_surface || !(rrb->bo->flags & mask)) {
+        offset = x * rrb->cpp + y * rrb->pitch;
+    } else {
+        offset = 0;
+        if (rrb->bo->flags & RADEON_BO_FLAGS_MACRO_TILE) {
+            if (rrb->bo->flags & RADEON_BO_FLAGS_MICRO_TILE) {
+                nmacroblkpl = rrb->pitch >> 5;
+                offset += ((y >> 4) * nmacroblkpl) << 11;
+                offset += ((y & 15) >> 1) << 8;
+                offset += (y & 1) << 4;
+                offset += (x >> 5) << 11;
+                offset += ((x & 31) >> 2) << 5;
+                offset += (x & 3) << 2;
+            } else {
+                nmacroblkpl = rrb->pitch >> 6;
+                offset += ((y >> 3) * nmacroblkpl) << 11;
+                offset += (y & 7) << 8;
+                offset += (x >> 6) << 11;
+                offset += ((x & 63) >> 3) << 5;
+                offset += (x & 7) << 2;
+            }
+        } else {
+            nmicroblkpl = ((rrb->pitch + 31) & ~31) >> 5;
+            offset += (y * nmicroblkpl) << 5;
+            offset += (x >> 3) << 5;
+            offset += (x & 7) << 2;
+        }
+    }
+    return &ptr[offset];
+}
+
+static GLubyte *radeon_ptr16(const struct radeon_renderbuffer * rrb,
+                            GLint x, GLint y)
+{
+    GLubyte *ptr = rrb->bo->ptr;
+    uint32_t mask = RADEON_BO_FLAGS_MACRO_TILE | RADEON_BO_FLAGS_MICRO_TILE;
+    GLint offset;
+    GLint nmacroblkpl;
+    GLint nmicroblkpl;
+
+    if (rrb->has_surface || !(rrb->bo->flags & mask)) {
+        offset = x * rrb->cpp + y * rrb->pitch;
+    } else {
+        offset = 0;
+        if (rrb->bo->flags & RADEON_BO_FLAGS_MACRO_TILE) {
+            if (rrb->bo->flags & RADEON_BO_FLAGS_MICRO_TILE) {
+                nmacroblkpl = rrb->pitch >> 6;
+                offset += ((y >> 4) * nmacroblkpl) << 11;
+                offset += ((y & 15) >> 1) << 8;
+                offset += (y & 1) << 4;
+                offset += (x >> 6) << 11;
+                offset += ((x & 63) >> 3) << 5;
+                offset += (x & 7) << 1;
+            } else {
+                nmacroblkpl = rrb->pitch >> 7;
+                offset += ((y >> 3) * nmacroblkpl) << 11;
+                offset += (y & 7) << 8;
+                offset += (x >> 7) << 11;
+                offset += ((x & 127) >> 4) << 5;
+                offset += (x & 15) << 2;
+            }
+        } else {
+            nmicroblkpl = ((rrb->pitch + 31) & ~31) >> 5;
+            offset += (y * nmicroblkpl) << 5;
+            offset += (x >> 4) << 5;
+            offset += (x & 15) << 2;
+        }
+    }
+    return &ptr[offset];
+}
+
+static GLubyte *radeon_ptr(const struct radeon_renderbuffer * rrb,
+                          GLint x, GLint y)
+{
+    GLubyte *ptr = rrb->bo->ptr;
+    uint32_t mask = RADEON_BO_FLAGS_MACRO_TILE | RADEON_BO_FLAGS_MICRO_TILE;
+    GLint offset;
+    GLint microblkxs;
+    GLint macroblkxs;
+    GLint nmacroblkpl;
+    GLint nmicroblkpl;
+
+    if (rrb->has_surface || !(rrb->bo->flags & mask)) {
+        offset = x * rrb->cpp + y * rrb->pitch;
+    } else {
+        offset = 0;
+        if (rrb->bo->flags & RADEON_BO_FLAGS_MACRO_TILE) {
+            if (rrb->bo->flags & RADEON_BO_FLAGS_MICRO_TILE) {
+                microblkxs = 16 / rrb->cpp;
+                macroblkxs = 128 / rrb->cpp;
+                nmacroblkpl = rrb->pitch / macroblkxs;
+                offset += ((y >> 4) * nmacroblkpl) << 11;
+                offset += ((y & 15) >> 1) << 8;
+                offset += (y & 1) << 4;
+                offset += (x / macroblkxs) << 11;
+                offset += ((x & (macroblkxs - 1)) / microblkxs) << 5;
+                offset += (x & (microblkxs - 1)) * rrb->cpp;
+            } else {
+                microblkxs = 32 / rrb->cpp;
+                macroblkxs = 256 / rrb->cpp;
+                nmacroblkpl = rrb->pitch / macroblkxs;
+                offset += ((y >> 3) * nmacroblkpl) << 11;
+                offset += (y & 7) << 8;
+                offset += (x / macroblkxs) << 11;
+                offset += ((x & (macroblkxs - 1)) / microblkxs) << 5;
+                offset += (x & (microblkxs - 1)) * rrb->cpp;
+            }
+        } else {
+            microblkxs = 32 / rrb->cpp;
+            nmicroblkpl = ((rrb->pitch + 31) & ~31) >> 5;
+            offset += (y * nmicroblkpl) << 5;
+            offset += (x / microblkxs) << 5;
+            offset += (x & (microblkxs - 1)) * rrb->cpp;
+        }
+    }
+    return &ptr[offset];
+}
+
+#ifndef COMPILE_R300
+static uint32_t
+z24s8_to_s8z24(uint32_t val)
+{
+   return (val << 24) | (val >> 8);
+}
+
+static uint32_t
+s8z24_to_z24s8(uint32_t val)
+{
+   return (val >> 24) | (val << 8);
+}
+#endif
+
 /*
  * Note that all information needed to access pixels in a renderbuffer
  * should be obtained through the gl_renderbuffer parameter, not per-context
  * information.
  */
 #define LOCAL_VARS                                             \
-   driRenderbuffer *drb = (driRenderbuffer *) rb;              \
-   const __DRIdrawablePrivate *dPriv = drb->dPriv;             \
-   const GLuint bottom = dPriv->h - 1;                         \
-   GLubyte *buf = (GLubyte *) drb->flippedData                 \
-      + (dPriv->y * drb->flippedPitch + dPriv->x) * drb->cpp;  \
-   GLuint p;                                                   \
-   (void) p;
+   struct radeon_context *radeon = RADEON_CONTEXT(ctx);                        \
+   struct radeon_renderbuffer *rrb = (void *) rb;              \
+   const GLint yScale = ctx->DrawBuffer->Name ? 1 : -1;                        \
+   const GLint yBias = ctx->DrawBuffer->Name ? 0 : rrb->base.Height - 1;\
+   unsigned int num_cliprects;                                         \
+   struct drm_clip_rect *cliprects;                                    \
+   int x_off, y_off;                                                   \
+   GLuint p;                                           \
+   (void)p;                                            \
+   radeon_get_cliprects(radeon, &cliprects, &num_cliprects, &x_off, &y_off);
 
 #define LOCAL_DEPTH_VARS                               \
-   driRenderbuffer *drb = (driRenderbuffer *) rb;      \
-   const __DRIdrawablePrivate *dPriv = drb->dPriv;     \
-   const GLuint bottom = dPriv->h - 1;                 \
-   GLuint xo = dPriv->x;                               \
-   GLuint yo = dPriv->y;                               \
-   GLubyte *buf = (GLubyte *) drb->Base.Data;
+   struct radeon_context *radeon = RADEON_CONTEXT(ctx);                        \
+   struct radeon_renderbuffer *rrb = (void *) rb;      \
+   const GLint yScale = ctx->DrawBuffer->Name ? 1 : -1;                        \
+   const GLint yBias = ctx->DrawBuffer->Name ? 0 : rrb->base.Height - 1;\
+   unsigned int num_cliprects;                                         \
+   struct drm_clip_rect *cliprects;                                    \
+   int x_off, y_off;                                                   \
+  radeon_get_cliprects(radeon, &cliprects, &num_cliprects, &x_off, &y_off);
 
 #define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
 
-#define Y_FLIP(Y) (bottom - (Y))
+#define Y_FLIP(_y) ((_y) * yScale + yBias)
 
 #define HW_LOCK()
 
 #define HW_UNLOCK()
 
+/* 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 = num_cliprects;                                         \
+      while ( _nc-- ) {                                                        \
+        int minx = cliprects[_nc].x1 - x_off;                          \
+        int miny = cliprects[_nc].y1 - y_off;                          \
+        int maxx = cliprects[_nc].x2 - x_off;                          \
+        int maxy = cliprects[_nc].y2 - y_off;
+       
 /* ================================================================
  * Color buffer
  */
@@ -94,7 +251,21 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define TAG(x)    radeon##x##_RGB565
 #define TAG2(x,y) radeon##x##_RGB565##y
-#define GET_PTR(X,Y) (buf + ((Y) * drb->flippedPitch + (X)) * 2)
+#define GET_PTR(X,Y) radeon_ptr16(rrb, (X) + x_off, (Y) + y_off)
+#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)    radeon##x##_xRGB8888
+#define TAG2(x,y) radeon##x##_xRGB8888##y
+#define GET_VALUE(_x, _y) ((*(GLuint*)(radeon_ptr32(rrb, _x + x_off, _y + y_off)) | 0xff000000))
+#define PUT_VALUE(_x, _y, d) { \
+   GLuint *_ptr = (GLuint*)radeon_ptr32( rrb, _x + x_off, _y + y_off );                \
+   *_ptr = d;                                                          \
+} while (0)
 #include "spantmp2.h"
 
 /* 32 bit, ARGB8888 color spanline and pixel functions
@@ -104,7 +275,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define TAG(x)    radeon##x##_ARGB8888
 #define TAG2(x,y) radeon##x##_ARGB8888##y
-#define GET_PTR(X,Y) (buf + ((Y) * drb->flippedPitch + (X)) * 4)
+#define GET_PTR(X,Y) radeon_ptr32(rrb, (X) + x_off, (Y) + y_off)
 #include "spantmp2.h"
 
 /* ================================================================
@@ -121,70 +292,20 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  * too...
  */
 
-static GLuint radeon_mba_z32(const driRenderbuffer * drb, GLint x, GLint y)
-{
-       GLuint pitch = drb->pitch;
-       if (drb->depthHasSurface) {
-               return 4 * (x + y * pitch);
-       } else {
-               GLuint ba, address = 0; /* a[0..1] = 0           */
-
-#ifdef COMPILE_R300
-               ba = (y / 8) * (pitch / 8) + (x / 8);
-#else
-               ba = (y / 16) * (pitch / 16) + (x / 16);
-#endif
-
-               address |= (x & 0x7) << 2;      /* a[2..4] = x[0..2]     */
-               address |= (y & 0x3) << 5;      /* a[5..6] = y[0..1]     */
-               address |= (((x & 0x10) >> 2) ^ (y & 0x4)) << 5;        /* a[7]    = x[4] ^ y[2] */
-               address |= (ba & 0x3) << 8;     /* a[8..9] = ba[0..1]    */
-
-               address |= (y & 0x8) << 7;      /* a[10]   = y[3]        */
-               address |= (((x & 0x8) << 1) ^ (y & 0x10)) << 7;        /* a[11]   = x[3] ^ y[4] */
-               address |= (ba & ~0x3) << 10;   /* a[12..] = ba[2..]     */
-
-               return address;
-       }
-}
-
-static INLINE GLuint
-radeon_mba_z16(const driRenderbuffer * drb, GLint x, GLint y)
-{
-       GLuint pitch = drb->pitch;
-       if (drb->depthHasSurface) {
-               return 2 * (x + y * pitch);
-       } else {
-               GLuint ba, address = 0; /* a[0]    = 0           */
-
-               ba = (y / 16) * (pitch / 32) + (x / 32);
-
-               address |= (x & 0x7) << 1;      /* a[1..3] = x[0..2]     */
-               address |= (y & 0x7) << 4;      /* a[4..6] = y[0..2]     */
-               address |= (x & 0x8) << 4;      /* a[7]    = x[3]        */
-               address |= (ba & 0x3) << 8;     /* a[8..9] = ba[0..1]    */
-               address |= (y & 0x8) << 7;      /* a[10]   = y[3]        */
-               address |= ((x & 0x10) ^ (y & 0x10)) << 7;      /* a[11]   = x[4] ^ y[4] */
-               address |= (ba & ~0x3) << 10;   /* a[12..] = ba[2..]     */
-
-               return address;
-       }
-}
-
 /* 16-bit depth buffer functions
  */
 #define VALUE_TYPE GLushort
 
 #define WRITE_DEPTH( _x, _y, d )                                       \
-   *(GLushort *)(buf + radeon_mba_z16( drb, _x + xo, _y + yo )) = d;
+   *(GLushort *)radeon_ptr(rrb, _x + x_off, _y + y_off) = d
 
 #define READ_DEPTH( d, _x, _y )                                                \
-   d = *(GLushort *)(buf + radeon_mba_z16( drb, _x + xo, _y + yo ));
+   d = *(GLushort *)radeon_ptr(rrb, _x + x_off, _y + y_off)
 
 #define TAG(x) radeon##x##_z16
 #include "depthtmp.h"
 
-/* 24 bit depth, 8 bit stencil depthbuffer functions
+/* 24 bit depth
  *
  * Careful: It looks like the R300 uses ZZZS byte order while the R200
  * uses SZZZ for 24 bit depth, 8 bit stencil mode.
@@ -194,35 +315,76 @@ radeon_mba_z16(const driRenderbuffer * drb, GLint x, GLint y)
 #ifdef COMPILE_R300
 #define WRITE_DEPTH( _x, _y, d )                                       \
 do {                                                                   \
-   GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo );            \
-   GLuint tmp = *(GLuint *)(buf + offset);                             \
+   GLuint *_ptr = (GLuint*)radeon_ptr32( rrb, _x + x_off, _y + y_off );                \
+   GLuint tmp = *_ptr;                         \
    tmp &= 0x000000ff;                                                  \
    tmp |= ((d << 8) & 0xffffff00);                                     \
-   *(GLuint *)(buf + offset) = tmp;                                    \
+   *_ptr = tmp;                                        \
 } while (0)
 #else
 #define WRITE_DEPTH( _x, _y, d )                                       \
 do {                                                                   \
-   GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo );            \
-   GLuint tmp = *(GLuint *)(buf + offset);                             \
+   GLuint *_ptr = (GLuint*)radeon_ptr32( rrb, _x + x_off, _y + y_off );        \
+   GLuint tmp = *_ptr;                                                 \
    tmp &= 0xff000000;                                                  \
    tmp |= ((d) & 0x00ffffff);                                          \
-   *(GLuint *)(buf + offset) = tmp;                                    \
+   *_ptr = tmp;                                        \
 } while (0)
 #endif
 
 #ifdef COMPILE_R300
 #define READ_DEPTH( d, _x, _y )                                                \
-  do { \
-    d = (*(GLuint *)(buf + radeon_mba_z32( drb, _x + xo,               \
-                                        _y + yo )) & 0xffffff00) >> 8; \
+  do {                                                                 \
+    d = (*(GLuint*)(radeon_ptr32(rrb, _x + x_off, _y + y_off)) & 0xffffff00) >> 8; \
   }while(0)
 #else
-#define READ_DEPTH( d, _x, _y )                                                \
-   d = *(GLuint *)(buf + radeon_mba_z32( drb, _x + xo,                 \
-                                        _y + yo )) & 0x00ffffff;
+#define READ_DEPTH( d, _x, _y )        \
+  d = *(GLuint*)(radeon_ptr32(rrb, _x + x_off, _y + y_off)) & 0x00ffffff;
+#endif
+/*
+    fprintf(stderr, "dval(%d, %d, %d, %d)=0x%08X\n", _x, xo, _y, yo, d);\
+   d = *(GLuint*)(radeon_ptr(rrb, _x,  _y )) & 0x00ffffff;
+*/
+#define TAG(x) radeon##x##_z24
+#include "depthtmp.h"
+
+/* 24 bit depth, 8 bit stencil depthbuffer functions
+ * EXT_depth_stencil
+ *
+ * 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 {                                                                   \
+   GLuint *_ptr = (GLuint*)radeon_ptr32( rrb, _x + x_off, _y + y_off );                \
+   *_ptr = d;                                                          \
+} while (0)
+#else
+#define WRITE_DEPTH( _x, _y, d )                                       \
+do {                                                                   \
+   GLuint *_ptr = (GLuint*)radeon_ptr32( rrb, _x + x_off, _y + y_off );        \
+   GLuint tmp = z24s8_to_s8z24(d);                                     \
+   *_ptr = tmp;                                        \
+} while (0)
 #endif
 
+#ifdef COMPILE_R300
+#define READ_DEPTH( d, _x, _y )                                                \
+  do { \
+    d = (*(GLuint*)(radeon_ptr32(rrb, _x + x_off, _y + y_off)));       \
+  }while(0)
+#else
+#define READ_DEPTH( d, _x, _y )        do {                                    \
+    d = s8z24_to_z24s8(*(GLuint*)(radeon_ptr32(rrb, _x + x_off,        _y + y_off ))); \
+  } while (0)
+#endif
+/*
+    fprintf(stderr, "dval(%d, %d, %d, %d)=0x%08X\n", _x, xo, _y, yo, d);\
+   d = *(GLuint*)(radeon_ptr(rrb, _x,  _y )) & 0x00ffffff;
+*/
 #define TAG(x) radeon##x##_z24_s8
 #include "depthtmp.h"
 
@@ -235,35 +397,35 @@ do {                                                                      \
 #ifdef COMPILE_R300
 #define WRITE_STENCIL( _x, _y, d )                                     \
 do {                                                                   \
-   GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo );            \
-   GLuint tmp = *(GLuint *)(buf + offset);                             \
+   GLuint *_ptr = (GLuint*)radeon_ptr32(rrb, _x + x_off, _y + y_off);          \
+   GLuint tmp = *_ptr;                         \
    tmp &= 0xffffff00;                                                  \
    tmp |= (d) & 0xff;                                                  \
-   *(GLuint *)(buf + offset) = tmp;                                    \
+   *_ptr = tmp;                                        \
 } while (0)
 #else
 #define WRITE_STENCIL( _x, _y, d )                                     \
 do {                                                                   \
-   GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo );            \
-   GLuint tmp = *(GLuint *)(buf + offset);                             \
+   GLuint *_ptr = (GLuint*)radeon_ptr32(rrb, _x + x_off, _y + y_off);          \
+   GLuint tmp = *_ptr;                         \
    tmp &= 0x00ffffff;                                                  \
    tmp |= (((d) & 0xff) << 24);                                                \
-   *(GLuint *)(buf + offset) = tmp;                                    \
+   *_ptr = tmp;                                        \
 } while (0)
 #endif
 
 #ifdef COMPILE_R300
 #define READ_STENCIL( d, _x, _y )                                      \
 do {                                                                   \
-   GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo );            \
-   GLuint tmp = *(GLuint *)(buf + offset);                             \
+   GLuint *_ptr = (GLuint*)radeon_ptr32( rrb, _x + x_off, _y + y_off );                \
+   GLuint tmp = *_ptr;                         \
    d = tmp & 0x000000ff;                                               \
 } while (0)
 #else
 #define READ_STENCIL( d, _x, _y )                                      \
 do {                                                                   \
-   GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo );            \
-   GLuint tmp = *(GLuint *)(buf + offset);                             \
+   GLuint *_ptr = (GLuint*)radeon_ptr32( rrb, _x + x_off, _y + y_off );                \
+   GLuint tmp = *_ptr;                         \
    d = (tmp & 0xff000000) >> 24;                                       \
 } while (0)
 #endif
@@ -271,29 +433,105 @@ do {                                                                     \
 #define TAG(x) radeon##x##_z24_s8
 #include "stenciltmp.h"
 
-/* Move locking out to get reasonable span performance (10x better
- * than doing this in HW_LOCK above).  WaitForIdle() is the main
- * culprit.
- */
 
+static void map_unmap_rb(struct gl_renderbuffer *rb, int flag)
+{
+       struct radeon_renderbuffer *rrb = radeon_renderbuffer(rb);
+       int r;
+       
+       if (rrb == NULL || !rrb->bo)
+               return;
+
+       if (flag) {
+               r = radeon_bo_map(rrb->bo, 1);
+               if (r) {
+                       fprintf(stderr, "(%s) error(%d) mapping buffer.\n",
+                               __FUNCTION__, r);
+               }
+
+               radeonSetSpanFunctions(rrb);
+       } else {
+               radeon_bo_unmap(rrb->bo);
+               rb->GetRow = NULL;
+               rb->PutRow = NULL;
+       }
+}
+
+static void
+radeon_map_unmap_buffers(GLcontext *ctx, GLboolean map)
+{
+       GLuint i, j;
+
+       /* color draw buffers */
+       for (j = 0; j < ctx->DrawBuffer->_NumColorDrawBuffers; j++)
+               map_unmap_rb(ctx->DrawBuffer->_ColorDrawBuffers[j], map);
+
+       /* 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)
+                               ctx->Driver.MapTexture(ctx, tex);
+                       else
+                               ctx->Driver.UnmapTexture(ctx, tex);
+               }
+       }
+       
+       map_unmap_rb(ctx->ReadBuffer->_ColorReadBuffer, map);
+
+       /* depth buffer (Note wrapper!) */
+       if (ctx->DrawBuffer->_DepthBuffer)
+               map_unmap_rb(ctx->DrawBuffer->_DepthBuffer->Wrapped, map);
+       
+       if (ctx->DrawBuffer->_StencilBuffer)
+               map_unmap_rb(ctx->DrawBuffer->_StencilBuffer->Wrapped, map);
+
+}
 static void radeonSpanRenderStart(GLcontext * ctx)
 {
        radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-#ifdef COMPILE_R300
-       r300ContextPtr r300 = (r300ContextPtr) rmesa;
-       R300_FIREVERTICES(r300);
-#else
-       RADEON_FIREVERTICES(rmesa);
-#endif
-       LOCK_HARDWARE(rmesa);
-       radeonWaitForIdleLocked(rmesa);
+       int i;
+
+       radeon_firevertices(rmesa);
+
+       /* The locking and wait for idle should really only be needed in classic mode.
+        * In a future memory manager based implementation, this should become
+        * unnecessary due to the fact that mapping our buffers, textures, etc.
+        * should implicitly wait for any previous rendering commands that must
+        * be waited on. */
+       if (!rmesa->radeonScreen->driScreen->dri2.enabled) {
+               LOCK_HARDWARE(rmesa);
+               radeonWaitForIdleLocked(rmesa);
+       }
+       for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {
+               if (ctx->Texture.Unit[i]._ReallyEnabled)
+                       ctx->Driver.MapTexture(ctx, ctx->Texture.Unit[i]._Current);
+       }
+
+       radeon_map_unmap_buffers(ctx, 1);
+
+
+
 }
 
 static void radeonSpanRenderFinish(GLcontext * ctx)
 {
        radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+       int i;
        _swrast_flush(ctx);
-       UNLOCK_HARDWARE(rmesa);
+       if (!rmesa->radeonScreen->driScreen->dri2.enabled) {
+               UNLOCK_HARDWARE(rmesa);
+       }
+       for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {
+               if (ctx->Texture.Unit[i]._ReallyEnabled)
+                       ctx->Driver.UnmapTexture(ctx, ctx->Texture.Unit[i]._Current);
+       }
+
+       radeon_map_unmap_buffers(ctx, 0);
 }
 
 void radeonInitSpanFuncs(GLcontext * ctx)
@@ -307,20 +545,21 @@ void radeonInitSpanFuncs(GLcontext * ctx)
 /**
  * Plug in the Get/Put routines for the given driRenderbuffer.
  */
-void radeonSetSpanFunctions(driRenderbuffer * drb, const GLvisual * vis)
+static void radeonSetSpanFunctions(struct radeon_renderbuffer *rrb)
 {
-       if (drb->Base.InternalFormat == GL_RGBA) {
-               if (vis->redBits == 5 && vis->greenBits == 6
-                   && vis->blueBits == 5) {
-                       radeonInitPointers_RGB565(&drb->Base);
-               } else {
-                       radeonInitPointers_ARGB8888(&drb->Base);
-               }
-       } else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
-               radeonInitDepthPointers_z16(&drb->Base);
-       } else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
-               radeonInitDepthPointers_z24_s8(&drb->Base);
-       } else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
-               radeonInitStencilPointers_z24_s8(&drb->Base);
+       if (rrb->base._ActualFormat == GL_RGB5) {
+               radeonInitPointers_RGB565(&rrb->base);
+       } else if (rrb->base._ActualFormat == GL_RGB8) {
+               radeonInitPointers_xRGB8888(&rrb->base);
+       } else if (rrb->base._ActualFormat == GL_RGBA8) {
+               radeonInitPointers_ARGB8888(&rrb->base);
+       } else if (rrb->base._ActualFormat == GL_DEPTH_COMPONENT16) {
+               radeonInitDepthPointers_z16(&rrb->base);
+       } else if (rrb->base._ActualFormat == GL_DEPTH_COMPONENT24) {
+               radeonInitDepthPointers_z24(&rrb->base);
+       } else if (rrb->base._ActualFormat == GL_DEPTH24_STENCIL8_EXT) {
+               radeonInitDepthPointers_z24_s8(&rrb->base);
+       } else if (rrb->base._ActualFormat == GL_STENCIL_INDEX8_EXT) {
+               radeonInitStencilPointers_z24_s8(&rrb->base);
        }
 }
index 9abe0864b1736ca6cdba0eefc2e4a4dd4424a185..ea6a2e7fb4e4f3d965842f057bcef2f253bc026e 100644 (file)
@@ -42,9 +42,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #ifndef __RADEON_SPAN_H__
 #define __RADEON_SPAN_H__
 
-#include "drirenderbuffer.h"
-
 extern void radeonInitSpanFuncs(GLcontext * ctx);
-extern void radeonSetSpanFunctions(driRenderbuffer * rb, const GLvisual * vis);
 
 #endif
index b6561001e766eb550ea141229f5f71188155b375..06b8c2993688edfa266cd8a04044381d8759a184 100644 (file)
@@ -47,6 +47,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "swrast_setup/swrast_setup.h"
 
 #include "radeon_context.h"
+#include "radeon_mipmap_tree.h"
 #include "radeon_ioctl.h"
 #include "radeon_state.h"
 #include "radeon_tcl.h"
@@ -62,7 +63,7 @@ static void radeonUpdateSpecular( GLcontext *ctx );
 
 static void radeonAlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    int pp_misc = rmesa->hw.ctx.cmd[CTX_PP_MISC];
    GLubyte refByte;
 
@@ -106,7 +107,7 @@ static void radeonAlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref )
 static void radeonBlendEquationSeparate( GLcontext *ctx,
                                         GLenum modeRGB, GLenum modeA )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLuint b = rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] & ~RADEON_COMB_FCN_MASK;
    GLboolean fallback = GL_FALSE;
 
@@ -147,8 +148,8 @@ static void radeonBlendFuncSeparate( GLcontext *ctx,
                                     GLenum sfactorRGB, GLenum dfactorRGB,
                                     GLenum sfactorA, GLenum dfactorA )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-   GLuint b = rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] & 
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
+   GLuint b = rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] &
       ~(RADEON_SRC_BLEND_MASK | RADEON_DST_BLEND_MASK);
    GLboolean fallback = GL_FALSE;
 
@@ -257,7 +258,7 @@ static void radeonBlendFuncSeparate( GLcontext *ctx,
 
 static void radeonDepthFunc( GLcontext *ctx, GLenum func )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
 
    RADEON_STATECHANGE( rmesa, ctx );
    rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] &= ~RADEON_Z_TEST_MASK;
@@ -293,7 +294,7 @@ static void radeonDepthFunc( GLcontext *ctx, GLenum func )
 
 static void radeonDepthMask( GLcontext *ctx, GLboolean flag )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    RADEON_STATECHANGE( rmesa, ctx );
 
    if ( ctx->Depth.Mask ) {
@@ -305,16 +306,16 @@ static void radeonDepthMask( GLcontext *ctx, GLboolean flag )
 
 static void radeonClearDepth( GLcontext *ctx, GLclampd d )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLuint format = (rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] &
                    RADEON_DEPTH_FORMAT_MASK);
 
    switch ( format ) {
    case RADEON_DEPTH_FORMAT_16BIT_INT_Z:
-      rmesa->state.depth.clear = d * 0x0000ffff;
+      rmesa->radeon.state.depth.clear = d * 0x0000ffff;
       break;
    case RADEON_DEPTH_FORMAT_24BIT_INT_Z:
-      rmesa->state.depth.clear = d * 0x00ffffff;
+      rmesa->radeon.state.depth.clear = d * 0x00ffffff;
       break;
    }
 }
@@ -327,7 +328,7 @@ static void radeonClearDepth( GLcontext *ctx, GLclampd d )
 
 static void radeonFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    union { int i; float f; } c, d;
    GLchan col[4];
 
@@ -391,7 +392,7 @@ static void radeonFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
         rmesa->hw.fog.cmd[FOG_D] = d.i;
       }
       break;
-   case GL_FOG_COLOR: 
+   case GL_FOG_COLOR:
       RADEON_STATECHANGE( rmesa, ctx );
       UNCLAMPED_FLOAT_TO_RGB_CHAN( col, ctx->Fog.Color );
       rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] &= ~RADEON_FOG_COLOR_MASK;
@@ -406,109 +407,13 @@ static void radeonFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
    }
 }
 
-
-/* =============================================================
- * Scissoring
- */
-
-
-static GLboolean intersect_rect( drm_clip_rect_t *out,
-                                drm_clip_rect_t *a,
-                                drm_clip_rect_t *b )
-{
-   *out = *a;
-   if ( b->x1 > out->x1 ) out->x1 = b->x1;
-   if ( b->y1 > out->y1 ) out->y1 = b->y1;
-   if ( b->x2 < out->x2 ) out->x2 = b->x2;
-   if ( b->y2 < out->y2 ) out->y2 = b->y2;
-   if ( out->x1 >= out->x2 ) return GL_FALSE;
-   if ( out->y1 >= out->y2 ) return GL_FALSE;
-   return GL_TRUE;
-}
-
-
-void radeonRecalcScissorRects( radeonContextPtr rmesa )
-{
-   drm_clip_rect_t *out;
-   int i;
-
-   /* Grow cliprect store?
-    */
-   if (rmesa->state.scissor.numAllocedClipRects < rmesa->numClipRects) {
-      while (rmesa->state.scissor.numAllocedClipRects < rmesa->numClipRects) {
-        rmesa->state.scissor.numAllocedClipRects += 1; /* zero case */
-        rmesa->state.scissor.numAllocedClipRects *= 2;
-      }
-
-      if (rmesa->state.scissor.pClipRects)
-        FREE(rmesa->state.scissor.pClipRects);
-
-      rmesa->state.scissor.pClipRects = 
-        MALLOC( rmesa->state.scissor.numAllocedClipRects * 
-                sizeof(drm_clip_rect_t) );
-
-      if ( rmesa->state.scissor.pClipRects == NULL ) {
-        rmesa->state.scissor.numAllocedClipRects = 0;
-        return;
-      }
-   }
-   
-   out = rmesa->state.scissor.pClipRects;
-   rmesa->state.scissor.numClipRects = 0;
-
-   for ( i = 0 ; i < rmesa->numClipRects ;  i++ ) {
-      if ( intersect_rect( out, 
-                          &rmesa->pClipRects[i], 
-                          &rmesa->state.scissor.rect ) ) {
-        rmesa->state.scissor.numClipRects++;
-        out++;
-      }
-   }
-}
-
-
-static void radeonUpdateScissor( GLcontext *ctx )
-{
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
-   if ( rmesa->dri.drawable ) {
-      __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
-
-      int x = ctx->Scissor.X;
-      int y = dPriv->h - ctx->Scissor.Y - ctx->Scissor.Height;
-      int w = ctx->Scissor.X + ctx->Scissor.Width - 1;
-      int h = dPriv->h - ctx->Scissor.Y - 1;
-
-      rmesa->state.scissor.rect.x1 = x + dPriv->x;
-      rmesa->state.scissor.rect.y1 = y + dPriv->y;
-      rmesa->state.scissor.rect.x2 = w + dPriv->x + 1;
-      rmesa->state.scissor.rect.y2 = h + dPriv->y + 1;
-
-      radeonRecalcScissorRects( rmesa );
-   }
-}
-
-
-static void radeonScissor( GLcontext *ctx,
-                          GLint x, GLint y, GLsizei w, GLsizei h )
-{
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
-   if ( ctx->Scissor.Enabled ) {
-      RADEON_FIREVERTICES( rmesa );    /* don't pipeline cliprect changes */
-      radeonUpdateScissor( ctx );
-   }
-
-}
-
-
 /* =============================================================
  * Culling
  */
 
 static void radeonCullFace( GLcontext *ctx, GLenum unused )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLuint s = rmesa->hw.set.cmd[SET_SE_CNTL];
    GLuint t = rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL];
 
@@ -545,7 +450,7 @@ static void radeonCullFace( GLcontext *ctx, GLenum unused )
 
 static void radeonFrontFace( GLcontext *ctx, GLenum mode )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
 
    RADEON_STATECHANGE( rmesa, set );
    rmesa->hw.set.cmd[SET_SE_CNTL] &= ~RADEON_FFACE_CULL_DIR_MASK;
@@ -570,7 +475,7 @@ static void radeonFrontFace( GLcontext *ctx, GLenum mode )
  */
 static void radeonLineWidth( GLcontext *ctx, GLfloat widthf )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
 
    RADEON_STATECHANGE( rmesa, lin );
    RADEON_STATECHANGE( rmesa, set );
@@ -587,10 +492,10 @@ static void radeonLineWidth( GLcontext *ctx, GLfloat widthf )
 
 static void radeonLineStipple( GLcontext *ctx, GLint factor, GLushort pattern )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
 
    RADEON_STATECHANGE( rmesa, lin );
-   rmesa->hw.lin.cmd[LIN_RE_LINE_PATTERN] = 
+   rmesa->hw.lin.cmd[LIN_RE_LINE_PATTERN] =
       ((((GLuint)factor & 0xff) << 16) | ((GLuint)pattern));
 }
 
@@ -602,8 +507,8 @@ static void radeonColorMask( GLcontext *ctx,
                             GLboolean r, GLboolean g,
                             GLboolean b, GLboolean a )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-   GLuint mask = radeonPackColor( rmesa->radeonScreen->cpp,
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
+   GLuint mask = radeonPackColor( rmesa->radeon.radeonScreen->cpp,
                                  ctx->Color.ColorMask[RCOMP],
                                  ctx->Color.ColorMask[GCOMP],
                                  ctx->Color.ColorMask[BCOMP],
@@ -623,8 +528,9 @@ static void radeonColorMask( GLcontext *ctx,
 static void radeonPolygonOffset( GLcontext *ctx,
                                 GLfloat factor, GLfloat units )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-   float_ui32_type constant =  { units * rmesa->state.depth.scale };
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
+   const GLfloat depthScale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
+   float_ui32_type constant =  { units * depthScale };
    float_ui32_type factoru = { factor };
 
    RADEON_STATECHANGE( rmesa, zbs );
@@ -634,7 +540,7 @@ static void radeonPolygonOffset( GLcontext *ctx,
 
 static void radeonPolygonStipple( GLcontext *ctx, const GLubyte *mask )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLuint i;
    drm_radeon_stipple_t stipple;
 
@@ -646,27 +552,27 @@ static void radeonPolygonStipple( GLcontext *ctx, const GLubyte *mask )
 
    /* TODO: push this into cmd mechanism
     */
-   RADEON_FIREVERTICES( rmesa );
-   LOCK_HARDWARE( rmesa );
+   radeon_firevertices(&rmesa->radeon);
+   LOCK_HARDWARE( &rmesa->radeon );
 
    /* FIXME: Use window x,y offsets into stipple RAM.
     */
    stipple.mask = rmesa->state.stipple.mask;
-   drmCommandWrite( rmesa->dri.fd, DRM_RADEON_STIPPLE, 
+   drmCommandWrite( rmesa->radeon.dri.fd, DRM_RADEON_STIPPLE,
                     &stipple, sizeof(drm_radeon_stipple_t) );
-   UNLOCK_HARDWARE( rmesa );
+   UNLOCK_HARDWARE( &rmesa->radeon );
 }
 
 static void radeonPolygonMode( GLcontext *ctx, GLenum face, GLenum mode )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLboolean flag = (ctx->_TriangleCaps & DD_TRI_UNFILLED) != 0;
 
    /* Can't generally do unfilled via tcl, but some good special
-    * cases work. 
+    * cases work.
     */
    TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_UNFILLED, flag);
-   if (rmesa->TclFallback) {
+   if (rmesa->radeon.TclFallback) {
       radeonChooseRenderState( ctx );
       radeonChooseVertexState( ctx );
    }
@@ -686,7 +592,7 @@ static void radeonPolygonMode( GLcontext *ctx, GLenum face, GLenum mode )
  */
 static void radeonUpdateSpecular( GLcontext *ctx )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    uint32_t p = rmesa->hw.ctx.cmd[CTX_PP_CNTL];
    GLuint flag = 0;
 
@@ -711,7 +617,7 @@ static void radeonUpdateSpecular( GLcontext *ctx )
       rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE;
       rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_LIGHTING_ENABLE;
       p |=  RADEON_SPECULAR_ENABLE;
-      rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &= 
+      rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &=
         ~RADEON_DIFFUSE_SPECULAR_COMBINE;
    }
    else if (ctx->Light.Enabled) {
@@ -741,7 +647,7 @@ static void radeonUpdateSpecular( GLcontext *ctx )
            RADEON_TCL_COMPUTE_SPECULAR) != 0;
       }
    }
+
    TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_FOGCOORDSPEC, flag);
 
    if (NEED_SECONDARY_COLOR(ctx)) {
@@ -757,7 +663,7 @@ static void radeonUpdateSpecular( GLcontext *ctx )
 
    /* Update vertex/render formats
     */
-   if (rmesa->TclFallback) { 
+   if (rmesa->radeon.TclFallback) {
       radeonChooseRenderState( ctx );
       radeonChooseVertexState( ctx );
    }
@@ -769,12 +675,12 @@ static void radeonUpdateSpecular( GLcontext *ctx )
  */
 
 
-/* Update on colormaterial, material emmissive/ambient, 
+/* Update on colormaterial, material emmissive/ambient,
  * lightmodel.globalambient
  */
 static void update_global_ambient( GLcontext *ctx )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    float *fcmd = (float *)RADEON_DB_STATE( glt );
 
    /* Need to do more if both emmissive & ambient are PREMULT:
@@ -782,23 +688,23 @@ static void update_global_ambient( GLcontext *ctx )
     */
    if ((rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &
        ((3 << RADEON_EMISSIVE_SOURCE_SHIFT) |
-       (3 << RADEON_AMBIENT_SOURCE_SHIFT))) == 0) 
+       (3 << RADEON_AMBIENT_SOURCE_SHIFT))) == 0)
    {
-      COPY_3V( &fcmd[GLT_RED], 
+      COPY_3V( &fcmd[GLT_RED],
               ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_EMISSION]);
       ACC_SCALE_3V( &fcmd[GLT_RED],
                   ctx->Light.Model.Ambient,
                   ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_AMBIENT]);
-   } 
+   }
    else
    {
       COPY_3V( &fcmd[GLT_RED], ctx->Light.Model.Ambient );
    }
-   
+
    RADEON_DB_STATECHANGE(rmesa, &rmesa->hw.glt);
 }
 
-/* Update on change to 
+/* Update on change to
  *    - light[p].colors
  *    - light[p].enabled
  */
@@ -809,13 +715,13 @@ static void update_light_colors( GLcontext *ctx, GLuint p )
 /*     fprintf(stderr, "%s\n", __FUNCTION__); */
 
    if (l->Enabled) {
-      radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+      r100ContextPtr rmesa = R100_CONTEXT(ctx);
       float *fcmd = (float *)RADEON_DB_STATE( lit[p] );
 
-      COPY_4V( &fcmd[LIT_AMBIENT_RED], l->Ambient );    
+      COPY_4V( &fcmd[LIT_AMBIENT_RED], l->Ambient );
       COPY_4V( &fcmd[LIT_DIFFUSE_RED], l->Diffuse );
       COPY_4V( &fcmd[LIT_SPECULAR_RED], l->Specular );
-      
+
       RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.lit[p] );
    }
 }
@@ -829,7 +735,7 @@ static void check_twoside_fallback( GLcontext *ctx )
 
    if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) {
       if (ctx->Light.ColorMaterialEnabled &&
-         (ctx->Light.ColorMaterialBitmask & BACK_MATERIAL_BITS) != 
+         (ctx->Light.ColorMaterialBitmask & BACK_MATERIAL_BITS) !=
          ((ctx->Light.ColorMaterialBitmask & FRONT_MATERIAL_BITS)<<1))
         fallback = GL_TRUE;
       else {
@@ -837,7 +743,7 @@ static void check_twoside_fallback( GLcontext *ctx )
            if (memcmp( ctx->Light.Material.Attrib[i],
                        ctx->Light.Material.Attrib[i+1],
                        sizeof(GLfloat)*4) != 0) {
-              fallback = GL_TRUE;  
+              fallback = GL_TRUE;
               break;
            }
       }
@@ -849,14 +755,14 @@ static void check_twoside_fallback( GLcontext *ctx )
 
 static void radeonColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
 {
-      radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+      r100ContextPtr rmesa = R100_CONTEXT(ctx);
       GLuint light_model_ctl1 = rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL];
 
       light_model_ctl1 &= ~((3 << RADEON_EMISSIVE_SOURCE_SHIFT) |
                           (3 << RADEON_AMBIENT_SOURCE_SHIFT) |
                           (3 << RADEON_DIFFUSE_SOURCE_SHIFT) |
-                          (3 << RADEON_SPECULAR_SOURCE_SHIFT)); 
-   
+                          (3 << RADEON_SPECULAR_SOURCE_SHIFT));
+
    if (ctx->Light.ColorMaterialEnabled) {
       GLuint mask = ctx->Light.ColorMaterialBitmask;
 
@@ -877,7 +783,7 @@ static void radeonColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
         light_model_ctl1 |= (RADEON_LM_SOURCE_STATE_MULT <<
                             RADEON_AMBIENT_SOURCE_SHIFT);
       }
-        
+
       if (mask & MAT_BIT_FRONT_DIFFUSE) {
         light_model_ctl1 |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE <<
                             RADEON_DIFFUSE_SOURCE_SHIFT);
@@ -886,7 +792,7 @@ static void radeonColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
         light_model_ctl1 |= (RADEON_LM_SOURCE_STATE_MULT <<
                             RADEON_DIFFUSE_SOURCE_SHIFT);
       }
-   
+
       if (mask & MAT_BIT_FRONT_SPECULAR) {
         light_model_ctl1 |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE <<
                             RADEON_SPECULAR_SOURCE_SHIFT);
@@ -904,27 +810,27 @@ static void radeonColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
                   (RADEON_LM_SOURCE_STATE_MULT << RADEON_DIFFUSE_SOURCE_SHIFT) |
                   (RADEON_LM_SOURCE_STATE_MULT << RADEON_SPECULAR_SOURCE_SHIFT);
    }
-   
+
       if (light_model_ctl1 != rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL]) {
         RADEON_STATECHANGE( rmesa, tcl );
-        rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] = light_model_ctl1;      
+        rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] = light_model_ctl1;
    }
 }
 
 void radeonUpdateMaterial( GLcontext *ctx )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
    GLfloat *fcmd = (GLfloat *)RADEON_DB_STATE( mtl );
    GLuint mask = ~0;
-   
+
    if (ctx->Light.ColorMaterialEnabled)
       mask &= ~ctx->Light.ColorMaterialBitmask;
 
    if (RADEON_DEBUG & DEBUG_STATE)
       fprintf(stderr, "%s\n", __FUNCTION__);
 
-      
+
    if (mask & MAT_BIT_FRONT_EMISSION) {
       fcmd[MTL_EMMISSIVE_RED]   = mat[MAT_ATTRIB_FRONT_EMISSION][0];
       fcmd[MTL_EMMISSIVE_GREEN] = mat[MAT_ATTRIB_FRONT_EMISSION][1];
@@ -974,11 +880,11 @@ void radeonUpdateMaterial( GLcontext *ctx )
  *
  * which are calculated in light.c and are correct for the current
  * lighting space (model or eye), hence dependencies on _NEW_MODELVIEW
- * and _MESA_NEW_NEED_EYE_COORDS.  
+ * and _MESA_NEW_NEED_EYE_COORDS.
  */
 static void update_light( GLcontext *ctx )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
 
    /* Have to check these, or have an automatic shortcircuit mechanism
     * to remove noop statechanges. (Or just do a better job on the
@@ -991,12 +897,12 @@ static void update_light( GLcontext *ctx )
         tmp &= ~RADEON_LIGHT_IN_MODELSPACE;
       else
         tmp |= RADEON_LIGHT_IN_MODELSPACE;
-      
+
 
       /* Leave this test disabled: (unexplained q3 lockup) (even with
          new packets)
       */
-      if (tmp != rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL]) 
+      if (tmp != rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL])
       {
         RADEON_STATECHANGE( rmesa, tcl );
         rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] = tmp;
@@ -1020,10 +926,10 @@ static void update_light( GLcontext *ctx )
         if (ctx->Light.Light[p].Enabled) {
            struct gl_light *l = &ctx->Light.Light[p];
            GLfloat *fcmd = (GLfloat *)RADEON_DB_STATE( lit[p] );
-           
+
            if (l->EyePosition[3] == 0.0) {
-              COPY_3FV( &fcmd[LIT_POSITION_X], l->_VP_inf_norm ); 
-              COPY_3FV( &fcmd[LIT_DIRECTION_X], l->_h_inf_norm ); 
+              COPY_3FV( &fcmd[LIT_POSITION_X], l->_VP_inf_norm );
+              COPY_3FV( &fcmd[LIT_DIRECTION_X], l->_h_inf_norm );
               fcmd[LIT_POSITION_W] = 0;
               fcmd[LIT_DIRECTION_W] = 0;
            } else {
@@ -1043,30 +949,30 @@ static void update_light( GLcontext *ctx )
 static void radeonLightfv( GLcontext *ctx, GLenum light,
                           GLenum pname, const GLfloat *params )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLint p = light - GL_LIGHT0;
    struct gl_light *l = &ctx->Light.Light[p];
    GLfloat *fcmd = (GLfloat *)rmesa->hw.lit[p].cmd;
-   
+
 
    switch (pname) {
-   case GL_AMBIENT:            
+   case GL_AMBIENT:
    case GL_DIFFUSE:
    case GL_SPECULAR:
       update_light_colors( ctx, p );
       break;
 
-   case GL_SPOT_DIRECTION: 
-      /* picked up in update_light */  
+   case GL_SPOT_DIRECTION:
+      /* picked up in update_light */
       break;
 
    case GL_POSITION: {
-      /* positions picked up in update_light, but can do flag here */  
+      /* positions picked up in update_light, but can do flag here */
       GLuint flag;
       GLuint idx = TCL_PER_LIGHT_CTL_0 + p/2;
 
       /* FIXME: Set RANGE_ATTEN only when needed */
-      if (p&1) 
+      if (p&1)
         flag = RADEON_LIGHT_1_IS_LOCAL;
       else
         flag = RADEON_LIGHT_0_IS_LOCAL;
@@ -1158,16 +1064,16 @@ static void radeonLightfv( GLcontext *ctx, GLenum light,
    }
 }
 
-                 
+
 
 
 static void radeonLightModelfv( GLcontext *ctx, GLenum pname,
                                const GLfloat *param )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
 
    switch (pname) {
-      case GL_LIGHT_MODEL_AMBIENT: 
+      case GL_LIGHT_MODEL_AMBIENT:
         update_global_ambient( ctx );
         break;
 
@@ -1188,7 +1094,7 @@ static void radeonLightModelfv( GLcontext *ctx, GLenum pname,
 
         check_twoside_fallback( ctx );
 
-        if (rmesa->TclFallback) {
+        if (rmesa->radeon.TclFallback) {
            radeonChooseRenderState( ctx );
            radeonChooseVertexState( ctx );
         }
@@ -1205,7 +1111,7 @@ static void radeonLightModelfv( GLcontext *ctx, GLenum pname,
 
 static void radeonShadeModel( GLcontext *ctx, GLenum mode )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLuint s = rmesa->hw.set.cmd[SET_SE_CNTL];
 
    s &= ~(RADEON_DIFFUSE_SHADE_MASK |
@@ -1244,7 +1150,7 @@ static void radeonShadeModel( GLcontext *ctx, GLenum mode )
 static void radeonClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *eq )
 {
    GLint p = (GLint) plane - (GLint) GL_CLIP_PLANE0;
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLint *ip = (GLint *)ctx->Transform._ClipUserPlane[p];
 
    RADEON_STATECHANGE( rmesa, ucp[p] );
@@ -1256,7 +1162,7 @@ static void radeonClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *eq )
 
 static void radeonUpdateClipPlanes( GLcontext *ctx )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLuint p;
 
    for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
@@ -1281,7 +1187,7 @@ static void
 radeonStencilFuncSeparate( GLcontext *ctx, GLenum face, GLenum func,
                            GLint ref, GLuint mask )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLuint refmask = (((ctx->Stencil.Ref[0] & 0xff) << RADEON_STENCIL_REF_SHIFT) |
                     ((ctx->Stencil.ValueMask[0] & 0xff) << RADEON_STENCIL_MASK_SHIFT));
 
@@ -1325,7 +1231,7 @@ radeonStencilFuncSeparate( GLcontext *ctx, GLenum face, GLenum func,
 static void
 radeonStencilMaskSeparate( GLcontext *ctx, GLenum face, GLuint mask )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
 
    RADEON_STATECHANGE( rmesa, msk );
    rmesa->hw.msk.cmd[MSK_RB3D_STENCILREFMASK] &= ~RADEON_STENCIL_WRITE_MASK;
@@ -1336,20 +1242,20 @@ radeonStencilMaskSeparate( GLcontext *ctx, GLenum face, GLuint mask )
 static void radeonStencilOpSeparate( GLcontext *ctx, GLenum face, GLenum fail,
                                      GLenum zfail, GLenum zpass )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
 
    /* radeon 7200 have stencil bug, DEC and INC_WRAP will actually both do DEC_WRAP,
       and DEC_WRAP (and INVERT) will do INVERT. No way to get correct INC_WRAP and DEC,
       but DEC_WRAP can be fixed by using DEC and INC_WRAP at least use INC. */
-   
+
    GLuint tempRADEON_STENCIL_FAIL_DEC_WRAP;
    GLuint tempRADEON_STENCIL_FAIL_INC_WRAP;
    GLuint tempRADEON_STENCIL_ZFAIL_DEC_WRAP;
    GLuint tempRADEON_STENCIL_ZFAIL_INC_WRAP;
    GLuint tempRADEON_STENCIL_ZPASS_DEC_WRAP;
    GLuint tempRADEON_STENCIL_ZPASS_INC_WRAP;
-   
-   if (rmesa->radeonScreen->chip_flags & RADEON_CHIPSET_BROKEN_STENCIL) {
+
+   if (rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_BROKEN_STENCIL) {
       tempRADEON_STENCIL_FAIL_DEC_WRAP = RADEON_STENCIL_FAIL_DEC;
       tempRADEON_STENCIL_FAIL_INC_WRAP = RADEON_STENCIL_FAIL_INC;
       tempRADEON_STENCIL_ZFAIL_DEC_WRAP = RADEON_STENCIL_ZFAIL_DEC;
@@ -1365,7 +1271,7 @@ static void radeonStencilOpSeparate( GLcontext *ctx, GLenum face, GLenum fail,
       tempRADEON_STENCIL_ZPASS_DEC_WRAP = RADEON_STENCIL_ZPASS_DEC_WRAP;
       tempRADEON_STENCIL_ZPASS_INC_WRAP = RADEON_STENCIL_ZPASS_INC_WRAP;
    }
-   
+
    RADEON_STATECHANGE( rmesa, ctx );
    rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] &= ~(RADEON_STENCIL_FAIL_MASK |
                                               RADEON_STENCIL_ZFAIL_MASK |
@@ -1455,9 +1361,9 @@ static void radeonStencilOpSeparate( GLcontext *ctx, GLenum face, GLenum fail,
 
 static void radeonClearStencil( GLcontext *ctx, GLint s )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
 
-   rmesa->state.stencil.clear = 
+   rmesa->radeon.state.stencil.clear =
       ((GLuint) (ctx->Stencil.Clear & 0xff) |
        (0xff << RADEON_STENCIL_MASK_SHIFT) |
        ((ctx->Stencil.WriteMask[0] & 0xff) << RADEON_STENCIL_WRITEMASK_SHIFT));
@@ -1481,20 +1387,30 @@ static void radeonClearStencil( GLcontext *ctx, GLint s )
  */
 void radeonUpdateWindow( GLcontext *ctx )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
-   GLfloat xoffset = (GLfloat)dPriv->x;
-   GLfloat yoffset = (GLfloat)dPriv->y + dPriv->h;
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
+   __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
+   GLfloat xoffset = dPriv ? (GLfloat) dPriv->x : 0;
+   GLfloat yoffset = dPriv ? (GLfloat) dPriv->y + dPriv->h : 0;
    const GLfloat *v = ctx->Viewport._WindowMap.m;
+   const GLboolean render_to_fbo = (ctx->DrawBuffer ? (ctx->DrawBuffer->Name != 0) : 0);
+   const GLfloat depthScale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
+   GLfloat y_scale, y_bias;
+
+   if (render_to_fbo) {
+      y_scale = 1.0;
+      y_bias = 0;
+   } else {
+      y_scale = -1.0;
+      y_bias = yoffset;
+   }
 
    float_ui32_type sx = { v[MAT_SX] };
    float_ui32_type tx = { v[MAT_TX] + xoffset + SUBPIXEL_X };
-   float_ui32_type sy = { - v[MAT_SY] };
-   float_ui32_type ty = { (- v[MAT_TY]) + yoffset + SUBPIXEL_Y };
-   float_ui32_type sz = { v[MAT_SZ] * rmesa->state.depth.scale };
-   float_ui32_type tz = { v[MAT_TZ] * rmesa->state.depth.scale };
+   float_ui32_type sy = { v[MAT_SY] * y_scale };
+   float_ui32_type ty = { (v[MAT_TY] * y_scale) + y_bias + SUBPIXEL_Y };
+   float_ui32_type sz = { v[MAT_SZ] * depthScale };
+   float_ui32_type tz = { v[MAT_TZ] * depthScale };
 
-   RADEON_FIREVERTICES( rmesa );
    RADEON_STATECHANGE( rmesa, vpt );
 
    rmesa->hw.vpt.cmd[VPT_SE_VPORT_XSCALE]  = sx.ui32;
@@ -1514,6 +1430,8 @@ static void radeonViewport( GLcontext *ctx, GLint x, GLint y,
     * values, or keep the originals hanging around.
     */
    radeonUpdateWindow( ctx );
+
+   radeon_viewport(ctx, x, y, width, height);
 }
 
 static void radeonDepthRange( GLcontext *ctx, GLclampd nearval,
@@ -1524,8 +1442,8 @@ static void radeonDepthRange( GLcontext *ctx, GLclampd nearval,
 
 void radeonUpdateViewportOffset( GLcontext *ctx )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
+   __DRIdrawablePrivate *dPriv = radeon_get_drawable(&rmesa->radeon);
    GLfloat xoffset = (GLfloat)dPriv->x;
    GLfloat yoffset = (GLfloat)dPriv->y + dPriv->h;
    const GLfloat *v = ctx->Viewport._WindowMap.m;
@@ -1555,8 +1473,8 @@ void radeonUpdateViewportOffset( GLcontext *ctx )
                 RADEON_STIPPLE_Y_OFFSET_MASK);
 
          /* add magic offsets, then invert */
-         stx = 31 - ((rmesa->dri.drawable->x - 1) & RADEON_STIPPLE_COORD_MASK);
-         sty = 31 - ((rmesa->dri.drawable->y + rmesa->dri.drawable->h - 1)
+         stx = 31 - ((dPriv->x - 1) & RADEON_STIPPLE_COORD_MASK);
+         sty = 31 - ((dPriv->y + dPriv->h - 1)
                      & RADEON_STIPPLE_COORD_MASK);
 
          m |= ((stx << RADEON_STIPPLE_X_OFFSET_SHIFT) |
@@ -1580,20 +1498,20 @@ void radeonUpdateViewportOffset( GLcontext *ctx )
 
 static void radeonClearColor( GLcontext *ctx, const GLfloat color[4] )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLubyte c[4];
    CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]);
    CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]);
    CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]);
    CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]);
-   rmesa->state.color.clear = radeonPackColor( rmesa->radeonScreen->cpp,
+   rmesa->radeon.state.color.clear = radeonPackColor( rmesa->radeon.radeonScreen->cpp,
                                               c[0], c[1], c[2], c[3] );
 }
 
 
 static void radeonRenderMode( GLcontext *ctx, GLenum mode )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    FALLBACK( rmesa, RADEON_FALLBACK_RENDER_MODE, (mode != GL_RENDER) );
 }
 
@@ -1619,7 +1537,7 @@ static GLuint radeon_rop_tab[] = {
 
 static void radeonLogicOpCode( GLcontext *ctx, GLenum opcode )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLuint rop = (GLuint)opcode - GL_CLEAR;
 
    ASSERT( rop < 16 );
@@ -1628,105 +1546,13 @@ static void radeonLogicOpCode( GLcontext *ctx, GLenum opcode )
    rmesa->hw.msk.cmd[MSK_RB3D_ROPCNTL] = radeon_rop_tab[rop];
 }
 
-
-/**
- * Set up the cliprects for either front or back-buffer drawing.
- */
-void radeonSetCliprects( radeonContextPtr rmesa )
-{
-   __DRIdrawablePrivate *const drawable = rmesa->dri.drawable;
-   __DRIdrawablePrivate *const readable = rmesa->dri.readable;
-   GLframebuffer *const draw_fb = (GLframebuffer*) drawable->driverPrivate;
-   GLframebuffer *const read_fb = (GLframebuffer*) readable->driverPrivate;
-
-   if (draw_fb->_ColorDrawBufferIndexes[0] == BUFFER_BACK_LEFT) {
-      /* Can't ignore 2d windows if we are page flipping.
-       */
-      if ( drawable->numBackClipRects == 0 || rmesa->doPageFlip ) {
-        rmesa->numClipRects = drawable->numClipRects;
-        rmesa->pClipRects = drawable->pClipRects;
-      }
-      else {
-        rmesa->numClipRects = drawable->numBackClipRects;
-        rmesa->pClipRects = drawable->pBackClipRects;
-      }
-   }
-   else {
-      /* front buffer (or none, or multiple buffers */
-      rmesa->numClipRects = drawable->numClipRects;
-      rmesa->pClipRects = drawable->pClipRects;
-   }
-
-   if ((draw_fb->Width != drawable->w) || (draw_fb->Height != drawable->h)) {
-      _mesa_resize_framebuffer(rmesa->glCtx, draw_fb,
-                              drawable->w, drawable->h);
-      draw_fb->Initialized = GL_TRUE;
-   }
-
-   if (drawable != readable) {
-      if ((read_fb->Width != readable->w) || (read_fb->Height != readable->h)) {
-        _mesa_resize_framebuffer(rmesa->glCtx, read_fb,
-                                 readable->w, readable->h);
-        read_fb->Initialized = GL_TRUE;
-      }
-   }
-
-   if (rmesa->state.scissor.enabled)
-      radeonRecalcScissorRects( rmesa );
-
-   rmesa->lastStamp = drawable->lastStamp;
-}
-
-
-/**
- * Called via glDrawBuffer.
- */
-static void radeonDrawBuffer( GLcontext *ctx, GLenum mode )
-{
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
-   if (RADEON_DEBUG & DEBUG_DRI)
-      fprintf(stderr, "%s %s\n", __FUNCTION__,
-             _mesa_lookup_enum_by_nr( mode ));
-
-   RADEON_FIREVERTICES(rmesa); /* don't pipeline cliprect changes */
-
-   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:
-      FALLBACK( rmesa, RADEON_FALLBACK_DRAW_BUFFER, GL_TRUE );
-      return;
-   }
-
-   radeonSetCliprects( rmesa );
-
-   /* We'll set the drawing engine's offset/pitch parameters later
-    * when we update other state.
-    */
-}
-
-static void radeonReadBuffer( GLcontext *ctx, GLenum mode )
-{
-   /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
-}
-
-
 /* =============================================================
  * State enable/disable
  */
 
 static void radeonEnable( GLcontext *ctx, GLenum cap, GLboolean state )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLuint p, flag;
 
    if ( RADEON_DEBUG & DEBUG_STATE )
@@ -1787,7 +1613,7 @@ static void radeonEnable( GLcontext *ctx, GLenum cap, GLboolean state )
    case GL_CLIP_PLANE2:
    case GL_CLIP_PLANE3:
    case GL_CLIP_PLANE4:
-   case GL_CLIP_PLANE5: 
+   case GL_CLIP_PLANE5:
       p = cap-GL_CLIP_PLANE0;
       RADEON_STATECHANGE( rmesa, tcl );
       if (state) {
@@ -1821,10 +1647,10 @@ static void radeonEnable( GLcontext *ctx, GLenum cap, GLboolean state )
       RADEON_STATECHANGE(rmesa, ctx );
       if ( state ) {
         rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |=  RADEON_DITHER_ENABLE;
-        rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~rmesa->state.color.roundEnable;
+        rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~rmesa->radeon.state.color.roundEnable;
       } else {
         rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_DITHER_ENABLE;
-        rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |=  rmesa->state.color.roundEnable;
+        rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |=  rmesa->radeon.state.color.roundEnable;
       }
       break;
 
@@ -1852,13 +1678,13 @@ static void radeonEnable( GLcontext *ctx, GLenum cap, GLboolean state )
    case GL_LIGHT7:
       RADEON_STATECHANGE(rmesa, tcl);
       p = cap - GL_LIGHT0;
-      if (p&1) 
+      if (p&1)
         flag = (RADEON_LIGHT_1_ENABLE |
-                RADEON_LIGHT_1_ENABLE_AMBIENT | 
+                RADEON_LIGHT_1_ENABLE_AMBIENT |
                 RADEON_LIGHT_1_ENABLE_SPECULAR);
       else
         flag = (RADEON_LIGHT_0_ENABLE |
-                RADEON_LIGHT_0_ENABLE_AMBIENT | 
+                RADEON_LIGHT_0_ENABLE_AMBIENT |
                 RADEON_LIGHT_0_ENABLE_SPECULAR);
 
       if (state)
@@ -1866,7 +1692,7 @@ static void radeonEnable( GLcontext *ctx, GLenum cap, GLboolean state )
       else
         rmesa->hw.tcl.cmd[p/2 + TCL_PER_LIGHT_CTL_0] &= ~flag;
 
-      /* 
+      /*
        */
       update_light_colors( ctx, p );
       break;
@@ -1904,7 +1730,7 @@ static void radeonEnable( GLcontext *ctx, GLenum cap, GLboolean state )
         rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ROP_ENABLE;
       }
       break;
-      
+
    case GL_NORMALIZE:
       RADEON_STATECHANGE( rmesa, tcl );
       if ( state ) {
@@ -1971,21 +1797,30 @@ static void radeonEnable( GLcontext *ctx, GLenum cap, GLboolean state )
    }
 
    case GL_SCISSOR_TEST:
-      RADEON_FIREVERTICES( rmesa );
-      rmesa->state.scissor.enabled = state;
+      radeon_firevertices(&rmesa->radeon);
+      rmesa->radeon.state.scissor.enabled = state;
       radeonUpdateScissor( ctx );
       break;
 
    case GL_STENCIL_TEST:
-      if ( rmesa->state.stencil.hwBuffer ) {
-        RADEON_STATECHANGE( rmesa, ctx );
-        if ( state ) {
-           rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |=  RADEON_STENCIL_ENABLE;
+      {
+        GLboolean hw_stencil = GL_FALSE;
+        if (ctx->DrawBuffer) {
+           struct radeon_renderbuffer *rrbStencil
+              = radeon_get_renderbuffer(ctx->DrawBuffer, BUFFER_STENCIL);
+           hw_stencil = (rrbStencil && rrbStencil->bo);
+        }
+
+        if (hw_stencil) {
+           RADEON_STATECHANGE( rmesa, ctx );
+           if ( state ) {
+              rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |=  RADEON_STENCIL_ENABLE;
+           } else {
+              rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_STENCIL_ENABLE;
+           }
         } else {
-           rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_STENCIL_ENABLE;
+           FALLBACK( rmesa, RADEON_FALLBACK_STENCIL, state );
         }
-      } else {
-        FALLBACK( rmesa, RADEON_FALLBACK_STENCIL, state );
       }
       break;
 
@@ -1995,7 +1830,7 @@ static void radeonEnable( GLcontext *ctx, GLenum cap, GLboolean state )
    case GL_TEXTURE_GEN_T:
       /* Picked up in radeonUpdateTextureState.
        */
-      rmesa->recheck_texgen[ctx->Texture.CurrentUnit] = GL_TRUE; 
+      rmesa->recheck_texgen[ctx->Texture.CurrentUnit] = GL_TRUE;
       break;
 
    case GL_COLOR_SUM_EXT:
@@ -2010,7 +1845,7 @@ static void radeonEnable( GLcontext *ctx, GLenum cap, GLboolean state )
 
 static void radeonLightingSpaceChange( GLcontext *ctx )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLboolean tmp;
    RADEON_STATECHANGE( rmesa, tcl );
 
@@ -2029,7 +1864,7 @@ static void radeonLightingSpaceChange( GLcontext *ctx )
       rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &= ~RADEON_RESCALE_NORMALS;
    }
 
-   if (RADEON_DEBUG & DEBUG_STATE) 
+   if (RADEON_DEBUG & DEBUG_STATE)
       fprintf(stderr, "%s %d AFTER %x\n", __FUNCTION__, ctx->_NeedEyeCoords,
              rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL]);
 }
@@ -2039,7 +1874,7 @@ static void radeonLightingSpaceChange( GLcontext *ctx )
  */
 
 
-void radeonUploadTexMatrix( radeonContextPtr rmesa,
+void radeonUploadTexMatrix( r100ContextPtr rmesa,
                            int unit, GLboolean swapcols )
 {
 /* Here's how this works: on r100, only 3 tex coords can be submitted, so the
@@ -2065,7 +1900,7 @@ void radeonUploadTexMatrix( radeonContextPtr rmesa,
    int idx = TEXMAT_0 + unit;
    float *dest = ((float *)RADEON_DB_STATE( mat[idx] )) + MAT_ELT_0;
    int i;
-   struct gl_texture_unit tUnit = rmesa->glCtx->Texture.Unit[unit];
+   struct gl_texture_unit tUnit = rmesa->radeon.glCtx->Texture.Unit[unit];
    GLfloat *src = rmesa->tmpmat[unit].m;
 
    rmesa->TexMatColSwap &= ~(1 << unit);
@@ -2119,7 +1954,7 @@ void radeonUploadTexMatrix( radeonContextPtr rmesa,
 }
 
 
-static void upload_matrix( radeonContextPtr rmesa, GLfloat *src, int idx )
+static void upload_matrix( r100ContextPtr rmesa, GLfloat *src, int idx )
 {
    float *dest = ((float *)RADEON_DB_STATE( mat[idx] ))+MAT_ELT_0;
    int i;
@@ -2135,7 +1970,7 @@ static void upload_matrix( radeonContextPtr rmesa, GLfloat *src, int idx )
    RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.mat[idx] );
 }
 
-static void upload_matrix_t( radeonContextPtr rmesa, GLfloat *src, int idx )
+static void upload_matrix_t( r100ContextPtr rmesa, GLfloat *src, int idx )
 {
    float *dest = ((float *)RADEON_DB_STATE( mat[idx] ))+MAT_ELT_0;
    memcpy(dest, src, 16*sizeof(float));
@@ -2145,7 +1980,7 @@ static void upload_matrix_t( radeonContextPtr rmesa, GLfloat *src, int idx )
 
 static void update_texturematrix( GLcontext *ctx )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+   r100ContextPtr rmesa = R100_CONTEXT( ctx );
    GLuint tpc = rmesa->hw.tcl.cmd[TCL_TEXTURE_PROC_CTL];
    GLuint vs = rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL];
    int unit;
@@ -2209,64 +2044,75 @@ static void update_texturematrix( GLcontext *ctx )
    }
 }
 
-
-/**
- * Tell the card where to render (offset, pitch).
- * Effected by glDrawBuffer, etc
- */
-void
-radeonUpdateDrawBuffer(GLcontext *ctx)
+static GLboolean r100ValidateBuffers(GLcontext *ctx)
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-   struct gl_framebuffer *fb = ctx->DrawBuffer;
-   driRenderbuffer *drb;
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
+   struct radeon_renderbuffer *rrb;
+   int i;
 
-   if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
-      /* draw to front */
-      drb = (driRenderbuffer *) fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
-   }
-   else if (fb->_ColorDrawBufferIndexes[0] == BUFFER_BACK_LEFT) {
-      /* draw to back */
-      drb = (driRenderbuffer *) fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
+   radeon_validate_reset_bos(&rmesa->radeon);
+
+   rrb = radeon_get_colorbuffer(&rmesa->radeon);
+   /* color buffer */
+   if (rrb && rrb->bo) {
+     radeon_validate_bo(&rmesa->radeon, rrb->bo,
+                       0, RADEON_GEM_DOMAIN_VRAM);
    }
-   else {
-      /* drawing to multiple buffers, or none */
-      return;
+
+   /* depth buffer */
+   rrb = radeon_get_depthbuffer(&rmesa->radeon);
+   /* color buffer */
+   if (rrb && rrb->bo) {
+     radeon_validate_bo(&rmesa->radeon, rrb->bo,
+                       0, RADEON_GEM_DOMAIN_VRAM);
    }
 
-   assert(drb);
-   assert(drb->flippedPitch);
+   for (i = 0; i < ctx->Const.MaxTextureImageUnits; ++i) {
+      radeonTexObj *t;
 
-   RADEON_STATECHANGE( rmesa, ctx );
+      if (!ctx->Texture.Unit[i]._ReallyEnabled)
+        continue;
 
-   /* Note: we used the (possibly) page-flipped values */
-   rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET]
-     = ((drb->flippedOffset + rmesa->radeonScreen->fbLocation)
-       & RADEON_COLOROFFSET_MASK);
-   rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = drb->flippedPitch;
-   if (rmesa->sarea->tiling_enabled) {
-      rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= RADEON_COLOR_TILE_ENABLE;
+      t = radeon_tex_obj(ctx->Texture.Unit[i]._Current);
+      if (t->image_override && t->bo)
+       radeon_validate_bo(&rmesa->radeon, t->bo,
+                          RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
+      else if (t->mt->bo)
+       radeon_validate_bo(&rmesa->radeon, t->mt->bo,
+                          RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
    }
-}
 
+   if (rmesa->radeon.dma.current)
+       radeon_validate_bo(&rmesa->radeon, rmesa->radeon.dma.current,
+                         RADEON_GEM_DOMAIN_GTT, 0);
+
+   return radeon_revalidate_bos(ctx);
+}
 
-void radeonValidateState( GLcontext *ctx )
+GLboolean radeonValidateState( GLcontext *ctx )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-   GLuint new_state = rmesa->NewGLState;
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
+   GLuint new_state = rmesa->radeon.NewGLState;
 
-   if (new_state & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL)) {
-     radeonUpdateDrawBuffer(ctx);
+   if (new_state & _NEW_BUFFERS) {
+     _mesa_update_framebuffer(ctx);
+     /* this updates the DrawBuffer's Width/Height if it's a FBO */
+     _mesa_update_draw_buffer_bounds(ctx);
+     RADEON_STATECHANGE(rmesa, ctx);
    }
 
    if (new_state & _NEW_TEXTURE) {
       radeonUpdateTextureState( ctx );
-      new_state |= rmesa->NewGLState; /* may add TEXTURE_MATRIX */
+      new_state |= rmesa->radeon.NewGLState; /* may add TEXTURE_MATRIX */
    }
 
+   /* we need to do a space check here */
+   if (!r100ValidateBuffers(ctx))
+     return GL_FALSE;
+
    /* Need an event driven matrix update?
     */
-   if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION)) 
+   if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
       upload_matrix( rmesa, ctx->_ModelProjectMatrix.m, MODEL_PROJ );
 
    /* Need these for lighting (shouldn't upload otherwise)
@@ -2290,12 +2136,14 @@ void radeonValidateState( GLcontext *ctx )
    /* emit all active clip planes if projection matrix changes.
     */
    if (new_state & (_NEW_PROJECTION)) {
-      if (ctx->Transform.ClipPlanesEnabled) 
+      if (ctx->Transform.ClipPlanesEnabled)
         radeonUpdateClipPlanes( ctx );
    }
 
 
-   rmesa->NewGLState = 0;
+   rmesa->radeon.NewGLState = 0;
+
+   return GL_TRUE;
 }
 
 
@@ -2306,7 +2154,7 @@ static void radeonInvalidateState( GLcontext *ctx, GLuint new_state )
    _vbo_InvalidateState( ctx, new_state );
    _tnl_InvalidateState( ctx, new_state );
    _ae_invalidate_state( ctx, new_state );
-   RADEON_CONTEXT(ctx)->NewGLState |= new_state;
+   R100_CONTEXT(ctx)->radeon.NewGLState |= new_state;
 }
 
 
@@ -2317,8 +2165,8 @@ static GLboolean check_material( GLcontext *ctx )
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    GLint i;
 
-   for (i = _TNL_ATTRIB_MAT_FRONT_AMBIENT; 
-       i < _TNL_ATTRIB_MAT_BACK_INDEXES; 
+   for (i = _TNL_ATTRIB_MAT_FRONT_AMBIENT;
+       i < _TNL_ATTRIB_MAT_BACK_INDEXES;
        i++)
       if (tnl->vb.AttribPtr[i] &&
          tnl->vb.AttribPtr[i]->stride)
@@ -2326,20 +2174,21 @@ static GLboolean check_material( GLcontext *ctx )
 
    return GL_FALSE;
 }
-      
+
 
 static void radeonWrapRunPipeline( GLcontext *ctx )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLboolean has_material;
 
    if (0)
-      fprintf(stderr, "%s, newstate: %x\n", __FUNCTION__, rmesa->NewGLState);
+      fprintf(stderr, "%s, newstate: %x\n", __FUNCTION__, rmesa->radeon.NewGLState);
 
    /* Validate state:
     */
-   if (rmesa->NewGLState)
-      radeonValidateState( ctx );
+   if (rmesa->radeon.NewGLState)
+      if (!radeonValidateState( ctx ))
+        FALLBACK(rmesa, RADEON_FALLBACK_TEXTURE, GL_TRUE);
 
    has_material = (ctx->Light.Enabled && check_material( ctx ));
 
@@ -2348,7 +2197,7 @@ static void radeonWrapRunPipeline( GLcontext *ctx )
    }
 
    /* Run the pipeline.
-    */ 
+    */
    _tnl_run_pipeline( ctx );
 
    if (has_material) {
index 2171879f759547b80eea10ead7977b1ab13ae964..a7c8eef32a54697fb2ba1e35ab3833960b369d00 100644 (file)
@@ -39,30 +39,25 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "radeon_context.h"
 
-extern void radeonInitState( radeonContextPtr rmesa );
+extern void radeonInitState( r100ContextPtr rmesa );
 extern void radeonInitStateFuncs( GLcontext *ctx );
 
 extern void radeonUpdateMaterial( GLcontext *ctx );
 
-extern void radeonSetCliprects( radeonContextPtr rmesa );
-extern void radeonRecalcScissorRects( radeonContextPtr rmesa );
 extern void radeonUpdateViewportOffset( GLcontext *ctx );
 extern void radeonUpdateWindow( GLcontext *ctx );
 extern void radeonUpdateDrawBuffer( GLcontext *ctx );
-extern void radeonUploadTexMatrix( radeonContextPtr rmesa,
+extern void radeonUploadTexMatrix( r100ContextPtr rmesa,
                                   int unit, GLboolean swapcols );
 
-extern void radeonValidateState( GLcontext *ctx );
-
-extern void radeonPrintDirty( radeonContextPtr rmesa,
-                             const char *msg );
+extern GLboolean radeonValidateState( GLcontext *ctx );
 
 
 extern void radeonFallback( GLcontext *ctx, GLuint bit, GLboolean mode );
 #define FALLBACK( rmesa, bit, mode ) do {                              \
    if ( 0 ) fprintf( stderr, "FALLBACK in %s: #%d=%d\n",               \
                     __FUNCTION__, bit, mode );                         \
-   radeonFallback( rmesa->glCtx, bit, mode );                          \
+   radeonFallback( rmesa->radeon.glCtx, bit, mode );                           \
 } while (0)
 
 
index 57dc3800501a08610d2cc0a361f9e23332cdff41..f5d4189d669c545f8306b8cbeaa48e97c19c699c 100644 (file)
 #include "swrast_setup/swrast_setup.h"
 
 #include "radeon_context.h"
+#include "radeon_mipmap_tree.h"
 #include "radeon_ioctl.h"
 #include "radeon_state.h"
 #include "radeon_tcl.h"
 #include "radeon_tex.h"
 #include "radeon_swtcl.h"
 
+#include "../r200/r200_reg.h"
+
 #include "xmlpool.h"
 
+/* New (1.3) state mechanism.  3 commands (packet, scalar, vector) in
+ * 1.3 cmdbuffers allow all previous state to be updated as well as
+ * the tcl scalar and vector areas.
+ */
+static struct {
+       int start;
+       int len;
+       const char *name;
+} packet[RADEON_MAX_STATE_PACKETS] = {
+       {RADEON_PP_MISC, 7, "RADEON_PP_MISC"},
+       {RADEON_PP_CNTL, 3, "RADEON_PP_CNTL"},
+       {RADEON_RB3D_COLORPITCH, 1, "RADEON_RB3D_COLORPITCH"},
+       {RADEON_RE_LINE_PATTERN, 2, "RADEON_RE_LINE_PATTERN"},
+       {RADEON_SE_LINE_WIDTH, 1, "RADEON_SE_LINE_WIDTH"},
+       {RADEON_PP_LUM_MATRIX, 1, "RADEON_PP_LUM_MATRIX"},
+       {RADEON_PP_ROT_MATRIX_0, 2, "RADEON_PP_ROT_MATRIX_0"},
+       {RADEON_RB3D_STENCILREFMASK, 3, "RADEON_RB3D_STENCILREFMASK"},
+       {RADEON_SE_VPORT_XSCALE, 6, "RADEON_SE_VPORT_XSCALE"},
+       {RADEON_SE_CNTL, 2, "RADEON_SE_CNTL"},
+       {RADEON_SE_CNTL_STATUS, 1, "RADEON_SE_CNTL_STATUS"},
+       {RADEON_RE_MISC, 1, "RADEON_RE_MISC"},
+       {RADEON_PP_TXFILTER_0, 6, "RADEON_PP_TXFILTER_0"},
+       {RADEON_PP_BORDER_COLOR_0, 1, "RADEON_PP_BORDER_COLOR_0"},
+       {RADEON_PP_TXFILTER_1, 6, "RADEON_PP_TXFILTER_1"},
+       {RADEON_PP_BORDER_COLOR_1, 1, "RADEON_PP_BORDER_COLOR_1"},
+       {RADEON_PP_TXFILTER_2, 6, "RADEON_PP_TXFILTER_2"},
+       {RADEON_PP_BORDER_COLOR_2, 1, "RADEON_PP_BORDER_COLOR_2"},
+       {RADEON_SE_ZBIAS_FACTOR, 2, "RADEON_SE_ZBIAS_FACTOR"},
+       {RADEON_SE_TCL_OUTPUT_VTX_FMT, 11, "RADEON_SE_TCL_OUTPUT_VTX_FMT"},
+       {RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED, 17,
+                   "RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED"},
+       {R200_PP_TXCBLEND_0, 4, "R200_PP_TXCBLEND_0"},
+       {R200_PP_TXCBLEND_1, 4, "R200_PP_TXCBLEND_1"},
+       {R200_PP_TXCBLEND_2, 4, "R200_PP_TXCBLEND_2"},
+       {R200_PP_TXCBLEND_3, 4, "R200_PP_TXCBLEND_3"},
+       {R200_PP_TXCBLEND_4, 4, "R200_PP_TXCBLEND_4"},
+       {R200_PP_TXCBLEND_5, 4, "R200_PP_TXCBLEND_5"},
+       {R200_PP_TXCBLEND_6, 4, "R200_PP_TXCBLEND_6"},
+       {R200_PP_TXCBLEND_7, 4, "R200_PP_TXCBLEND_7"},
+       {R200_SE_TCL_LIGHT_MODEL_CTL_0, 6, "R200_SE_TCL_LIGHT_MODEL_CTL_0"},
+       {R200_PP_TFACTOR_0, 6, "R200_PP_TFACTOR_0"},
+       {R200_SE_VTX_FMT_0, 4, "R200_SE_VTX_FMT_0"},
+       {R200_SE_VAP_CNTL, 1, "R200_SE_VAP_CNTL"},
+       {R200_SE_TCL_MATRIX_SEL_0, 5, "R200_SE_TCL_MATRIX_SEL_0"},
+       {R200_SE_TCL_TEX_PROC_CTL_2, 5, "R200_SE_TCL_TEX_PROC_CTL_2"},
+       {R200_SE_TCL_UCP_VERT_BLEND_CTL, 1, "R200_SE_TCL_UCP_VERT_BLEND_CTL"},
+       {R200_PP_TXFILTER_0, 6, "R200_PP_TXFILTER_0"},
+       {R200_PP_TXFILTER_1, 6, "R200_PP_TXFILTER_1"},
+       {R200_PP_TXFILTER_2, 6, "R200_PP_TXFILTER_2"},
+       {R200_PP_TXFILTER_3, 6, "R200_PP_TXFILTER_3"},
+       {R200_PP_TXFILTER_4, 6, "R200_PP_TXFILTER_4"},
+       {R200_PP_TXFILTER_5, 6, "R200_PP_TXFILTER_5"},
+       {R200_PP_TXOFFSET_0, 1, "R200_PP_TXOFFSET_0"},
+       {R200_PP_TXOFFSET_1, 1, "R200_PP_TXOFFSET_1"},
+       {R200_PP_TXOFFSET_2, 1, "R200_PP_TXOFFSET_2"},
+       {R200_PP_TXOFFSET_3, 1, "R200_PP_TXOFFSET_3"},
+       {R200_PP_TXOFFSET_4, 1, "R200_PP_TXOFFSET_4"},
+       {R200_PP_TXOFFSET_5, 1, "R200_PP_TXOFFSET_5"},
+       {R200_SE_VTE_CNTL, 1, "R200_SE_VTE_CNTL"},
+       {R200_SE_TCL_OUTPUT_VTX_COMP_SEL, 1,
+        "R200_SE_TCL_OUTPUT_VTX_COMP_SEL"},
+       {R200_PP_TAM_DEBUG3, 1, "R200_PP_TAM_DEBUG3"},
+       {R200_PP_CNTL_X, 1, "R200_PP_CNTL_X"},
+       {R200_RB3D_DEPTHXY_OFFSET, 1, "R200_RB3D_DEPTHXY_OFFSET"},
+       {R200_RE_AUX_SCISSOR_CNTL, 1, "R200_RE_AUX_SCISSOR_CNTL"},
+       {R200_RE_SCISSOR_TL_0, 2, "R200_RE_SCISSOR_TL_0"},
+       {R200_RE_SCISSOR_TL_1, 2, "R200_RE_SCISSOR_TL_1"},
+       {R200_RE_SCISSOR_TL_2, 2, "R200_RE_SCISSOR_TL_2"},
+       {R200_SE_VAP_CNTL_STATUS, 1, "R200_SE_VAP_CNTL_STATUS"},
+       {R200_SE_VTX_STATE_CNTL, 1, "R200_SE_VTX_STATE_CNTL"},
+       {R200_RE_POINTSIZE, 1, "R200_RE_POINTSIZE"},
+       {R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0, 4,
+                   "R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0"},
+       {R200_PP_CUBIC_FACES_0, 1, "R200_PP_CUBIC_FACES_0"},    /* 61 */
+       {R200_PP_CUBIC_OFFSET_F1_0, 5, "R200_PP_CUBIC_OFFSET_F1_0"}, /* 62 */
+       {R200_PP_CUBIC_FACES_1, 1, "R200_PP_CUBIC_FACES_1"},
+       {R200_PP_CUBIC_OFFSET_F1_1, 5, "R200_PP_CUBIC_OFFSET_F1_1"},
+       {R200_PP_CUBIC_FACES_2, 1, "R200_PP_CUBIC_FACES_2"},
+       {R200_PP_CUBIC_OFFSET_F1_2, 5, "R200_PP_CUBIC_OFFSET_F1_2"},
+       {R200_PP_CUBIC_FACES_3, 1, "R200_PP_CUBIC_FACES_3"},
+       {R200_PP_CUBIC_OFFSET_F1_3, 5, "R200_PP_CUBIC_OFFSET_F1_3"},
+       {R200_PP_CUBIC_FACES_4, 1, "R200_PP_CUBIC_FACES_4"},
+       {R200_PP_CUBIC_OFFSET_F1_4, 5, "R200_PP_CUBIC_OFFSET_F1_4"},
+       {R200_PP_CUBIC_FACES_5, 1, "R200_PP_CUBIC_FACES_5"},
+       {R200_PP_CUBIC_OFFSET_F1_5, 5, "R200_PP_CUBIC_OFFSET_F1_5"},
+       {RADEON_PP_TEX_SIZE_0, 2, "RADEON_PP_TEX_SIZE_0"},
+       {RADEON_PP_TEX_SIZE_1, 2, "RADEON_PP_TEX_SIZE_1"},
+       {RADEON_PP_TEX_SIZE_2, 2, "RADEON_PP_TEX_SIZE_2"},
+       {R200_RB3D_BLENDCOLOR, 3, "R200_RB3D_BLENDCOLOR"},
+       {R200_SE_TCL_POINT_SPRITE_CNTL, 1, "R200_SE_TCL_POINT_SPRITE_CNTL"},
+       {RADEON_PP_CUBIC_FACES_0, 1, "RADEON_PP_CUBIC_FACES_0"},
+       {RADEON_PP_CUBIC_OFFSET_T0_0, 5, "RADEON_PP_CUBIC_OFFSET_T0_0"},
+       {RADEON_PP_CUBIC_FACES_1, 1, "RADEON_PP_CUBIC_FACES_1"},
+       {RADEON_PP_CUBIC_OFFSET_T1_0, 5, "RADEON_PP_CUBIC_OFFSET_T1_0"},
+       {RADEON_PP_CUBIC_FACES_2, 1, "RADEON_PP_CUBIC_FACES_2"},
+       {RADEON_PP_CUBIC_OFFSET_T2_0, 5, "RADEON_PP_CUBIC_OFFSET_T2_0"},
+       {R200_PP_TRI_PERF, 2, "R200_PP_TRI_PERF"},
+       {R200_PP_TXCBLEND_8, 32, "R200_PP_AFS_0"},     /* 85 */
+       {R200_PP_TXCBLEND_0, 32, "R200_PP_AFS_1"},
+       {R200_PP_TFACTOR_0, 8, "R200_ATF_TFACTOR"},
+       {R200_PP_TXFILTER_0, 8, "R200_PP_TXCTLALL_0"},
+       {R200_PP_TXFILTER_1, 8, "R200_PP_TXCTLALL_1"},
+       {R200_PP_TXFILTER_2, 8, "R200_PP_TXCTLALL_2"},
+       {R200_PP_TXFILTER_3, 8, "R200_PP_TXCTLALL_3"},
+       {R200_PP_TXFILTER_4, 8, "R200_PP_TXCTLALL_4"},
+       {R200_PP_TXFILTER_5, 8, "R200_PP_TXCTLALL_5"},
+       {R200_VAP_PVS_CNTL_1, 2, "R200_VAP_PVS_CNTL"},
+};
+
 /* =============================================================
  * State initialization
  */
-
-void radeonPrintDirty( radeonContextPtr rmesa, const char *msg )
+static int cmdpkt( r100ContextPtr rmesa, int id ) 
 {
-   struct radeon_state_atom *l;
-
-   fprintf(stderr, msg);
-   fprintf(stderr, ": ");
+   drm_radeon_cmd_header_t h;
 
-   foreach(l, &rmesa->hw.atomlist) {
-      if (l->dirty || rmesa->hw.all_dirty)
-        fprintf(stderr, "%s, ", l->name);
+   if (rmesa->radeon.radeonScreen->kernel_mm) {
+     return CP_PACKET0(packet[id].start, packet[id].len - 1);
+   } else {
+     h.i = 0;
+     h.packet.cmd_type = RADEON_CMD_PACKET;
+     h.packet.packet_id = id;
    }
-
-   fprintf(stderr, "\n");
-}
-
-static int cmdpkt( int id ) 
-{
-   drm_radeon_cmd_header_t h;
-   h.i = 0;
-   h.packet.cmd_type = RADEON_CMD_PACKET;
-   h.packet.packet_id = id;
    return h.i;
 }
 
@@ -96,17 +197,17 @@ static int cmdscl( int offset, int stride, int count )
    return h.i;
 }
 
-#define CHECK( NM, FLAG )                      \
-static GLboolean check_##NM( GLcontext *ctx )  \
-{                                              \
-   return FLAG;                                        \
+#define CHECK( NM, FLAG )                              \
+static int check_##NM( GLcontext *ctx, struct radeon_state_atom *atom )        \
+{                                                      \
+   return FLAG ? atom->cmd_size : 0;                   \
 }
 
 #define TCL_CHECK( NM, FLAG )                          \
-static GLboolean check_##NM( GLcontext *ctx )          \
+static int check_##NM( GLcontext *ctx, struct radeon_state_atom *atom )        \
 {                                                      \
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);       \
-   return !rmesa->TclFallback && (FLAG);               \
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);   \
+   return (!rmesa->radeon.TclFallback && (FLAG)) ? atom->cmd_size : 0; \
 }
 
 
@@ -146,81 +247,392 @@ CHECK( txr0, (ctx->Texture.Unit[0]._ReallyEnabled & TEXTURE_RECT_BIT))
 CHECK( txr1, (ctx->Texture.Unit[1]._ReallyEnabled & TEXTURE_RECT_BIT))
 CHECK( txr2, (ctx->Texture.Unit[2]._ReallyEnabled & TEXTURE_RECT_BIT))
 
+#define OUT_VEC(hdr, data) do {                        \
+    drm_radeon_cmd_header_t h;                                 \
+    h.i = hdr;                                                         \
+    OUT_BATCH(CP_PACKET0(RADEON_SE_TCL_STATE_FLUSH, 0));               \
+    OUT_BATCH(0);                                                      \
+    OUT_BATCH(CP_PACKET0(R200_SE_TCL_VECTOR_INDX_REG, 0));             \
+    OUT_BATCH(h.vectors.offset | (h.vectors.stride << RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT)); \
+    OUT_BATCH(CP_PACKET0_ONE(R200_SE_TCL_VECTOR_DATA_REG, h.vectors.count - 1));       \
+    OUT_BATCH_TABLE((data), h.vectors.count);                          \
+  } while(0)
+
+#define OUT_SCL(hdr, data) do {                                        \
+    drm_radeon_cmd_header_t h;                                         \
+    h.i = hdr;                                                         \
+    OUT_BATCH(CP_PACKET0(R200_SE_TCL_SCALAR_INDX_REG, 0));             \
+    OUT_BATCH((h.scalars.offset) | (h.scalars.stride << RADEON_SCAL_INDX_DWORD_STRIDE_SHIFT)); \
+    OUT_BATCH(CP_PACKET0_ONE(R200_SE_TCL_SCALAR_DATA_REG, h.scalars.count - 1));       \
+    OUT_BATCH_TABLE((data), h.scalars.count);                          \
+  } while(0)
+
+static void scl_emit(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+   r100ContextPtr r100 = R100_CONTEXT(ctx);
+   BATCH_LOCALS(&r100->radeon);
+   uint32_t dwords = atom->cmd_size;
+   
+   dwords += 2;
+   BEGIN_BATCH_NO_AUTOSTATE(dwords);
+   OUT_SCL(atom->cmd[0], atom->cmd+1);
+   END_BATCH();
+}
 
 
-/* Initialize the context's hardware state.
- */
-void radeonInitState( radeonContextPtr rmesa )
+static void vec_emit(GLcontext *ctx, struct radeon_state_atom *atom)
 {
-   GLcontext *ctx = rmesa->glCtx;
-   GLuint color_fmt, depth_fmt, i;
-   GLint drawPitch, drawOffset;
+   r100ContextPtr r100 = R100_CONTEXT(ctx);
+   BATCH_LOCALS(&r100->radeon);
+   uint32_t dwords = atom->cmd_size;
+
+   dwords += 4;
+   BEGIN_BATCH_NO_AUTOSTATE(dwords);
+   OUT_VEC(atom->cmd[0], atom->cmd+1);
+   END_BATCH();
+}
 
-   switch ( rmesa->radeonScreen->cpp ) {
-   case 2:
-      color_fmt = RADEON_COLOR_FORMAT_RGB565;
-      break;
-   case 4:
-      color_fmt = RADEON_COLOR_FORMAT_ARGB8888;
-      break;
-   default:
-      fprintf( stderr, "Error: Unsupported pixel depth... exiting\n" );
-      exit( -1 );
+
+static void lit_emit(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+   r100ContextPtr r100 = R100_CONTEXT(ctx);
+   BATCH_LOCALS(&r100->radeon);
+   uint32_t dwords = atom->cmd_size;
+
+   dwords += 6;
+   BEGIN_BATCH_NO_AUTOSTATE(dwords);
+   OUT_VEC(atom->cmd[LIT_CMD_0], atom->cmd+1);
+   OUT_SCL(atom->cmd[LIT_CMD_1], atom->cmd+LIT_CMD_1+1);
+   END_BATCH();
+}
+
+static void ctx_emit(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+   r100ContextPtr r100 = R100_CONTEXT(ctx);
+   BATCH_LOCALS(&r100->radeon);
+   struct radeon_renderbuffer *rrb;
+   uint32_t cbpitch;
+   uint32_t zbpitch, depth_fmt;
+   uint32_t dwords = atom->cmd_size;
+
+   /* output the first 7 bytes of context */
+   BEGIN_BATCH_NO_AUTOSTATE(dwords + 4);
+   OUT_BATCH_TABLE(atom->cmd, 5);
+
+   rrb = radeon_get_depthbuffer(&r100->radeon);
+   if (!rrb) {
+     OUT_BATCH(0);
+     OUT_BATCH(0);
+   } else {
+     zbpitch = (rrb->pitch / rrb->cpp);
+     if (r100->using_hyperz)
+       zbpitch |= RADEON_DEPTH_HYPERZ;
+
+     OUT_BATCH_RELOC(0, rrb->bo, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+     OUT_BATCH(zbpitch);
+     if (rrb->cpp == 4)
+        depth_fmt = RADEON_DEPTH_FORMAT_24BIT_INT_Z;
+     else
+        depth_fmt = RADEON_DEPTH_FORMAT_16BIT_INT_Z;
+     atom->cmd[CTX_RB3D_ZSTENCILCNTL] &= ~RADEON_DEPTH_FORMAT_MASK;
+     atom->cmd[CTX_RB3D_ZSTENCILCNTL] |= depth_fmt;
+   }
+     
+   OUT_BATCH(atom->cmd[CTX_RB3D_ZSTENCILCNTL]);
+   OUT_BATCH(atom->cmd[CTX_CMD_1]);
+   OUT_BATCH(atom->cmd[CTX_PP_CNTL]);
+
+   rrb = radeon_get_colorbuffer(&r100->radeon);
+   if (!rrb || !rrb->bo) {
+      OUT_BATCH(atom->cmd[CTX_RB3D_CNTL]);
+      OUT_BATCH(atom->cmd[CTX_RB3D_COLOROFFSET]);
+   } else {
+      atom->cmd[CTX_RB3D_CNTL] &= ~(0xf << 10);
+      if (rrb->cpp == 4)
+         atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_ARGB8888;
+      else
+         atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_RGB565;
+
+      OUT_BATCH(atom->cmd[CTX_RB3D_CNTL]);
+      OUT_BATCH_RELOC(0, rrb->bo, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
    }
 
-   rmesa->state.color.clear = 0x00000000;
+   OUT_BATCH(atom->cmd[CTX_CMD_2]);
+
+   if (!rrb || !rrb->bo) {
+     OUT_BATCH(atom->cmd[CTX_RB3D_COLORPITCH]);
+   } else {
+     cbpitch = (rrb->pitch / rrb->cpp);
+     if (rrb->bo->flags & RADEON_BO_FLAGS_MACRO_TILE)
+       cbpitch |= RADEON_COLOR_TILE_ENABLE;
+     OUT_BATCH(cbpitch);
+   }
+
+   END_BATCH();
+}
+
+static void ctx_emit_cs(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+   r100ContextPtr r100 = R100_CONTEXT(ctx);
+   BATCH_LOCALS(&r100->radeon);
+   struct radeon_renderbuffer *rrb, *drb;
+   uint32_t cbpitch = 0;
+   uint32_t zbpitch = 0;
+   uint32_t dwords = atom->cmd_size;
+   uint32_t depth_fmt;
+
+   rrb = radeon_get_colorbuffer(&r100->radeon);
+   if (!rrb || !rrb->bo) {
+      fprintf(stderr, "no rrb\n");
+      return;
+   }
+
+   atom->cmd[CTX_RB3D_CNTL] &= ~(0xf << 10);
+   if (rrb->cpp == 4)
+       atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_ARGB8888;
+   else
+       atom->cmd[CTX_RB3D_CNTL] |= RADEON_COLOR_FORMAT_RGB565;
+
+   cbpitch = (rrb->pitch / rrb->cpp);
+   if (rrb->bo->flags & RADEON_BO_FLAGS_MACRO_TILE)
+       cbpitch |= R200_COLOR_TILE_ENABLE;
+
+   drb = radeon_get_depthbuffer(&r100->radeon);
+   if (drb) {
+     zbpitch = (drb->pitch / drb->cpp);
+     if (drb->cpp == 4)
+        depth_fmt = RADEON_DEPTH_FORMAT_24BIT_INT_Z;
+     else
+        depth_fmt = RADEON_DEPTH_FORMAT_16BIT_INT_Z;
+     atom->cmd[CTX_RB3D_ZSTENCILCNTL] &= ~RADEON_DEPTH_FORMAT_MASK;
+     atom->cmd[CTX_RB3D_ZSTENCILCNTL] |= depth_fmt;
+     
+   }
+
+   /* output the first 7 bytes of context */
+   dwords = 10;
+   if (drb)
+     dwords += 6;
+   if (rrb)
+     dwords += 6;
+   BEGIN_BATCH_NO_AUTOSTATE(dwords);
+
+   /* In the CS case we need to split this up */
+   OUT_BATCH(CP_PACKET0(packet[0].start, 3));
+   OUT_BATCH_TABLE((atom->cmd + 1), 4);
+
+   if (drb) {
+     OUT_BATCH(CP_PACKET0(RADEON_RB3D_DEPTHOFFSET, 0));
+     OUT_BATCH_RELOC(0, drb->bo, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+
+     OUT_BATCH(CP_PACKET0(RADEON_RB3D_DEPTHPITCH, 0));
+     OUT_BATCH(zbpitch);
+   }
+
+   OUT_BATCH(CP_PACKET0(RADEON_RB3D_ZSTENCILCNTL, 0));
+   OUT_BATCH(atom->cmd[CTX_RB3D_ZSTENCILCNTL]);
+   OUT_BATCH(CP_PACKET0(RADEON_PP_CNTL, 1));
+   OUT_BATCH(atom->cmd[CTX_PP_CNTL]);
+   OUT_BATCH(atom->cmd[CTX_RB3D_CNTL]);
+
+   if (rrb) {
+     OUT_BATCH(CP_PACKET0(RADEON_RB3D_COLOROFFSET, 0));
+     OUT_BATCH_RELOC(0, rrb->bo, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+
+     OUT_BATCH(CP_PACKET0(RADEON_RB3D_COLORPITCH, 0));
+     OUT_BATCH(cbpitch);
+   }
+
+   // if (atom->cmd_size == CTX_STATE_SIZE_NEWDRM) {
+   //   OUT_BATCH_TABLE((atom->cmd + 14), 4);
+   // }
+
+   END_BATCH();
+   BEGIN_BATCH_NO_AUTOSTATE(4);
+   OUT_BATCH(CP_PACKET0(RADEON_RE_TOP_LEFT, 0));
+   OUT_BATCH(0);
+   OUT_BATCH(CP_PACKET0(RADEON_RE_WIDTH_HEIGHT, 0));
+   if (rrb) {
+       OUT_BATCH(((rrb->width - 1) << RADEON_RE_WIDTH_SHIFT) |
+                 ((rrb->height - 1) << RADEON_RE_HEIGHT_SHIFT));
+   } else {
+       OUT_BATCH(0);
+   }
+   END_BATCH();
+}
+
+static void cube_emit(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+   r100ContextPtr r100 = R100_CONTEXT(ctx);
+   BATCH_LOCALS(&r100->radeon);
+   uint32_t dwords = 2;
+   int i = atom->idx, j;
+   radeonTexObj *t = r100->state.texture.unit[i].texobj;
+   radeon_mipmap_level *lvl;
+   uint32_t base_reg;
+
+   if (!(ctx->Texture.Unit[i]._ReallyEnabled & TEXTURE_CUBE_BIT))
+       return;
+
+   if (!t)
+       return;
+
+   if (!t->mt)
+       return;
+
+   switch(i) {
+       case 1: base_reg = RADEON_PP_CUBIC_OFFSET_T1_0; break;
+       case 2: base_reg = RADEON_PP_CUBIC_OFFSET_T2_0; break;
+       default:
+       case 0: base_reg = RADEON_PP_CUBIC_OFFSET_T0_0; break;
+   };
+   BEGIN_BATCH_NO_AUTOSTATE(dwords + (5 * 4));
+   OUT_BATCH_TABLE(atom->cmd, 2);
+   lvl = &t->mt->levels[0];
+   for (j = 0; j < 5; j++) {
+       OUT_BATCH(CP_PACKET0(base_reg + (4 * (j-1)), 0));
+       OUT_BATCH_RELOC(lvl->faces[j].offset, t->mt->bo, lvl->faces[j].offset,
+                       RADEON_GEM_DOMAIN_VRAM, 0, 0);
+   }
+   END_BATCH();
+}
+
+static void tex_emit(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+   r100ContextPtr r100 = R100_CONTEXT(ctx);
+   BATCH_LOCALS(&r100->radeon);
+   uint32_t dwords = atom->cmd_size;
+   int i = atom->idx;
+   radeonTexObj *t = r100->state.texture.unit[i].texobj;
+   radeon_mipmap_level *lvl;
+
+   if (t && t->mt && !t->image_override)
+     dwords += 2;
+   BEGIN_BATCH_NO_AUTOSTATE(dwords);
+
+   OUT_BATCH_TABLE(atom->cmd, 3);
+   if (t && t->mt && !t->image_override) {
+     if ((ctx->Texture.Unit[i]._ReallyEnabled & TEXTURE_CUBE_BIT)) {
+       lvl = &t->mt->levels[0];
+       OUT_BATCH_RELOC(lvl->faces[5].offset, t->mt->bo, lvl->faces[5].offset,
+                       RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);
+     } else {
+        OUT_BATCH_RELOC(t->tile_bits, t->mt->bo, 0,
+                    RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);
+     }
+   } else if (!t) {
+     /* workaround for old CS mechanism */
+     OUT_BATCH(r100->radeon.radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP]);
+     //     OUT_BATCH(r100->radeon.radeonScreen);
+   } else {
+     OUT_BATCH(t->override_offset);
+   }
+
+   OUT_BATCH_TABLE((atom->cmd+4), 5);
+   END_BATCH();
+}
+
+static void tex_emit_cs(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+   r100ContextPtr r100 = R100_CONTEXT(ctx);
+   BATCH_LOCALS(&r100->radeon);
+   uint32_t dwords = atom->cmd_size;
+   int i = atom->idx;
+   radeonTexObj *t = r100->state.texture.unit[i].texobj;
+   radeon_mipmap_level *lvl;
+   int hastexture = 1;
+
+   if (!t)
+       hastexture = 0;
+   else {
+       if (!t->mt && !t->bo)
+               hastexture = 0;
+   }
+   dwords += 1;
+   if (hastexture)
+     dwords += 2;
+   else
+     dwords -= 2;
+   BEGIN_BATCH_NO_AUTOSTATE(dwords);
+
+   OUT_BATCH(CP_PACKET0(RADEON_PP_TXFILTER_0 + (24 * i), 1));
+   OUT_BATCH_TABLE((atom->cmd + 1), 2);
+
+   if (hastexture) {
+     OUT_BATCH(CP_PACKET0(RADEON_PP_TXOFFSET_0 + (24 * i), 0));
+     if (t->mt && !t->image_override) {
+        if ((ctx->Texture.Unit[i]._ReallyEnabled & TEXTURE_CUBE_BIT)) {
+            lvl = &t->mt->levels[0];
+           OUT_BATCH_RELOC(lvl->faces[5].offset, t->mt->bo, lvl->faces[5].offset,
+                       RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);
+        } else {
+           OUT_BATCH_RELOC(t->tile_bits, t->mt->bo, 0,
+                    RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);
+        }
+      } else {
+       if (t->bo)
+            OUT_BATCH_RELOC(t->tile_bits, t->bo, 0,
+                            RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);
+      }
+   }
+
+   OUT_BATCH(CP_PACKET0(RADEON_PP_TXCBLEND_0 + (i * 24), 1));
+   OUT_BATCH_TABLE((atom->cmd+4), 2);
+   OUT_BATCH(CP_PACKET0(RADEON_PP_BORDER_COLOR_0 + (i * 4), 0));
+   OUT_BATCH((atom->cmd[TEX_PP_BORDER_COLOR]));
+   END_BATCH();
+}
+
+/* Initialize the context's hardware state.
+ */
+void radeonInitState( r100ContextPtr rmesa )
+{
+   GLcontext *ctx = rmesa->radeon.glCtx;
+   GLuint i;
+
+   rmesa->radeon.state.color.clear = 0x00000000;
 
    switch ( ctx->Visual.depthBits ) {
    case 16:
-      rmesa->state.depth.clear = 0x0000ffff;
-      rmesa->state.depth.scale = 1.0 / (GLfloat)0xffff;
-      depth_fmt = RADEON_DEPTH_FORMAT_16BIT_INT_Z;
-      rmesa->state.stencil.clear = 0x00000000;
+      rmesa->radeon.state.depth.clear = 0x0000ffff;
+      rmesa->radeon.state.stencil.clear = 0x00000000;
       break;
    case 24:
-      rmesa->state.depth.clear = 0x00ffffff;
-      rmesa->state.depth.scale = 1.0 / (GLfloat)0xffffff;
-      depth_fmt = RADEON_DEPTH_FORMAT_24BIT_INT_Z;
-      rmesa->state.stencil.clear = 0xffff0000;
+      rmesa->radeon.state.depth.clear = 0x00ffffff;
+      rmesa->radeon.state.stencil.clear = 0xffff0000;
       break;
    default:
-      fprintf( stderr, "Error: Unsupported depth %d... exiting\n",
-              ctx->Visual.depthBits );
-      exit( -1 );
+      break;
    }
 
-   /* Only have hw stencil when depth buffer is 24 bits deep */
-   rmesa->state.stencil.hwBuffer = ( ctx->Visual.stencilBits > 0 &&
-                                    ctx->Visual.depthBits == 24 );
+   rmesa->radeon.Fallback = 0;
 
-   rmesa->Fallback = 0;
-
-   if ( ctx->Visual.doubleBufferMode && rmesa->sarea->pfCurrentPage == 0 ) {
-      drawOffset = rmesa->radeonScreen->backOffset;
-      drawPitch  = rmesa->radeonScreen->backPitch;
-   } else {
-      drawOffset = rmesa->radeonScreen->frontOffset;
-      drawPitch  = rmesa->radeonScreen->frontPitch;
-   }
 
-   rmesa->hw.max_state_size = 0;
+   rmesa->radeon.hw.max_state_size = 0;
 
-#define ALLOC_STATE( ATOM, CHK, SZ, NM, FLAG )                         \
+#define ALLOC_STATE_IDX( ATOM, CHK, SZ, NM, FLAG, IDX )                \
    do {                                                                \
       rmesa->hw.ATOM.cmd_size = SZ;                            \
-      rmesa->hw.ATOM.cmd = (int *)CALLOC(SZ * sizeof(int));    \
-      rmesa->hw.ATOM.lastcmd = (int *)CALLOC(SZ * sizeof(int));        \
-      rmesa->hw.ATOM.name = NM;                                        \
+      rmesa->hw.ATOM.cmd = (GLuint *)CALLOC(SZ * sizeof(int)); \
+      rmesa->hw.ATOM.lastcmd = (GLuint *)CALLOC(SZ * sizeof(int)); \
+      rmesa->hw.ATOM.name = NM;                                                \
       rmesa->hw.ATOM.is_tcl = FLAG;                                    \
       rmesa->hw.ATOM.check = check_##CHK;                              \
-      rmesa->hw.ATOM.dirty = GL_TRUE;                          \
-      rmesa->hw.max_state_size += SZ * sizeof(int);            \
+      rmesa->hw.ATOM.dirty = GL_TRUE;                                  \
+      rmesa->hw.ATOM.idx = IDX;                                        \
+      rmesa->radeon.hw.max_state_size += SZ * sizeof(int);             \
    } while (0)
-      
-      
+
+#define ALLOC_STATE( ATOM, CHK, SZ, NM, FLAG )         \
+   ALLOC_STATE_IDX(ATOM, CHK, SZ, NM, FLAG, 0)
+
    /* Allocate state buffers:
     */
    ALLOC_STATE( ctx, always, CTX_STATE_SIZE, "CTX/context", 0 );
+   if (rmesa->radeon.radeonScreen->kernel_mm)
+     rmesa->hw.ctx.emit = ctx_emit_cs;
+   else
+     rmesa->hw.ctx.emit = ctx_emit;
    ALLOC_STATE( lin, always, LIN_STATE_SIZE, "LIN/line", 0 );
    ALLOC_STATE( msk, always, MSK_STATE_SIZE, "MSK/mask", 0 );
    ALLOC_STATE( vpt, always, VPT_STATE_SIZE, "VPT/viewport", 0 );
@@ -233,20 +645,29 @@ void radeonInitState( radeonContextPtr rmesa )
    ALLOC_STATE( fog, fog, FOG_STATE_SIZE, "FOG/fog", 1 );
    ALLOC_STATE( glt, tcl_lighting, GLT_STATE_SIZE, "GLT/light-global", 1 );
    ALLOC_STATE( eye, tcl_lighting, EYE_STATE_SIZE, "EYE/eye-vector", 1 );
-   ALLOC_STATE( tex[0], tex0, TEX_STATE_SIZE, "TEX/tex-0", 0 );
-   ALLOC_STATE( tex[1], tex1, TEX_STATE_SIZE, "TEX/tex-1", 0 );
-   ALLOC_STATE( tex[2], tex2, TEX_STATE_SIZE, "TEX/tex-2", 0 );
-   if (rmesa->radeonScreen->drmSupportsCubeMapsR100)
+   ALLOC_STATE_IDX( tex[0], tex0, TEX_STATE_SIZE, "TEX/tex-0", 0, 0);
+   ALLOC_STATE_IDX( tex[1], tex1, TEX_STATE_SIZE, "TEX/tex-1", 0, 1);
+   ALLOC_STATE_IDX( tex[2], tex2, TEX_STATE_SIZE, "TEX/tex-2", 0, 2);
+
+   for (i = 0; i < 3; i++) {
+      if (rmesa->radeon.radeonScreen->kernel_mm)
+          rmesa->hw.tex[i].emit = tex_emit_cs;
+      else
+          rmesa->hw.tex[i].emit = tex_emit;
+   }
+   if (rmesa->radeon.radeonScreen->drmSupportsCubeMapsR100)
    {
-      ALLOC_STATE( cube[0], cube0, CUBE_STATE_SIZE, "CUBE/cube-0", 0 );
-      ALLOC_STATE( cube[1], cube1, CUBE_STATE_SIZE, "CUBE/cube-1", 0 );
-      ALLOC_STATE( cube[2], cube2, CUBE_STATE_SIZE, "CUBE/cube-2", 0 );
+      ALLOC_STATE_IDX( cube[0], cube0, CUBE_STATE_SIZE, "CUBE/cube-0", 0, 0 );
+      ALLOC_STATE_IDX( cube[1], cube1, CUBE_STATE_SIZE, "CUBE/cube-1", 0, 1 );
+      ALLOC_STATE_IDX( cube[2], cube2, CUBE_STATE_SIZE, "CUBE/cube-2", 0, 2 );
+      for (i = 0; i < 3; i++)
+         rmesa->hw.cube[i].emit = cube_emit;
    }
    else
    {
-      ALLOC_STATE( cube[0], never, CUBE_STATE_SIZE, "CUBE/cube-0", 0 );
-      ALLOC_STATE( cube[1], never, CUBE_STATE_SIZE, "CUBE/cube-1", 0 );
-      ALLOC_STATE( cube[2], never, CUBE_STATE_SIZE, "CUBE/cube-2", 0 );
+      ALLOC_STATE_IDX( cube[0], never, CUBE_STATE_SIZE, "CUBE/cube-0", 0, 0 );
+      ALLOC_STATE_IDX( cube[1], never, CUBE_STATE_SIZE, "CUBE/cube-1", 0, 1 );
+      ALLOC_STATE_IDX( cube[2], never, CUBE_STATE_SIZE, "CUBE/cube-2", 0, 2 );
    }
    ALLOC_STATE( mat[0], tcl, MAT_STATE_SIZE, "MAT/modelproject", 1 );
    ALLOC_STATE( mat[1], tcl_eyespace_or_fog, MAT_STATE_SIZE, "MAT/modelview", 1 );
@@ -268,43 +689,43 @@ void radeonInitState( radeonContextPtr rmesa )
    ALLOC_STATE( lit[5], tcl_lit5, LIT_STATE_SIZE, "LIT/light-5", 1 );
    ALLOC_STATE( lit[6], tcl_lit6, LIT_STATE_SIZE, "LIT/light-6", 1 );
    ALLOC_STATE( lit[7], tcl_lit7, LIT_STATE_SIZE, "LIT/light-7", 1 );
-   ALLOC_STATE( txr[0], txr0, TXR_STATE_SIZE, "TXR/txr-0", 0 );
-   ALLOC_STATE( txr[1], txr1, TXR_STATE_SIZE, "TXR/txr-1", 0 );
-   ALLOC_STATE( txr[2], txr2, TXR_STATE_SIZE, "TXR/txr-2", 0 );
+   ALLOC_STATE_IDX( txr[0], txr0, TXR_STATE_SIZE, "TXR/txr-0", 0, 0 );
+   ALLOC_STATE_IDX( txr[1], txr1, TXR_STATE_SIZE, "TXR/txr-1", 0, 1 );
+   ALLOC_STATE_IDX( txr[2], txr2, TXR_STATE_SIZE, "TXR/txr-2", 0, 2 );
 
    radeonSetUpAtomList( rmesa );
 
    /* Fill in the packet headers:
     */
-   rmesa->hw.ctx.cmd[CTX_CMD_0] = cmdpkt(RADEON_EMIT_PP_MISC);
-   rmesa->hw.ctx.cmd[CTX_CMD_1] = cmdpkt(RADEON_EMIT_PP_CNTL);
-   rmesa->hw.ctx.cmd[CTX_CMD_2] = cmdpkt(RADEON_EMIT_RB3D_COLORPITCH);
-   rmesa->hw.lin.cmd[LIN_CMD_0] = cmdpkt(RADEON_EMIT_RE_LINE_PATTERN);
-   rmesa->hw.lin.cmd[LIN_CMD_1] = cmdpkt(RADEON_EMIT_SE_LINE_WIDTH);
-   rmesa->hw.msk.cmd[MSK_CMD_0] = cmdpkt(RADEON_EMIT_RB3D_STENCILREFMASK);
-   rmesa->hw.vpt.cmd[VPT_CMD_0] = cmdpkt(RADEON_EMIT_SE_VPORT_XSCALE);
-   rmesa->hw.set.cmd[SET_CMD_0] = cmdpkt(RADEON_EMIT_SE_CNTL);
-   rmesa->hw.set.cmd[SET_CMD_1] = cmdpkt(RADEON_EMIT_SE_CNTL_STATUS);
-   rmesa->hw.msc.cmd[MSC_CMD_0] = cmdpkt(RADEON_EMIT_RE_MISC);
-   rmesa->hw.tex[0].cmd[TEX_CMD_0] = cmdpkt(RADEON_EMIT_PP_TXFILTER_0);
-   rmesa->hw.tex[0].cmd[TEX_CMD_1] = cmdpkt(RADEON_EMIT_PP_BORDER_COLOR_0);
-   rmesa->hw.tex[1].cmd[TEX_CMD_0] = cmdpkt(RADEON_EMIT_PP_TXFILTER_1);
-   rmesa->hw.tex[1].cmd[TEX_CMD_1] = cmdpkt(RADEON_EMIT_PP_BORDER_COLOR_1);
-   rmesa->hw.tex[2].cmd[TEX_CMD_0] = cmdpkt(RADEON_EMIT_PP_TXFILTER_2);
-   rmesa->hw.tex[2].cmd[TEX_CMD_1] = cmdpkt(RADEON_EMIT_PP_BORDER_COLOR_2);
-   rmesa->hw.cube[0].cmd[CUBE_CMD_0] = cmdpkt(RADEON_EMIT_PP_CUBIC_FACES_0);
-   rmesa->hw.cube[0].cmd[CUBE_CMD_1] = cmdpkt(RADEON_EMIT_PP_CUBIC_OFFSETS_T0);
-   rmesa->hw.cube[1].cmd[CUBE_CMD_0] = cmdpkt(RADEON_EMIT_PP_CUBIC_FACES_1);
-   rmesa->hw.cube[1].cmd[CUBE_CMD_1] = cmdpkt(RADEON_EMIT_PP_CUBIC_OFFSETS_T1);
-   rmesa->hw.cube[2].cmd[CUBE_CMD_0] = cmdpkt(RADEON_EMIT_PP_CUBIC_FACES_2);
-   rmesa->hw.cube[2].cmd[CUBE_CMD_1] = cmdpkt(RADEON_EMIT_PP_CUBIC_OFFSETS_T2);
-   rmesa->hw.zbs.cmd[ZBS_CMD_0] = cmdpkt(RADEON_EMIT_SE_ZBIAS_FACTOR);
-   rmesa->hw.tcl.cmd[TCL_CMD_0] = cmdpkt(RADEON_EMIT_SE_TCL_OUTPUT_VTX_FMT);
+   rmesa->hw.ctx.cmd[CTX_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_PP_MISC);
+   rmesa->hw.ctx.cmd[CTX_CMD_1] = cmdpkt(rmesa, RADEON_EMIT_PP_CNTL);
+   rmesa->hw.ctx.cmd[CTX_CMD_2] = cmdpkt(rmesa, RADEON_EMIT_RB3D_COLORPITCH);
+   rmesa->hw.lin.cmd[LIN_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_RE_LINE_PATTERN);
+   rmesa->hw.lin.cmd[LIN_CMD_1] = cmdpkt(rmesa, RADEON_EMIT_SE_LINE_WIDTH);
+   rmesa->hw.msk.cmd[MSK_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_RB3D_STENCILREFMASK);
+   rmesa->hw.vpt.cmd[VPT_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_SE_VPORT_XSCALE);
+   rmesa->hw.set.cmd[SET_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_SE_CNTL);
+   rmesa->hw.set.cmd[SET_CMD_1] = cmdpkt(rmesa, RADEON_EMIT_SE_CNTL_STATUS);
+   rmesa->hw.msc.cmd[MSC_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_RE_MISC);
+   rmesa->hw.tex[0].cmd[TEX_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_PP_TXFILTER_0);
+   rmesa->hw.tex[0].cmd[TEX_CMD_1] = cmdpkt(rmesa, RADEON_EMIT_PP_BORDER_COLOR_0);
+   rmesa->hw.tex[1].cmd[TEX_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_PP_TXFILTER_1);
+   rmesa->hw.tex[1].cmd[TEX_CMD_1] = cmdpkt(rmesa, RADEON_EMIT_PP_BORDER_COLOR_1);
+   rmesa->hw.tex[2].cmd[TEX_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_PP_TXFILTER_2);
+   rmesa->hw.tex[2].cmd[TEX_CMD_1] = cmdpkt(rmesa, RADEON_EMIT_PP_BORDER_COLOR_2);
+   rmesa->hw.cube[0].cmd[CUBE_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_PP_CUBIC_FACES_0);
+   rmesa->hw.cube[0].cmd[CUBE_CMD_1] = cmdpkt(rmesa, RADEON_EMIT_PP_CUBIC_OFFSETS_T0);
+   rmesa->hw.cube[1].cmd[CUBE_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_PP_CUBIC_FACES_1);
+   rmesa->hw.cube[1].cmd[CUBE_CMD_1] = cmdpkt(rmesa, RADEON_EMIT_PP_CUBIC_OFFSETS_T1);
+   rmesa->hw.cube[2].cmd[CUBE_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_PP_CUBIC_FACES_2);
+   rmesa->hw.cube[2].cmd[CUBE_CMD_1] = cmdpkt(rmesa, RADEON_EMIT_PP_CUBIC_OFFSETS_T2);
+   rmesa->hw.zbs.cmd[ZBS_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_SE_ZBIAS_FACTOR);
+   rmesa->hw.tcl.cmd[TCL_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_SE_TCL_OUTPUT_VTX_FMT);
    rmesa->hw.mtl.cmd[MTL_CMD_0] = 
-      cmdpkt(RADEON_EMIT_SE_TCL_MATERIAL_EMMISSIVE_RED);
-   rmesa->hw.txr[0].cmd[TXR_CMD_0] = cmdpkt(RADEON_EMIT_PP_TEX_SIZE_0);
-   rmesa->hw.txr[1].cmd[TXR_CMD_0] = cmdpkt(RADEON_EMIT_PP_TEX_SIZE_1);
-   rmesa->hw.txr[2].cmd[TXR_CMD_0] = cmdpkt(RADEON_EMIT_PP_TEX_SIZE_2);
+      cmdpkt(rmesa, RADEON_EMIT_SE_TCL_MATERIAL_EMMISSIVE_RED);
+   rmesa->hw.txr[0].cmd[TXR_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_PP_TEX_SIZE_0);
+   rmesa->hw.txr[1].cmd[TXR_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_PP_TEX_SIZE_1);
+   rmesa->hw.txr[2].cmd[TXR_CMD_0] = cmdpkt(rmesa, RADEON_EMIT_PP_TEX_SIZE_2);
    rmesa->hw.grd.cmd[GRD_CMD_0] = 
       cmdscl( RADEON_SS_VERT_GUARD_CLIP_ADJ_ADDR, 1, 4 );
    rmesa->hw.fog.cmd[FOG_CMD_0] = 
@@ -331,6 +752,22 @@ void radeonInitState( radeonContextPtr rmesa )
         cmdvec( RADEON_VS_UCP_ADDR + i, 1, 4 );
    }
 
+   if (rmesa->radeon.radeonScreen->kernel_mm) {
+      rmesa->hw.grd.emit = scl_emit;
+      rmesa->hw.fog.emit = vec_emit;
+      rmesa->hw.glt.emit = vec_emit;
+      rmesa->hw.eye.emit = vec_emit;
+      
+      for (i = 0; i <= 6; i++)
+        rmesa->hw.mat[i].emit = vec_emit;
+
+      for (i = 0; i < 8; i++)
+        rmesa->hw.lit[i].emit = lit_emit;
+
+      for (i = 0; i < 6; i++)
+        rmesa->hw.ucp[i].emit = vec_emit;
+   }
+
    rmesa->last_ReallyEnabled = -1;
 
    /* Initial Harware state:
@@ -352,19 +789,7 @@ void radeonInitState( radeonContextPtr rmesa )
                                            RADEON_SRC_BLEND_GL_ONE |
                                            RADEON_DST_BLEND_GL_ZERO );
 
-   rmesa->hw.ctx.cmd[CTX_RB3D_DEPTHOFFSET] =
-      rmesa->radeonScreen->depthOffset + rmesa->radeonScreen->fbLocation;
-
-   rmesa->hw.ctx.cmd[CTX_RB3D_DEPTHPITCH] = 
-      ((rmesa->radeonScreen->depthPitch &
-       RADEON_DEPTHPITCH_MASK) |
-       RADEON_DEPTH_ENDIAN_NO_SWAP);
-       
-   if (rmesa->using_hyperz)
-       rmesa->hw.ctx.cmd[CTX_RB3D_DEPTHPITCH] |= RADEON_DEPTH_HYPERZ;
-
-   rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] = (depth_fmt |
-                                              RADEON_Z_TEST_LESS |
+   rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] = (RADEON_Z_TEST_LESS |
                                               RADEON_STENCIL_TEST_ALWAYS |
                                               RADEON_STENCIL_FAIL_KEEP |
                                               RADEON_STENCIL_ZPASS_KEEP |
@@ -374,7 +799,7 @@ void radeonInitState( radeonContextPtr rmesa )
    if (rmesa->using_hyperz) {
        rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_Z_COMPRESSION_ENABLE |
                                                   RADEON_Z_DECOMPRESSION_ENABLE;
-      if (rmesa->radeonScreen->chip_flags & RADEON_CHIPSET_TCL) {
+      if (rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL) {
         /* works for q3, but slight rendering errors with glxgears ? */
 /*      rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_Z_HIERARCHY_ENABLE;*/
         /* need this otherwise get lots of lockups with q3 ??? */
@@ -386,10 +811,9 @@ void radeonInitState( radeonContextPtr rmesa )
                                     RADEON_ANTI_ALIAS_NONE);
 
    rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] = (RADEON_PLANE_MASK_ENABLE |
-                                      color_fmt |
                                       RADEON_ZBLOCK16);
 
-   switch ( driQueryOptioni( &rmesa->optionCache, "dither_mode" ) ) {
+   switch ( driQueryOptioni( &rmesa->radeon.optionCache, "dither_mode" ) ) {
    case DRI_CONF_DITHER_XERRORDIFFRESET:
       rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_DITHER_INIT;
       break;
@@ -397,31 +821,18 @@ void radeonInitState( radeonContextPtr rmesa )
       rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_SCALE_DITHER_ENABLE;
       break;
    }
-   if ( driQueryOptioni( &rmesa->optionCache, "round_mode" ) ==
+   if ( driQueryOptioni( &rmesa->radeon.optionCache, "round_mode" ) ==
        DRI_CONF_ROUND_ROUND )
-      rmesa->state.color.roundEnable = RADEON_ROUND_ENABLE;
+      rmesa->radeon.state.color.roundEnable = RADEON_ROUND_ENABLE;
    else
-      rmesa->state.color.roundEnable = 0;
-   if ( driQueryOptioni (&rmesa->optionCache, "color_reduction" ) ==
+      rmesa->radeon.state.color.roundEnable = 0;
+   if ( driQueryOptioni (&rmesa->radeon.optionCache, "color_reduction" ) ==
        DRI_CONF_COLOR_REDUCTION_DITHER )
       rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_DITHER_ENABLE;
    else
-      rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= rmesa->state.color.roundEnable;
-
-   rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = ((drawOffset +
-                                              rmesa->radeonScreen->fbLocation)
-                                             & RADEON_COLOROFFSET_MASK);
-
-   rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = ((drawPitch &
-                                             RADEON_COLORPITCH_MASK) |
-                                            RADEON_COLOR_ENDIAN_NO_SWAP);
+      rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= rmesa->radeon.state.color.roundEnable;
 
 
-   /* (fixed size) sarea is initialized to zero afaics so can omit version check. Phew! */
-   if (rmesa->sarea->tiling_enabled) {
-      rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= RADEON_COLOR_TILE_ENABLE;
-   }
-
    rmesa->hw.set.cmd[SET_SE_CNTL] = (RADEON_FFACE_CULL_CCW |
                                     RADEON_BFACE_SOLID |
                                     RADEON_FFACE_SOLID |
@@ -444,7 +855,7 @@ void radeonInitState( radeonContextPtr rmesa )
                                            RADEON_VC_NO_SWAP;
 #endif
 
-   if (!(rmesa->radeonScreen->chip_flags & RADEON_CHIPSET_TCL)) {
+   if (!(rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL)) {
      rmesa->hw.set.cmd[SET_SE_CNTL_STATUS] |= RADEON_TCL_BYPASS;
    }
 
@@ -491,8 +902,8 @@ void radeonInitState( radeonContextPtr rmesa )
           (2 << RADEON_TXFORMAT_HEIGHT_SHIFT));
 
       /* Initialize the texture offset to the start of the card texture heap */
-      rmesa->hw.tex[i].cmd[TEX_PP_TXOFFSET] =
-         rmesa->radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP];
+      //      rmesa->hw.tex[i].cmd[TEX_PP_TXOFFSET] =
+      //         rmesa->radeon.radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP];
 
       rmesa->hw.tex[i].cmd[TEX_PP_BORDER_COLOR] = 0;
       rmesa->hw.tex[i].cmd[TEX_PP_TXCBLEND] =  
@@ -513,15 +924,15 @@ void radeonInitState( radeonContextPtr rmesa )
 
       rmesa->hw.cube[i].cmd[CUBE_PP_CUBIC_FACES] = 0;
       rmesa->hw.cube[i].cmd[CUBE_PP_CUBIC_OFFSET_0] =
-         rmesa->radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP];
+         rmesa->radeon.radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP];
       rmesa->hw.cube[i].cmd[CUBE_PP_CUBIC_OFFSET_1] =
-         rmesa->radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP];
+         rmesa->radeon.radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP];
       rmesa->hw.cube[i].cmd[CUBE_PP_CUBIC_OFFSET_2] =
-         rmesa->radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP];
+         rmesa->radeon.radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP];
       rmesa->hw.cube[i].cmd[CUBE_PP_CUBIC_OFFSET_3] =
-         rmesa->radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP];
+         rmesa->radeon.radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP];
       rmesa->hw.cube[i].cmd[CUBE_PP_CUBIC_OFFSET_4] =
-         rmesa->radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP];
+         rmesa->radeon.radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP];
    }
 
    /* Can only add ST1 at the time of doing some multitex but can keep
@@ -613,5 +1024,7 @@ void radeonInitState( radeonContextPtr rmesa )
    rmesa->hw.eye.cmd[EYE_Z] = IEEE_ONE;
    rmesa->hw.eye.cmd[EYE_RESCALE_FACTOR] = IEEE_ONE;
    
-   rmesa->hw.all_dirty = GL_TRUE;
+   rmesa->radeon.hw.all_dirty = GL_TRUE;
+
+   rcommonInitCmdBuf(&rmesa->radeon);
 }
index ebea1fecdca5bbcc7506a19557dd7c894455f464..e31f045991ca994a008b7a48d6c79007c0a12268 100644 (file)
@@ -52,8 +52,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "radeon_tcl.h"
 
 
-static void flush_last_swtcl_prim( radeonContextPtr rmesa  );
-
 /* R100: xyzw, c0, c1/fog, stq[0..2]  = 4+1+1+3*3 = 15  right? */
 /* R200: xyzw, c0, c1/fog, strq[0..5] = 4+1+1+4*6 = 30 */
 #define RADEON_MAX_TNL_VERTEX_SIZE (15 * sizeof(GLfloat))      /* for mesa _tnl stage */
@@ -64,18 +62,18 @@ static void flush_last_swtcl_prim( radeonContextPtr rmesa  );
 
 #define EMIT_ATTR( ATTR, STYLE, F0 )                                   \
 do {                                                                   \
-   rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].attrib = (ATTR);  \
-   rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].format = (STYLE); \
-   rmesa->swtcl.vertex_attr_count++;                                   \
+   rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].attrib = (ATTR);    \
+   rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].format = (STYLE);   \
+   rmesa->radeon.swtcl.vertex_attr_count++;                                    \
    fmt_0 |= F0;                                                                \
 } while (0)
 
 #define EMIT_PAD( N )                                                  \
 do {                                                                   \
-   rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].attrib = 0;               \
-   rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].format = EMIT_PAD;        \
-   rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].offset = (N);             \
-   rmesa->swtcl.vertex_attr_count++;                                   \
+   rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].attrib = 0;         \
+   rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].format = EMIT_PAD;  \
+   rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].offset = (N);               \
+   rmesa->radeon.swtcl.vertex_attr_count++;                                    \
 } while (0)
 
 static GLuint radeon_cp_vc_frmts[3][2] =
@@ -87,7 +85,7 @@ static GLuint radeon_cp_vc_frmts[3][2] =
 
 static void radeonSetVertexFormat( GLcontext *ctx )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+   r100ContextPtr rmesa = R100_CONTEXT( ctx );
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct vertex_buffer *VB = &tnl->vb;
    DECLARE_RENDERINPUTS(index_bitset);
@@ -106,7 +104,7 @@ static void radeonSetVertexFormat( GLcontext *ctx )
    }
 
    assert( VB->AttribPtr[VERT_ATTRIB_POS] != NULL );
-   rmesa->swtcl.vertex_attr_count = 0;
+   rmesa->radeon.swtcl.vertex_attr_count = 0;
 
    /* EMIT_ATTR's must be in order as they tell t_vertex.c how to
     * build up a hardware vertex.
@@ -204,33 +202,33 @@ static void radeonSetVertexFormat( GLcontext *ctx )
       }
    }
 
-   if (!RENDERINPUTS_EQUAL( rmesa->tnl_index_bitset, index_bitset ) ||
+   if (!RENDERINPUTS_EQUAL( rmesa->radeon.tnl_index_bitset, index_bitset ) ||
        fmt_0 != rmesa->swtcl.vertex_format) {
       RADEON_NEWPRIM(rmesa);
       rmesa->swtcl.vertex_format = fmt_0;
-      rmesa->swtcl.vertex_size =
+      rmesa->radeon.swtcl.vertex_size =
          _tnl_install_attrs( ctx,
-                             rmesa->swtcl.vertex_attrs, 
-                             rmesa->swtcl.vertex_attr_count,
+                             rmesa->radeon.swtcl.vertex_attrs, 
+                             rmesa->radeon.swtcl.vertex_attr_count,
                              NULL, 0 );
-      rmesa->swtcl.vertex_size /= 4;
-      RENDERINPUTS_COPY( rmesa->tnl_index_bitset, index_bitset );
+      rmesa->radeon.swtcl.vertex_size /= 4;
+      RENDERINPUTS_COPY( rmesa->radeon.tnl_index_bitset, index_bitset );
       if (RADEON_DEBUG & DEBUG_VERTS)
         fprintf( stderr, "%s: vertex_size= %d floats\n",
-                 __FUNCTION__, rmesa->swtcl.vertex_size);
+                 __FUNCTION__, rmesa->radeon.swtcl.vertex_size);
    }
 }
 
 
 static void radeonRenderStart( GLcontext *ctx )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+   r100ContextPtr rmesa = R100_CONTEXT( ctx );
 
    radeonSetVertexFormat( ctx );
    
-   if (rmesa->dma.flush != 0 && 
-       rmesa->dma.flush != flush_last_swtcl_prim)
-      rmesa->dma.flush( rmesa );
+   if (rmesa->radeon.dma.flush != 0 && 
+       rmesa->radeon.dma.flush != rcommon_flush_last_swtcl_prim)
+      rmesa->radeon.dma.flush( ctx );
 }
 
 
@@ -241,7 +239,7 @@ static void radeonRenderStart( GLcontext *ctx )
  */
 void radeonChooseVertexState( GLcontext *ctx )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+   r100ContextPtr rmesa = R100_CONTEXT( ctx );
    TNLcontext *tnl = TNL_CONTEXT(ctx);
 
    GLuint se_coord_fmt = rmesa->hw.set.cmd[SET_SE_COORDFMT];
@@ -254,7 +252,7 @@ void radeonChooseVertexState( GLcontext *ctx )
     * rasterization fallback.  As this function will be called again when we
     * leave a rasterization fallback, we can just skip it for now.
     */
-   if (rmesa->Fallback != 0)
+   if (rmesa->radeon.Fallback != 0)
       return;
 
    /* HW perspective divide is a win, but tiny vertex formats are a
@@ -281,80 +279,29 @@ void radeonChooseVertexState( GLcontext *ctx )
    }
 }
 
-
-/* Flush vertices in the current dma region.
- */
-static void flush_last_swtcl_prim( radeonContextPtr rmesa  )
+void r100_swtcl_flush(GLcontext *ctx, uint32_t current_offset)
 {
-   if (RADEON_DEBUG & DEBUG_IOCTL)
-      fprintf(stderr, "%s\n", __FUNCTION__);
-
-   rmesa->dma.flush = NULL;
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
 
-   if (rmesa->dma.current.buf) {
-      struct radeon_dma_region *current = &rmesa->dma.current;
-      GLuint current_offset = (rmesa->radeonScreen->gart_buffer_offset +
-                              current->buf->buf->idx * RADEON_BUFFER_SIZE + 
-                              current->start);
+   rcommonEnsureCmdBufSpace(&rmesa->radeon,
+                           rmesa->radeon.hw.max_state_size + (12*sizeof(int)),
+                           __FUNCTION__);
 
-      assert (!(rmesa->swtcl.hw_primitive & RADEON_CP_VC_CNTL_PRIM_WALK_IND));
 
-      assert (current->start + 
-             rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 ==
-             current->ptr);
+   radeonEmitState(&rmesa->radeon);
+   radeonEmitVertexAOS( rmesa,
+                       rmesa->radeon.swtcl.vertex_size,
+                       rmesa->radeon.dma.current,
+                       current_offset);
 
-      if (rmesa->dma.current.start != rmesa->dma.current.ptr) {
-        radeonEnsureCmdBufSpace( rmesa, VERT_AOS_BUFSZ +
-                                 rmesa->hw.max_state_size + VBUF_BUFSZ );
-
-        radeonEmitVertexAOS( rmesa,
-                             rmesa->swtcl.vertex_size,
-                             current_offset);
-
-        radeonEmitVbufPrim( rmesa,
-                            rmesa->swtcl.vertex_format,
-                            rmesa->swtcl.hw_primitive,
-                            rmesa->swtcl.numverts);
-      }
+                     
+   radeonEmitVbufPrim( rmesa,
+                      rmesa->swtcl.vertex_format,
+                      rmesa->radeon.swtcl.hw_primitive,
+                      rmesa->radeon.swtcl.numverts);
 
-      rmesa->swtcl.numverts = 0;
-      current->start = current->ptr;
-   }
 }
 
-
-/* Alloc space in the current dma region.
- */
-static INLINE void *
-radeonAllocDmaLowVerts( radeonContextPtr rmesa, int nverts, int vsize )
-{
-   GLuint bytes = vsize * nverts;
-
-   if ( rmesa->dma.current.ptr + bytes > rmesa->dma.current.end ) 
-      radeonRefillCurrentDmaRegion( rmesa );
-
-   if (!rmesa->dma.flush) {
-      rmesa->glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
-      rmesa->dma.flush = flush_last_swtcl_prim;
-   }
-
-   assert( vsize == rmesa->swtcl.vertex_size * 4 );
-   assert( rmesa->dma.flush == flush_last_swtcl_prim );
-   assert (rmesa->dma.current.start + 
-          rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 ==
-          rmesa->dma.current.ptr);
-
-
-   {
-      GLubyte *head = (GLubyte *)(rmesa->dma.current.address + rmesa->dma.current.ptr);
-      rmesa->dma.current.ptr += bytes;
-      rmesa->swtcl.numverts += nverts;
-      return head;
-   }
-
-}
-
-
 /*
  * Render unclipped vertex buffers by emitting vertices directly to
  * dma buffers.  Use strip/fan hardware primitives where possible.
@@ -387,22 +334,22 @@ static const GLuint hw_prim[GL_POLYGON+1] = {
 };
 
 static INLINE void
-radeonDmaPrimitive( radeonContextPtr rmesa, GLenum prim )
+radeonDmaPrimitive( r100ContextPtr rmesa, GLenum prim )
 {
    RADEON_NEWPRIM( rmesa );
-   rmesa->swtcl.hw_primitive = hw_prim[prim];
-   assert(rmesa->dma.current.ptr == rmesa->dma.current.start);
+   rmesa->radeon.swtcl.hw_primitive = hw_prim[prim];
+   //   assert(rmesa->radeon.dma.current.ptr == rmesa->radeon.dma.current.start);
 }
 
-#define LOCAL_VARS radeonContextPtr rmesa = RADEON_CONTEXT(ctx)
+#define LOCAL_VARS r100ContextPtr rmesa = R100_CONTEXT(ctx)
 #define INIT( prim ) radeonDmaPrimitive( rmesa, prim )
 #define FLUSH()  RADEON_NEWPRIM( rmesa )
-#define GET_CURRENT_VB_MAX_VERTS() \
-  (((int)rmesa->dma.current.end - (int)rmesa->dma.current.ptr) / (rmesa->swtcl.vertex_size*4))
+#define GET_CURRENT_VB_MAX_VERTS()                                     10\
+//  (((int)rmesa->radeon.dma.current.end - (int)rmesa->radeon.dma.current.ptr) / (rmesa->radeon.swtcl.vertex_size*4))
 #define GET_SUBSEQUENT_VB_MAX_VERTS() \
-  ((RADEON_BUFFER_SIZE) / (rmesa->swtcl.vertex_size*4))
+  ((RADEON_BUFFER_SIZE) / (rmesa->radeon.swtcl.vertex_size*4))
 #define ALLOC_VERTS( nr ) \
-  radeonAllocDmaLowVerts( rmesa, nr, rmesa->swtcl.vertex_size * 4 )
+  rcommonAllocDmaLowVerts( &rmesa->radeon, nr, rmesa->radeon.swtcl.vertex_size * 4 )
 #define EMIT_VERTS( ctx, j, nr, buf ) \
   _tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf)
 
@@ -418,16 +365,13 @@ radeonDmaPrimitive( radeonContextPtr rmesa, GLenum prim )
 static GLboolean radeon_run_render( GLcontext *ctx,
                                    struct tnl_pipeline_stage *stage )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct vertex_buffer *VB = &tnl->vb;
    tnl_render_func *tab = TAG(render_tab_verts);
    GLuint i;
 
-   if (rmesa->swtcl.indexed_verts.buf) 
-      RELEASE_ELT_VERTS();
-       
-   if (rmesa->swtcl.RenderIndex != 0 ||   
+   if (rmesa->radeon.swtcl.RenderIndex != 0 ||   
        !radeon_dma_validate_render( ctx, VB ))
       return GL_TRUE;          
 
@@ -496,13 +440,13 @@ static void radeonResetLineStipple( GLcontext *ctx );
 
 #undef LOCAL_VARS
 #undef ALLOC_VERTS
-#define CTX_ARG radeonContextPtr rmesa
-#define GET_VERTEX_DWORDS() rmesa->swtcl.vertex_size
-#define ALLOC_VERTS( n, size ) radeonAllocDmaLowVerts( rmesa, n, (size) * 4 )
+#define CTX_ARG r100ContextPtr rmesa
+#define GET_VERTEX_DWORDS() rmesa->radeon.swtcl.vertex_size
+#define ALLOC_VERTS( n, size ) rcommonAllocDmaLowVerts( &rmesa->radeon, n, (size) * 4 )
 #undef LOCAL_VARS
 #define LOCAL_VARS                                             \
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);               \
-   const char *radeonverts = (char *)rmesa->swtcl.verts;
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);           \
+   const char *radeonverts = (char *)rmesa->radeon.swtcl.verts;
 #define VERT(x) (radeonVertex *)(radeonverts + ((x) * (vertsize) * sizeof(int)))
 #define VERTEX radeonVertex 
 #undef TAG
@@ -560,7 +504,7 @@ static struct {
 #define VERT_Y(_v) _v->v.y
 #define VERT_Z(_v) _v->v.z
 #define AREA_IS_CCW( a ) (a < 0)
-#define GET_VERTEX(e) (rmesa->swtcl.verts + ((e) * rmesa->swtcl.vertex_size * sizeof(int)))
+#define GET_VERTEX(e) (rmesa->radeon.swtcl.verts + ((e) * rmesa->radeon.swtcl.vertex_size * sizeof(int)))
 
 #define VERT_SET_RGBA( v, c )                                          \
 do {                                                           \
@@ -606,7 +550,7 @@ do {                                                        \
 #undef INIT
 
 #define LOCAL_VARS(n)                                                  \
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);                       \
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);                   \
    GLuint color[n], spec[n];                                           \
    GLuint coloroffset = rmesa->swtcl.coloroffset;      \
    GLuint specoffset = rmesa->swtcl.specoffset;                        \
@@ -617,7 +561,7 @@ do {                                                        \
  ***********************************************************************/
 
 #define RASTERIZE(x) radeonRasterPrimitive( ctx, reduced_hw_prim[x] )
-#define RENDER_PRIMITIVE rmesa->swtcl.render_primitive
+#define RENDER_PRIMITIVE rmesa->radeon.swtcl.render_primitive
 #undef TAG
 #define TAG(x) x
 #include "tnl_dd/t_dd_unfilled.h"
@@ -673,9 +617,9 @@ static void init_rast_tab( void )
 } while (0)
 #undef LOCAL_VARS
 #define LOCAL_VARS                                             \
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);               \
-   const GLuint vertsize = rmesa->swtcl.vertex_size;           \
-   const char *radeonverts = (char *)rmesa->swtcl.verts;               \
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);           \
+   const GLuint vertsize = rmesa->radeon.swtcl.vertex_size;            \
+   const char *radeonverts = (char *)rmesa->radeon.swtcl.verts;                \
    const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts;       \
    const GLboolean stipple = ctx->Line.StippleFlag;            \
    (void) elt; (void) stipple;
@@ -700,17 +644,17 @@ static void init_rast_tab( void )
 void radeonChooseRenderState( GLcontext *ctx )
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLuint index = 0;
    GLuint flags = ctx->_TriangleCaps;
 
-   if (!rmesa->TclFallback || rmesa->Fallback) 
+   if (!rmesa->radeon.TclFallback || rmesa->radeon.Fallback) 
       return;
 
    if (flags & DD_TRI_LIGHT_TWOSIDE) index |= RADEON_TWOSIDE_BIT;
    if (flags & DD_TRI_UNFILLED)      index |= RADEON_UNFILLED_BIT;
 
-   if (index != rmesa->swtcl.RenderIndex) {
+   if (index != rmesa->radeon.swtcl.RenderIndex) {
       tnl->Driver.Render.Points = rast_tab[index].points;
       tnl->Driver.Render.Line = rast_tab[index].line;
       tnl->Driver.Render.ClippedLine = rast_tab[index].line;
@@ -727,7 +671,7 @@ void radeonChooseRenderState( GLcontext *ctx )
         tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon;
       }
 
-      rmesa->swtcl.RenderIndex = index;
+      rmesa->radeon.swtcl.RenderIndex = index;
    }
 }
 
@@ -739,18 +683,18 @@ void radeonChooseRenderState( GLcontext *ctx )
 
 static void radeonRasterPrimitive( GLcontext *ctx, GLuint hwprim )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
 
-   if (rmesa->swtcl.hw_primitive != hwprim) {
+   if (rmesa->radeon.swtcl.hw_primitive != hwprim) {
       RADEON_NEWPRIM( rmesa );
-      rmesa->swtcl.hw_primitive = hwprim;
+      rmesa->radeon.swtcl.hw_primitive = hwprim;
    }
 }
 
 static void radeonRenderPrimitive( GLcontext *ctx, GLenum prim )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-   rmesa->swtcl.render_primitive = prim;
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
+   rmesa->radeon.swtcl.render_primitive = prim;
    if (prim < GL_TRIANGLES || !(ctx->_TriangleCaps & DD_TRI_UNFILLED)) 
       radeonRasterPrimitive( ctx, reduced_hw_prim[prim] );
 }
@@ -761,7 +705,7 @@ static void radeonRenderFinish( GLcontext *ctx )
 
 static void radeonResetLineStipple( GLcontext *ctx )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    RADEON_STATECHANGE( rmesa, lin );
 }
 
@@ -795,17 +739,17 @@ static const char *getFallbackString(GLuint bit)
 
 void radeonFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
-   GLuint oldfallback = rmesa->Fallback;
+   GLuint oldfallback = rmesa->radeon.Fallback;
 
    if (mode) {
-      rmesa->Fallback |= bit;
+      rmesa->radeon.Fallback |= bit;
       if (oldfallback == 0) {
-        RADEON_FIREVERTICES( rmesa );
+        radeon_firevertices(&rmesa->radeon);
         TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_RASTER, GL_TRUE );
         _swsetup_Wakeup( ctx );
-        rmesa->swtcl.RenderIndex = ~0;
+        rmesa->radeon.swtcl.RenderIndex = ~0;
          if (RADEON_DEBUG & DEBUG_FALLBACKS) {
             fprintf(stderr, "Radeon begin rasterization fallback: 0x%x %s\n",
                     bit, getFallbackString(bit));
@@ -813,7 +757,7 @@ void radeonFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
       }
    }
    else {
-      rmesa->Fallback &= ~bit;
+      rmesa->radeon.Fallback &= ~bit;
       if (oldfallback == bit) {
         _swrast_flush( ctx );
         tnl->Driver.Render.Start = radeonRenderStart;
@@ -826,14 +770,14 @@ void radeonFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
 
         tnl->Driver.Render.ResetLineStipple = radeonResetLineStipple;
         TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_RASTER, GL_FALSE );
-        if (rmesa->TclFallback) {
-           /* These are already done if rmesa->TclFallback goes to
+        if (rmesa->radeon.TclFallback) {
+           /* These are already done if rmesa->radeon.TclFallback goes to
             * zero above. But not if it doesn't (RADEON_NO_TCL for
             * example?)
             */
            _tnl_invalidate_vertex_state( ctx, ~0 );
            _tnl_invalidate_vertices( ctx, ~0 );
-           RENDERINPUTS_ZERO( rmesa->tnl_index_bitset );
+           RENDERINPUTS_ZERO( rmesa->radeon.tnl_index_bitset );
            radeonChooseVertexState( ctx );
            radeonChooseRenderState( ctx );
         }
@@ -853,7 +797,7 @@ void radeonFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
 void radeonInitSwtcl( GLcontext *ctx )
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    static int firsttime = 1;
 
    if (firsttime) {
@@ -872,18 +816,9 @@ void radeonInitSwtcl( GLcontext *ctx )
    _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12, 
                       RADEON_MAX_TNL_VERTEX_SIZE);
    
-   rmesa->swtcl.verts = (GLubyte *)tnl->clipspace.vertex_buf;
-   rmesa->swtcl.RenderIndex = ~0;
-   rmesa->swtcl.render_primitive = GL_TRIANGLES;
-   rmesa->swtcl.hw_primitive = 0;
+   rmesa->radeon.swtcl.verts = (GLubyte *)tnl->clipspace.vertex_buf;
+   rmesa->radeon.swtcl.RenderIndex = ~0;
+   rmesa->radeon.swtcl.render_primitive = GL_TRIANGLES;
+   rmesa->radeon.swtcl.hw_primitive = 0;
 }
 
-
-void radeonDestroySwtcl( GLcontext *ctx )
-{
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
-   if (rmesa->swtcl.indexed_verts.buf) 
-      radeonReleaseDmaRegion( rmesa, &rmesa->swtcl.indexed_verts, 
-                             __FUNCTION__ );
-}
index e485052ad7746ca951da2ecb6ceffb2f2faf2ea8..da89158eeb9d13060b28819eb5466dfecfc74255 100644 (file)
@@ -40,7 +40,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "radeon_context.h"
 
 extern void radeonInitSwtcl( GLcontext *ctx );
-extern void radeonDestroySwtcl( GLcontext *ctx );
 
 extern void radeonChooseRenderState( GLcontext *ctx );
 extern void radeonChooseVertexState( GLcontext *ctx );
@@ -63,5 +62,5 @@ extern void radeon_translate_vertex( GLcontext *ctx,
 
 extern void radeon_print_vertex( GLcontext *ctx, const radeonVertex *v );
 
-
+extern void r100_swtcl_flush(GLcontext *ctx, uint32_t current_offset);
 #endif
index 779e9ae5df04a2b2d0d9b7602d361fc552b7029a..df6708f05e35dfc9a834651ecd79fad92afe1d60 100644 (file)
@@ -42,6 +42,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "tnl/tnl.h"
 #include "tnl/t_pipeline.h"
 
+#include "radeon_common.h"
 #include "radeon_context.h"
 #include "radeon_state.h"
 #include "radeon_ioctl.h"
@@ -104,7 +105,7 @@ static GLboolean discrete_prim[0x10] = {
 };
    
 
-#define LOCAL_VARS radeonContextPtr rmesa = RADEON_CONTEXT(ctx)
+#define LOCAL_VARS r100ContextPtr rmesa = R100_CONTEXT(ctx)
 #define ELT_TYPE  GLushort
 
 #define ELT_INIT(prim, hw_prim) \
@@ -125,7 +126,7 @@ static GLboolean discrete_prim[0x10] = {
 
 #define RESET_STIPPLE() do {                   \
    RADEON_STATECHANGE( rmesa, lin );           \
-   radeonEmitState( rmesa );                   \
+   radeonEmitState(&rmesa->radeon);                    \
 } while (0)
 
 #define AUTO_STIPPLE( mode )  do {             \
@@ -136,31 +137,29 @@ static GLboolean discrete_prim[0x10] = {
    else                                                \
       rmesa->hw.lin.cmd[LIN_RE_LINE_PATTERN] &=        \
         ~RADEON_LINE_PATTERN_AUTO_RESET;       \
-   radeonEmitState( rmesa );                   \
+   radeonEmitState(&rmesa->radeon);            \
 } while (0)
 
 
 
 #define ALLOC_ELTS(nr) radeonAllocElts( rmesa, nr )
 
-static GLushort *radeonAllocElts( radeonContextPtr rmesa, GLuint nr ) 
+static GLushort *radeonAllocElts( r100ContextPtr rmesa, GLuint nr ) 
 {
-   if (rmesa->dma.flush)
-      rmesa->dma.flush( rmesa );
+      if (rmesa->radeon.dma.flush)
+        rmesa->radeon.dma.flush( rmesa->radeon.glCtx );
 
-   radeonEnsureCmdBufSpace(rmesa, AOS_BUFSZ(rmesa->tcl.nr_aos_components) +
-                          rmesa->hw.max_state_size + ELTS_BUFSZ(nr));
+      rcommonEnsureCmdBufSpace(&rmesa->radeon, rmesa->radeon.hw.max_state_size + ELTS_BUFSZ(nr) + 
+                              AOS_BUFSZ(rmesa->radeon.tcl.aos_count), __FUNCTION__);
 
-   radeonEmitAOS( rmesa,
-               rmesa->tcl.aos_components,
-               rmesa->tcl.nr_aos_components, 0 );
+      radeonEmitAOS( rmesa,
+                    rmesa->radeon.tcl.aos_count, 0 );
 
-   return radeonAllocEltsOpenEnded( rmesa,
-                                   rmesa->tcl.vertex_format, 
-                                   rmesa->tcl.hw_primitive, nr );
+      return radeonAllocEltsOpenEnded( rmesa, rmesa->tcl.vertex_format,
+                                      rmesa->tcl.hw_primitive, nr );
 }
 
-#define CLOSE_ELTS()  RADEON_NEWPRIM( rmesa )
+#define CLOSE_ELTS() if (0)  RADEON_NEWPRIM( rmesa )
 
 
 
@@ -174,15 +173,15 @@ static void radeonEmitPrim( GLcontext *ctx,
                       GLuint start, 
                       GLuint count)    
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+   r100ContextPtr rmesa = R100_CONTEXT( ctx );
    radeonTclPrimitive( ctx, prim, hwprim );
    
-   radeonEnsureCmdBufSpace( rmesa, AOS_BUFSZ(rmesa->tcl.nr_aos_components) +
-                           rmesa->hw.max_state_size + VBUF_BUFSZ );
+   rcommonEnsureCmdBufSpace( &rmesa->radeon,
+                            AOS_BUFSZ(rmesa->radeon.tcl.aos_count) +
+                            rmesa->radeon.hw.max_state_size + VBUF_BUFSZ, __FUNCTION__ );
 
    radeonEmitAOS( rmesa,
-                 rmesa->tcl.aos_components,
-                 rmesa->tcl.nr_aos_components,
+                 rmesa->radeon.tcl.aos_count,
                  start );
    
    /* Why couldn't this packet have taken an offset param?
@@ -254,7 +253,7 @@ void radeonTclPrimitive( GLcontext *ctx,
                         GLenum prim,
                         int hw_prim )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLuint se_cntl;
    GLuint newprim = hw_prim | RADEON_CP_VC_CNTL_TCL_ENABLE;
 
@@ -371,7 +370,7 @@ radeonComputeFogBlendFactor( GLcontext *ctx, GLfloat fogcoord )
 static GLboolean radeon_run_tcl_render( GLcontext *ctx,
                                        struct tnl_pipeline_stage *stage )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct vertex_buffer *VB = &tnl->vb;
    GLuint inputs = VERT_BIT_POS | VERT_BIT_COLOR0;
@@ -379,7 +378,7 @@ static GLboolean radeon_run_tcl_render( GLcontext *ctx,
 
    /* TODO: separate this from the swtnl pipeline 
     */
-   if (rmesa->TclFallback)
+   if (rmesa->radeon.TclFallback)
       return GL_TRUE;  /* fallback to software t&l */
 
    if (VB->Count == 0)
@@ -461,7 +460,7 @@ const struct tnl_pipeline_stage _radeon_tcl_stage =
 
 static void transition_to_swtnl( GLcontext *ctx )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    GLuint se_cntl;
 
@@ -490,7 +489,7 @@ static void transition_to_swtnl( GLcontext *ctx )
 
 static void transition_to_hwtnl( GLcontext *ctx )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    GLuint se_coord_fmt = rmesa->hw.set.cmd[SET_SE_COORDFMT];
 
@@ -509,15 +508,15 @@ static void transition_to_hwtnl( GLcontext *ctx )
 
    tnl->Driver.NotifyMaterialChange = radeonUpdateMaterial;
 
-   if ( rmesa->dma.flush )                     
-      rmesa->dma.flush( rmesa );       
+   if ( rmesa->radeon.dma.flush )                      
+      rmesa->radeon.dma.flush( rmesa->radeon.glCtx );  
 
-   rmesa->dma.flush = NULL;
+   rmesa->radeon.dma.flush = NULL;
    rmesa->swtcl.vertex_format = 0;
    
-   if (rmesa->swtcl.indexed_verts.buf) 
-      radeonReleaseDmaRegion( rmesa, &rmesa->swtcl.indexed_verts, 
-                             __FUNCTION__ );
+   //   if (rmesa->swtcl.indexed_verts.buf) 
+   //      radeonReleaseDmaRegion( rmesa, &rmesa->swtcl.indexed_verts, 
+   //                        __FUNCTION__ );
 
    if (RADEON_DEBUG & DEBUG_FALLBACKS) 
       fprintf(stderr, "Radeon end tcl fallback\n");
@@ -550,11 +549,11 @@ static char *getFallbackString(GLuint bit)
 
 void radeonTclFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-   GLuint oldfallback = rmesa->TclFallback;
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
+   GLuint oldfallback = rmesa->radeon.TclFallback;
 
    if (mode) {
-      rmesa->TclFallback |= bit;
+      rmesa->radeon.TclFallback |= bit;
       if (oldfallback == 0) {
         if (RADEON_DEBUG & DEBUG_FALLBACKS) 
            fprintf(stderr, "Radeon begin tcl fallback %s\n",
@@ -563,7 +562,7 @@ void radeonTclFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
       }
    }
    else {
-      rmesa->TclFallback &= ~bit;
+      rmesa->radeon.TclFallback &= ~bit;
       if (oldfallback == bit) {
         if (RADEON_DEBUG & DEBUG_FALLBACKS) 
            fprintf(stderr, "Radeon end tcl fallback %s\n",
index f2b6deb9c0465d16b53d99299f5d10eb8a595321..2549d5cb5cbfbfc2370958700912f62c1e7de965 100644 (file)
@@ -44,6 +44,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/texobj.h"
 
 #include "radeon_context.h"
+#include "radeon_mipmap_tree.h"
 #include "radeon_state.h"
 #include "radeon_ioctl.h"
 #include "radeon_swtcl.h"
@@ -170,10 +171,13 @@ static void radeonSetTexFilter( radeonTexObjPtr t, GLenum minf, GLenum magf )
 {
    GLuint anisotropy = (t->pp_txfilter & RADEON_MAX_ANISO_MASK);
 
+   /* Force revalidation to account for switches from/to mipmapping. */
+   t->validated = GL_FALSE;
+
    t->pp_txfilter &= ~(RADEON_MIN_FILTER_MASK | RADEON_MAG_FILTER_MASK);
 
    /* r100 chips can't handle mipmaps/aniso for cubemap/volume textures */
-   if ( t->base.tObj->Target == GL_TEXTURE_CUBE_MAP ) {
+   if ( t->base.Target == GL_TEXTURE_CUBE_MAP ) {
       switch ( minf ) {
       case GL_NEAREST:
       case GL_NEAREST_MIPMAP_NEAREST:
@@ -249,433 +253,13 @@ static void radeonSetTexBorderColor( radeonTexObjPtr t, const GLfloat color[4] )
    t->pp_border_color = radeonPackColor( 4, c[0], c[1], c[2], c[3] );
 }
 
-
-/**
- * Allocate space for and load the mesa images into the texture memory block.
- * This will happen before drawing with a new texture, or drawing with a
- * texture after it was swapped out or teximaged again.
- */
-
-static radeonTexObjPtr radeonAllocTexObj( struct gl_texture_object *texObj )
-{
-   radeonTexObjPtr t;
-
-   t = CALLOC_STRUCT( radeon_tex_obj );
-   texObj->DriverData = t;
-   if ( t != NULL ) {
-      if ( RADEON_DEBUG & DEBUG_TEXTURE ) {
-        fprintf( stderr, "%s( %p, %p )\n", __FUNCTION__, (void *)texObj, (void *)t );
-      }
-
-      /* Initialize non-image-dependent parts of the state:
-       */
-      t->base.tObj = texObj;
-      t->border_fallback = GL_FALSE;
-
-      t->pp_txfilter = RADEON_BORDER_MODE_OGL;
-      t->pp_txformat = (RADEON_TXFORMAT_ENDIAN_NO_SWAP |
-                       RADEON_TXFORMAT_PERSPECTIVE_ENABLE);
-
-      make_empty_list( & t->base );
-
-      radeonSetTexWrap( t, texObj->WrapS, texObj->WrapT );
-      radeonSetTexMaxAnisotropy( t, texObj->MaxAnisotropy );
-      radeonSetTexFilter( t, texObj->MinFilter, texObj->MagFilter );
-      radeonSetTexBorderColor( t, texObj->BorderColor );
-   }
-
-   return t;
-}
-
-
-static const struct gl_texture_format *
-radeonChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
-                           GLenum format, GLenum type )
-{
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-   const GLboolean do32bpt =
-       ( rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32 );
-   const GLboolean force16bpt =
-       ( rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16 );
-   (void) format;
-
-   switch ( internalFormat ) {
-   case 4:
-   case GL_RGBA:
-   case GL_COMPRESSED_RGBA:
-      switch ( type ) {
-      case GL_UNSIGNED_INT_10_10_10_2:
-      case GL_UNSIGNED_INT_2_10_10_10_REV:
-        return do32bpt ? _dri_texformat_argb8888 : _dri_texformat_argb1555;
-      case GL_UNSIGNED_SHORT_4_4_4_4:
-      case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-        return _dri_texformat_argb4444;
-      case GL_UNSIGNED_SHORT_5_5_5_1:
-      case GL_UNSIGNED_SHORT_1_5_5_5_REV:
-        return _dri_texformat_argb1555;
-      default:
-         return do32bpt ? _dri_texformat_argb8888 : _dri_texformat_argb4444;
-      }
-
-   case 3:
-   case GL_RGB:
-   case GL_COMPRESSED_RGB:
-      switch ( type ) {
-      case GL_UNSIGNED_SHORT_4_4_4_4:
-      case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-        return _dri_texformat_argb4444;
-      case GL_UNSIGNED_SHORT_5_5_5_1:
-      case GL_UNSIGNED_SHORT_1_5_5_5_REV:
-        return _dri_texformat_argb1555;
-      case GL_UNSIGNED_SHORT_5_6_5:
-      case GL_UNSIGNED_SHORT_5_6_5_REV:
-        return _dri_texformat_rgb565;
-      default:
-         return do32bpt ? _dri_texformat_argb8888 : _dri_texformat_rgb565;
-      }
-
-   case GL_RGBA8:
-   case GL_RGB10_A2:
-   case GL_RGBA12:
-   case GL_RGBA16:
-      return !force16bpt ?
-         _dri_texformat_argb8888 : _dri_texformat_argb4444;
-
-   case GL_RGBA4:
-   case GL_RGBA2:
-      return _dri_texformat_argb4444;
-
-   case GL_RGB5_A1:
-      return _dri_texformat_argb1555;
-
-   case GL_RGB8:
-   case GL_RGB10:
-   case GL_RGB12:
-   case GL_RGB16:
-      return !force16bpt ? _dri_texformat_argb8888 : _dri_texformat_rgb565;
-
-   case GL_RGB5:
-   case GL_RGB4:
-   case GL_R3_G3_B2:
-      return _dri_texformat_rgb565;
-
-   case GL_ALPHA:
-   case GL_ALPHA4:
-   case GL_ALPHA8:
-   case GL_ALPHA12:
-   case GL_ALPHA16:
-   case GL_COMPRESSED_ALPHA:
-      return _dri_texformat_a8;
-
-   case 1:
-   case GL_LUMINANCE:
-   case GL_LUMINANCE4:
-   case GL_LUMINANCE8:
-   case GL_LUMINANCE12:
-   case GL_LUMINANCE16:
-   case GL_COMPRESSED_LUMINANCE:
-      return _dri_texformat_l8;
-
-   case 2:
-   case GL_LUMINANCE_ALPHA:
-   case GL_LUMINANCE4_ALPHA4:
-   case GL_LUMINANCE6_ALPHA2:
-   case GL_LUMINANCE8_ALPHA8:
-   case GL_LUMINANCE12_ALPHA4:
-   case GL_LUMINANCE12_ALPHA12:
-   case GL_LUMINANCE16_ALPHA16:
-   case GL_COMPRESSED_LUMINANCE_ALPHA:
-      return _dri_texformat_al88;
-
-   case GL_INTENSITY:
-   case GL_INTENSITY4:
-   case GL_INTENSITY8:
-   case GL_INTENSITY12:
-   case GL_INTENSITY16:
-   case GL_COMPRESSED_INTENSITY:
-      return _dri_texformat_i8;
-
-   case GL_YCBCR_MESA:
-      if (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
-          type == GL_UNSIGNED_BYTE)
-         return &_mesa_texformat_ycbcr;
-      else
-         return &_mesa_texformat_ycbcr_rev;
-
-   case GL_RGB_S3TC:
-   case GL_RGB4_S3TC:
-   case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-      return &_mesa_texformat_rgb_dxt1;
-
-   case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-      return &_mesa_texformat_rgba_dxt1;
-
-   case GL_RGBA_S3TC:
-   case GL_RGBA4_S3TC:
-   case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
-      return &_mesa_texformat_rgba_dxt3;
-
-   case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
-      return &_mesa_texformat_rgba_dxt5;
-
-   default:
-      _mesa_problem(ctx, "unexpected texture format in %s", __FUNCTION__);
-      return NULL;
-   }
-
-   return NULL; /* never get here */
-}
-
-
-static void radeonTexImage1D( GLcontext *ctx, GLenum target, GLint level,
-                              GLint internalFormat,
-                              GLint width, GLint border,
-                              GLenum format, GLenum type, const GLvoid *pixels,
-                              const struct gl_pixelstore_attrib *packing,
-                              struct gl_texture_object *texObj,
-                              struct gl_texture_image *texImage )
-{
-   driTextureObject * t = (driTextureObject *) texObj->DriverData;
-
-   if ( t ) {
-      driSwapOutTextureObject( t );
-   }
-   else {
-      t = (driTextureObject *) radeonAllocTexObj( texObj );
-      if (!t) {
-         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
-         return;
-      }
-   }
-
-   /* Note, this will call ChooseTextureFormat */
-   _mesa_store_teximage1d(ctx, target, level, internalFormat,
-                          width, border, format, type, pixels,
-                          &ctx->Unpack, texObj, texImage);
-
-   t->dirty_images[0] |= (1 << level);
-}
-
-
-static void radeonTexSubImage1D( GLcontext *ctx, GLenum target, GLint level,
-                                 GLint xoffset,
-                                 GLsizei width,
-                                 GLenum format, GLenum type,
-                                 const GLvoid *pixels,
-                                 const struct gl_pixelstore_attrib *packing,
-                                 struct gl_texture_object *texObj,
-                                 struct gl_texture_image *texImage )
-{
-   driTextureObject * t = (driTextureObject *) texObj->DriverData;
-
-   assert( t ); /* this _should_ be true */
-   if ( t ) {
-      driSwapOutTextureObject( t );
-   }
-   else {
-      t = (driTextureObject *) radeonAllocTexObj( texObj );
-      if (!t) {
-         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
-         return;
-      }
-   }
-
-   _mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
-                            format, type, pixels, packing, texObj,
-                            texImage);
-
-   t->dirty_images[0] |= (1 << level);
-}
-
-
-static void radeonTexImage2D( GLcontext *ctx, GLenum target, GLint level,
-                              GLint internalFormat,
-                              GLint width, GLint height, GLint border,
-                              GLenum format, GLenum type, const GLvoid *pixels,
-                              const struct gl_pixelstore_attrib *packing,
-                              struct gl_texture_object *texObj,
-                              struct gl_texture_image *texImage )
-{
-   driTextureObject * t = (driTextureObject *) texObj->DriverData;
-   GLuint face;
-
-   /* which cube face or ordinary 2D image */
-   switch (target) {
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
-      face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
-      ASSERT(face < 6);
-      break;
-   default:
-      face = 0;
-   }
-
-   if ( t != NULL ) {
-      driSwapOutTextureObject( t );
-   }
-   else {
-      t = (driTextureObject *) radeonAllocTexObj( texObj );
-      if (!t) {
-         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
-         return;
-      }
-   }
-
-   /* Note, this will call ChooseTextureFormat */
-   _mesa_store_teximage2d(ctx, target, level, internalFormat,
-                          width, height, border, format, type, pixels,
-                          &ctx->Unpack, texObj, texImage);
-
-   t->dirty_images[face] |= (1 << level);
-}
-
-
-static void radeonTexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
-                                 GLint xoffset, GLint yoffset,
-                                 GLsizei width, GLsizei height,
-                                 GLenum format, GLenum type,
-                                 const GLvoid *pixels,
-                                 const struct gl_pixelstore_attrib *packing,
-                                 struct gl_texture_object *texObj,
-                                 struct gl_texture_image *texImage )
-{
-   driTextureObject * t = (driTextureObject *) texObj->DriverData;
-   GLuint face;
-
-   /* which cube face or ordinary 2D image */
-   switch (target) {
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
-      face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
-      ASSERT(face < 6);
-      break;
-   default:
-      face = 0;
-   }
-
-   assert( t ); /* this _should_ be true */
-   if ( t ) {
-      driSwapOutTextureObject( t );
-   }
-   else {
-      t = (driTextureObject *) radeonAllocTexObj( texObj );
-      if (!t) {
-         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
-         return;
-      }
-   }
-
-   _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
-                            height, format, type, pixels, packing, texObj,
-                            texImage);
-
-   t->dirty_images[face] |= (1 << level);
-}
-
-static void radeonCompressedTexImage2D( GLcontext *ctx, GLenum target, GLint level,
-                              GLint internalFormat,
-                              GLint width, GLint height, GLint border,
-                              GLsizei imageSize, const GLvoid *data,
-                              struct gl_texture_object *texObj,
-                              struct gl_texture_image *texImage )
-{
-   driTextureObject * t = (driTextureObject *) texObj->DriverData;
-   GLuint face;
-
-   /* which cube face or ordinary 2D image */
-   switch (target) {
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
-      face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
-      ASSERT(face < 6);
-      break;
-   default:
-      face = 0;
-   }
-
-   if ( t != NULL ) {
-      driSwapOutTextureObject( t );
-   }
-   else {
-      t = (driTextureObject *) radeonAllocTexObj( texObj );
-      if (!t) {
-         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
-         return;
-      }
-   }
-
-   /* Note, this will call ChooseTextureFormat */
-   _mesa_store_compressed_teximage2d(ctx, target, level, internalFormat, width,
-                                 height, border, imageSize, data, texObj, texImage);
-
-   t->dirty_images[face] |= (1 << level);
-}
-
-
-static void radeonCompressedTexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
-                                 GLint xoffset, GLint yoffset,
-                                 GLsizei width, GLsizei height,
-                                 GLenum format,
-                                 GLsizei imageSize, const GLvoid *data,
-                                 struct gl_texture_object *texObj,
-                                 struct gl_texture_image *texImage )
-{
-   driTextureObject * t = (driTextureObject *) texObj->DriverData;
-   GLuint face;
-
-
-   /* which cube face or ordinary 2D image */
-   switch (target) {
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
-      face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
-      ASSERT(face < 6);
-      break;
-   default:
-      face = 0;
-   }
-
-   assert( t ); /* this _should_ be true */
-   if ( t ) {
-      driSwapOutTextureObject( t );
-   }
-   else {
-      t = (driTextureObject *) radeonAllocTexObj( texObj );
-      if (!t) {
-         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2D");
-         return;
-      }
-   }
-
-   _mesa_store_compressed_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
-                                 height, format, imageSize, data, texObj, texImage);
-
-   t->dirty_images[face] |= (1 << level);
-}
-
 #define SCALED_FLOAT_TO_BYTE( x, scale ) \
                (((GLuint)((255.0F / scale) * (x))) / 2)
 
 static void radeonTexEnv( GLcontext *ctx, GLenum target,
                          GLenum pname, const GLfloat *param )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLuint unit = ctx->Texture.CurrentUnit;
    struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
 
@@ -706,7 +290,7 @@ static void radeonTexEnv( GLcontext *ctx, GLenum target,
        * functions, one mapping [-1.0,0.0] to [-128,0] and one mapping
        * [0.0,4.0] to [0,127].
        */
-      min = driQueryOptionb (&rmesa->optionCache, "no_neg_lod_bias") ?
+      min = driQueryOptionb (&rmesa->radeon.optionCache, "no_neg_lod_bias") ?
          0.0 : -1.0;
       bias = CLAMP( *param, min, 4.0 );
       if ( bias == 0 ) {
@@ -739,7 +323,7 @@ static void radeonTexParameter( GLcontext *ctx, GLenum target,
                                struct gl_texture_object *texObj,
                                GLenum pname, const GLfloat *params )
 {
-   radeonTexObjPtr t = (radeonTexObjPtr) texObj->DriverData;
+   radeonTexObj* t = radeon_tex_obj(texObj);
 
    if ( RADEON_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {
       fprintf( stderr, "%s( %s )\n", __FUNCTION__,
@@ -767,57 +351,51 @@ static void radeonTexParameter( GLcontext *ctx, GLenum target,
    case GL_TEXTURE_MAX_LEVEL:
    case GL_TEXTURE_MIN_LOD:
    case GL_TEXTURE_MAX_LOD:
+
       /* This isn't the most efficient solution but there doesn't appear to
        * be a nice alternative.  Since there's no LOD clamping,
        * we just have to rely on loading the right subset of mipmap levels
        * to simulate a clamped LOD.
        */
-      driSwapOutTextureObject( (driTextureObject *) t );
+      if (t->mt) {
+         radeon_miptree_unreference(t->mt);
+        t->mt = 0;
+        t->validated = GL_FALSE;
+      }
       break;
 
    default:
       return;
    }
-
-   /* Mark this texobj as dirty (one bit per tex unit)
-    */
-   t->dirty_state = TEX_ALL;
-}
-
-
-static void radeonBindTexture( GLcontext *ctx, GLenum target,
-                              struct gl_texture_object *texObj )
-{
-   if ( RADEON_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {
-      fprintf( stderr, "%s( %p ) unit=%d\n", __FUNCTION__, (void *)texObj,
-              ctx->Texture.CurrentUnit );
-   }
-
-   assert( (target != GL_TEXTURE_1D && target != GL_TEXTURE_2D &&
-            target != GL_TEXTURE_RECTANGLE_NV && target != GL_TEXTURE_CUBE_MAP) ||
-           (texObj->DriverData != NULL) );
 }
 
-
 static void radeonDeleteTexture( GLcontext *ctx,
                                 struct gl_texture_object *texObj )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-   driTextureObject * t = (driTextureObject *) texObj->DriverData;
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
+   radeonTexObj* t = radeon_tex_obj(texObj);
+   int i;
 
    if ( RADEON_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {
       fprintf( stderr, "%s( %p (target = %s) )\n", __FUNCTION__, (void *)texObj,
               _mesa_lookup_enum_by_nr( texObj->Target ) );
    }
 
-   if ( t != NULL ) {
-      if ( rmesa ) {
-         RADEON_FIREVERTICES( rmesa );
-      }
-
-      driDestroyTextureObject( t );
+   if ( rmesa ) {
+     radeon_firevertices(&rmesa->radeon);
+     for ( i = 0 ; i < rmesa->radeon.glCtx->Const.MaxTextureUnits ; i++ ) {
+       if ( t == rmesa->state.texture.unit[i].texobj ) {
+        rmesa->state.texture.unit[i].texobj = NULL;
+        rmesa->hw.tex[i].dirty = GL_FALSE;
+        rmesa->hw.cube[i].dirty = GL_FALSE;
+       }
+     }
    }
 
+   if (t->mt) {
+      radeon_miptree_unreference(t->mt);
+      t->mt = 0;
+   }
    /* Free mipmap images and the texture object itself */
    _mesa_delete_texture_object(ctx, texObj);
 }
@@ -837,7 +415,7 @@ static void radeonTexGen( GLcontext *ctx,
                          GLenum pname,
                          const GLfloat *params )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLuint unit = ctx->Texture.CurrentUnit;
    rmesa->recheck_texgen[unit] = GL_TRUE;
 }
@@ -851,29 +429,40 @@ static void radeonTexGen( GLcontext *ctx,
 static struct gl_texture_object *
 radeonNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-   struct gl_texture_object *obj;
-   obj = _mesa_new_texture_object(ctx, name, target);
-   if (!obj)
-      return NULL;
-   obj->MaxAnisotropy = rmesa->initialMaxAnisotropy;
-   radeonAllocTexObj( obj );
-   return obj;
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
+   radeonTexObj* t = CALLOC_STRUCT(radeon_tex_obj);
+
+   _mesa_initialize_texture_object(&t->base, name, target);
+   t->base.MaxAnisotropy = rmesa->radeon.initialMaxAnisotropy;
+
+   t->border_fallback = GL_FALSE;
+
+   t->pp_txfilter = RADEON_BORDER_MODE_OGL;
+   t->pp_txformat = (RADEON_TXFORMAT_ENDIAN_NO_SWAP |
+                    RADEON_TXFORMAT_PERSPECTIVE_ENABLE);
+   
+   radeonSetTexWrap( t, t->base.WrapS, t->base.WrapT );
+   radeonSetTexMaxAnisotropy( t, t->base.MaxAnisotropy );
+   radeonSetTexFilter( t, t->base.MinFilter, t->base.MagFilter );
+   radeonSetTexBorderColor( t, t->base.BorderColor );
+   return &t->base;
 }
 
 
+
 void radeonInitTextureFuncs( struct dd_function_table *functions )
 {
-   functions->ChooseTextureFormat      = radeonChooseTextureFormat;
+   functions->ChooseTextureFormat      = radeonChooseTextureFormat_mesa;
    functions->TexImage1D               = radeonTexImage1D;
    functions->TexImage2D               = radeonTexImage2D;
    functions->TexSubImage1D            = radeonTexSubImage1D;
    functions->TexSubImage2D            = radeonTexSubImage2D;
+   functions->GetTexImage               = radeonGetTexImage;
+   functions->GetCompressedTexImage     = radeonGetCompressedTexImage;
 
    functions->NewTextureObject         = radeonNewTextureObject;
-   functions->BindTexture              = radeonBindTexture;
+   //   functions->BindTexture         = radeonBindTexture;
    functions->DeleteTexture            = radeonDeleteTexture;
-   functions->IsTextureResident                = driIsTextureResident;
 
    functions->TexEnv                   = radeonTexEnv;
    functions->TexParameter             = radeonTexParameter;
@@ -882,5 +471,12 @@ void radeonInitTextureFuncs( struct dd_function_table *functions )
    functions->CompressedTexImage2D     = radeonCompressedTexImage2D;
    functions->CompressedTexSubImage2D  = radeonCompressedTexSubImage2D;
 
+   functions->GenerateMipmap = radeonGenerateMipmap;
+
+   functions->NewTextureImage = radeonNewTextureImage;
+   functions->FreeTexImageData = radeonFreeTexImageData;
+   functions->MapTexture = radeonMapTexture;
+   functions->UnmapTexture = radeonUnmapTexture;
+
    driInitTextureFormats();
 }
index 80008808289011a83a3f2da2d4f6cc2534931133..a4aaddc74fa5bdc91680be258a4af0d28c6f7cad 100644 (file)
@@ -41,12 +41,16 @@ extern void radeonSetTexOffset(__DRIcontext *pDRICtx, GLint texname,
                                unsigned long long offset, GLint depth,
                                GLuint pitch);
 
+extern void radeonSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv);
+extern void radeonSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_format,
+                              __DRIdrawable *dPriv);
+
 extern void radeonUpdateTextureState( GLcontext *ctx );
 
-extern int radeonUploadTexImages( radeonContextPtr rmesa, radeonTexObjPtr t,
+extern int radeonUploadTexImages( r100ContextPtr rmesa, radeonTexObjPtr t,
                                  GLuint face );
 
-extern void radeonDestroyTexObj( radeonContextPtr rmesa, radeonTexObjPtr t );
+extern void radeonDestroyTexObj( r100ContextPtr rmesa, radeonTexObjPtr t );
 
 extern void radeonInitTextureFuncs( struct dd_function_table *functions );
 
diff --git a/src/mesa/drivers/dri/radeon/radeon_texmem.c b/src/mesa/drivers/dri/radeon/radeon_texmem.c
deleted file mode 100644 (file)
index 5f7bbe6..0000000
+++ /dev/null
@@ -1,404 +0,0 @@
-/**************************************************************************
-
-Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
-                     VA Linux Systems Inc., Fremont, California.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation on the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR THEIR
-SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <martin@valinux.com>
- *   Gareth Hughes <gareth@valinux.com>
- *
- */
-#include <errno.h> 
-
-#include "main/glheader.h"
-#include "main/imports.h"
-#include "main/context.h"
-#include "main/macros.h"
-
-#include "radeon_context.h"
-#include "radeon_ioctl.h"
-#include "radeon_tex.h"
-
-#include <unistd.h>  /* for usleep() */
-
-
-/**
- * Destroy any device-dependent state associated with the texture.  This may
- * include NULLing out hardware state that points to the texture.
- */
-void
-radeonDestroyTexObj( radeonContextPtr rmesa, radeonTexObjPtr t )
-{
-   if ( RADEON_DEBUG & DEBUG_TEXTURE ) {
-      fprintf( stderr, "%s( %p, %p )\n", __FUNCTION__, (void *)t, (void *)t->base.tObj );
-   }
-
-   if ( rmesa != NULL ) {
-      unsigned   i;
-
-
-      for ( i = 0 ; i < rmesa->glCtx->Const.MaxTextureUnits ; i++ ) {
-        if ( t == rmesa->state.texture.unit[i].texobj ) {
-           rmesa->state.texture.unit[i].texobj = NULL;
-        }
-      }
-   }
-}
-
-
-/* ------------------------------------------------------------
- * Texture image conversions
- */
-
-
-static void radeonUploadRectSubImage( radeonContextPtr rmesa,
-                                     radeonTexObjPtr t, 
-                                     struct gl_texture_image *texImage,
-                                     GLint x, GLint y, 
-                                     GLint width, GLint height )
-{
-   const struct gl_texture_format *texFormat = texImage->TexFormat;
-   int blit_format, dstPitch, done;
-
-   switch ( texFormat->TexelBytes ) {
-   case 1:
-      blit_format = RADEON_GMC_DST_8BPP_CI;
-      break;
-   case 2:
-      blit_format = RADEON_GMC_DST_16BPP;
-      break;
-   case 4:
-      blit_format = RADEON_GMC_DST_32BPP;
-      break;
-   default:
-      fprintf( stderr, "radeonUploadRectSubImage: unknown blit_format (texelbytes=%d)\n", 
-              texFormat->TexelBytes);
-      return;
-   }
-
-   t->image[0][0].data = texImage->Data;
-
-   /* Currently don't need to cope with small pitches.
-    */
-   width = texImage->Width;
-   height = texImage->Height;
-   dstPitch = t->pp_txpitch + 32;
-
-   {   /* FIXME: prefer GART-texturing if possible */
-      /* Data not in GART memory, or bad pitch.
-       */
-      for (done = 0; done < height ; ) {
-        struct radeon_dma_region region;
-        int lines = MIN2( height - done, RADEON_BUFFER_SIZE / dstPitch );
-        int src_pitch;
-        char *tex;
-
-         src_pitch = texImage->RowStride * texFormat->TexelBytes;
-
-        tex = (char *)texImage->Data + done * src_pitch;
-
-        memset(&region, 0, sizeof(region));
-        radeonAllocDmaRegion( rmesa, &region, lines * dstPitch, 1024 );
-
-        /* Copy texdata to dma:
-         */
-        if (0)
-           fprintf(stderr, "%s: src_pitch %d dst_pitch %d\n",
-                   __FUNCTION__, src_pitch, dstPitch);
-
-        if (src_pitch == dstPitch) {
-           memcpy( region.address + region.start, tex, lines * src_pitch );
-        } 
-        else {
-           char *buf = region.address + region.start;
-           int i;
-           for (i = 0 ; i < lines ; i++) {
-              memcpy( buf, tex, src_pitch );
-              buf += dstPitch;
-              tex += src_pitch;
-           }
-        }
-
-        radeonEmitWait( rmesa, RADEON_WAIT_3D );
-
-        
-
-        /* Blit to framebuffer
-         */
-        radeonEmitBlit( rmesa,
-                      blit_format,
-                      dstPitch, GET_START( &region ),
-                      dstPitch, t->bufAddr,
-                      0, 0,
-                      0, done,
-                      width, lines );
-        
-        radeonEmitWait( rmesa, RADEON_WAIT_2D );
-
-        radeonReleaseDmaRegion( rmesa, &region, __FUNCTION__ );
-        done += lines;
-      }
-   }
-}
-
-
-/**
- * Upload the texture image associated with texture \a t at the specified
- * level at the address relative to \a start.
- */
-static void uploadSubImage( radeonContextPtr rmesa, radeonTexObjPtr t, 
-                           GLint hwlevel,
-                           GLint x, GLint y, GLint width, GLint height,
-                           GLuint face )
-{
-   struct gl_texture_image *texImage = NULL;
-   GLuint offset;
-   GLint imageWidth, imageHeight;
-   GLint ret;
-   drm_radeon_texture_t tex;
-   drm_radeon_tex_image_t tmp;
-   const int level = hwlevel + t->base.firstLevel;
-
-   if ( RADEON_DEBUG & DEBUG_TEXTURE ) {
-      fprintf( stderr, "%s( %p, %p ) level/width/height/face = %d/%d/%d/%u\n", 
-              __FUNCTION__, (void *)t, (void *)t->base.tObj, level, width, height, face );
-   }
-
-   ASSERT(face < 6);
-
-   /* Ensure we have a valid texture to upload */
-   if ( ( hwlevel < 0 ) || ( hwlevel >= RADEON_MAX_TEXTURE_LEVELS ) ) {
-      _mesa_problem(NULL, "bad texture level in %s", __FUNCTION__);
-      return;
-   }
-
-   texImage = t->base.tObj->Image[face][level];
-
-   if ( !texImage ) {
-      if ( RADEON_DEBUG & DEBUG_TEXTURE )
-        fprintf( stderr, "%s: texImage %d is NULL!\n", __FUNCTION__, level );
-      return;
-   }
-   if ( !texImage->Data ) {
-      if ( RADEON_DEBUG & DEBUG_TEXTURE )
-        fprintf( stderr, "%s: image data is NULL!\n", __FUNCTION__ );
-      return;
-   }
-
-
-   if (t->base.tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
-      assert(level == 0);
-      assert(hwlevel == 0);
-      if ( RADEON_DEBUG & DEBUG_TEXTURE )
-        fprintf( stderr, "%s: image data is rectangular\n", __FUNCTION__);
-      radeonUploadRectSubImage( rmesa, t, texImage, x, y, width, height );
-      return;
-   }
-
-   imageWidth = texImage->Width;
-   imageHeight = texImage->Height;
-
-   offset = t->bufAddr + t->base.totalSize * face / 6;
-
-   if ( RADEON_DEBUG & (DEBUG_TEXTURE|DEBUG_IOCTL) ) {
-      GLint imageX = 0;
-      GLint imageY = 0;
-      GLint blitX = t->image[face][hwlevel].x;
-      GLint blitY = t->image[face][hwlevel].y;
-      GLint blitWidth = t->image[face][hwlevel].width;
-      GLint blitHeight = t->image[face][hwlevel].height;
-      fprintf( stderr, "   upload image: %d,%d at %d,%d\n",
-              imageWidth, imageHeight, imageX, imageY );
-      fprintf( stderr, "   upload  blit: %d,%d at %d,%d\n",
-              blitWidth, blitHeight, blitX, blitY );
-      fprintf( stderr, "       blit ofs: 0x%07x level: %d/%d\n",
-              (GLuint)offset, hwlevel, level );
-   }
-
-   t->image[face][hwlevel].data = texImage->Data;
-
-   /* Init the DRM_RADEON_TEXTURE command / drm_radeon_texture_t struct.
-    * NOTE: we're always use a 1KB-wide blit and I8 texture format.
-    * We used to use 1, 2 and 4-byte texels and used to use the texture
-    * width to dictate the blit width - but that won't work for compressed
-    * textures. (Brian)
-    * NOTE: can't do that with texture tiling. (sroland)
-    */
-   tex.offset = offset;
-   tex.image = &tmp;
-   /* copy (x,y,width,height,data) */
-   memcpy( &tmp, &t->image[face][hwlevel], sizeof(drm_radeon_tex_image_t) );
-
-   if (texImage->TexFormat->TexelBytes) {
-      /* use multi-byte upload scheme */
-      tex.height = imageHeight;
-      tex.width = imageWidth;
-      tex.format = t->pp_txformat & RADEON_TXFORMAT_FORMAT_MASK;
-      tex.pitch = MAX2((texImage->Width * texImage->TexFormat->TexelBytes) / 64, 1);
-      tex.offset += tmp.x & ~1023;
-      tmp.x = tmp.x % 1024;
-      if (t->tile_bits & RADEON_TXO_MICRO_TILE_X2) {
-        /* need something like "tiled coordinates" ? */
-        tmp.y = tmp.x / (tex.pitch * 128) * 2;
-        tmp.x = tmp.x % (tex.pitch * 128) / 2 / texImage->TexFormat->TexelBytes;
-        tex.pitch |= RADEON_DST_TILE_MICRO >> 22;
-      }
-      else {
-        tmp.x = tmp.x >> (texImage->TexFormat->TexelBytes >> 1);
-      }
-      if ((t->tile_bits & RADEON_TXO_MACRO_TILE) &&
-        (texImage->Width * texImage->TexFormat->TexelBytes >= 256)) {
-        /* radeon switches off macro tiling for small textures/mipmaps it seems */
-        tex.pitch |= RADEON_DST_TILE_MACRO >> 22;
-      }
-   }
-   else {
-      /* In case of for instance 8x8 texture (2x2 dxt blocks), padding after the first two blocks is
-         needed (only with dxt1 since 2 dxt3/dxt5 blocks already use 32 Byte). */
-      /* set tex.height to 1/4 since 1 "macropixel" (dxt-block) has 4 real pixels. Needed
-         so the kernel module reads the right amount of data. */
-      tex.format = RADEON_TXFORMAT_I8; /* any 1-byte texel format */
-      tex.pitch = (BLIT_WIDTH_BYTES / 64);
-      tex.height = (imageHeight + 3) / 4;
-      tex.width = (imageWidth + 3) / 4;
-      switch (t->pp_txformat & RADEON_TXFORMAT_FORMAT_MASK) {
-      case RADEON_TXFORMAT_DXT1:
-         tex.width *= 8;
-         break;
-      case RADEON_TXFORMAT_DXT23:
-      case RADEON_TXFORMAT_DXT45:
-         tex.width *= 16;
-         break;
-      }
-   }
-
-   LOCK_HARDWARE( rmesa );
-   do {
-      ret = drmCommandWriteRead( rmesa->dri.fd, DRM_RADEON_TEXTURE,
-                                 &tex, sizeof(drm_radeon_texture_t) );
-   } while ( ret == -EAGAIN );
-
-   UNLOCK_HARDWARE( rmesa );
-
-   if ( ret ) {
-      fprintf( stderr, "DRM_RADEON_TEXTURE: return = %d\n", ret );
-      fprintf( stderr, "   offset=0x%08x\n",
-              offset );
-      fprintf( stderr, "   image width=%d height=%d\n",
-              imageWidth, imageHeight );
-      fprintf( stderr, "    blit width=%d height=%d data=%p\n",
-              t->image[face][hwlevel].width, t->image[face][hwlevel].height,
-              t->image[face][hwlevel].data );
-      exit( 1 );
-   }
-}
-
-
-/**
- * Upload the texture images associated with texture \a t.  This might
- * require the allocation of texture memory.
- * 
- * \param rmesa Context pointer
- * \param t Texture to be uploaded
- * \param face Cube map face to be uploaded.  Zero for non-cube maps.
- */
-
-int radeonUploadTexImages( radeonContextPtr rmesa, radeonTexObjPtr t, GLuint face )
-{
-   int numLevels;
-
-   if ( !t || t->base.totalSize == 0 || t->image_override )
-      return 0;
-
-   if ( RADEON_DEBUG & (DEBUG_TEXTURE|DEBUG_IOCTL) ) {
-      fprintf( stderr, "%s( %p, %p ) sz=%d lvls=%d-%d\n", __FUNCTION__,
-              (void *)rmesa->glCtx, (void *)t->base.tObj, t->base.totalSize,
-              t->base.firstLevel, t->base.lastLevel );
-   }
-
-   numLevels = t->base.lastLevel - t->base.firstLevel + 1;
-
-   if (RADEON_DEBUG & DEBUG_SYNC) {
-      fprintf(stderr, "%s: Syncing\n", __FUNCTION__ );
-      radeonFinish( rmesa->glCtx );
-   }
-
-   LOCK_HARDWARE( rmesa );
-
-   if ( t->base.memBlock == NULL ) {
-      int heap;
-
-      heap = driAllocateTexture( rmesa->texture_heaps, rmesa->nr_heaps,
-                                (driTextureObject *) t );
-      if ( heap == -1 ) {
-        UNLOCK_HARDWARE( rmesa );
-        return -1;
-      }
-
-      /* Set the base offset of the texture image */
-      t->bufAddr = rmesa->radeonScreen->texOffset[heap] 
-          + t->base.memBlock->ofs;
-      t->pp_txoffset = t->bufAddr;
-
-      if (!(t->base.tObj->Image[0][0]->IsClientData)) {
-        /* hope it's safe to add that here... */
-        t->pp_txoffset |= t->tile_bits;
-      }
-
-      /* Mark this texobj as dirty on all units:
-       */
-      t->dirty_state = TEX_ALL;
-   }
-
-
-   /* Let the world know we've used this memory recently.
-    */
-   driUpdateTextureLRU( (driTextureObject *) t );
-   UNLOCK_HARDWARE( rmesa );
-
-
-   /* Upload any images that are new */
-   if (t->base.dirty_images[face]) {
-      int i;
-      for ( i = 0 ; i < numLevels ; i++ ) {
-         if ( (t->base.dirty_images[face] & (1 << (i+t->base.firstLevel))) != 0 ) {
-            uploadSubImage( rmesa, t, i, 0, 0, t->image[face][i].width,
-                           t->image[face][i].height, face );
-         }
-      }
-      t->base.dirty_images[face] = 0;
-   }
-
-   if (RADEON_DEBUG & DEBUG_SYNC) {
-      fprintf(stderr, "%s: Syncing\n", __FUNCTION__ );
-      radeonFinish( rmesa->glCtx );
-   }
-
-   return 0;
-}
index b165205c0939ea633b3497d68adc50aceaa8b394..279bcd4df6a3afc019ec59f624e0fb175681d6e0 100644 (file)
@@ -39,10 +39,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/context.h"
 #include "main/macros.h"
 #include "main/texformat.h"
+#include "main/teximage.h"
 #include "main/texobj.h"
 #include "main/enums.h"
 
 #include "radeon_context.h"
+#include "radeon_mipmap_tree.h"
 #include "radeon_state.h"
 #include "radeon_ioctl.h"
 #include "radeon_swtcl.h"
@@ -75,10 +77,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define VALID_FORMAT(f) ( ((f) <= MESA_FORMAT_RGBA_DXT5) \
                             && (tx_table[f].format != 0xffffffff) )
 
-static const struct {
+struct tx_table {
    GLuint format, filter;
-}
-tx_table[] =
+};
+
+static const struct tx_table tx_table[] =
 {
    _ALPHA(RGBA8888),
    _ALPHA_REV(RGBA8888),
@@ -111,252 +114,6 @@ tx_table[] =
 #undef _ALPHA
 #undef _INVALID
 
-/**
- * This function computes the number of bytes of storage needed for
- * the given texture object (all mipmap levels, all cube faces).
- * The \c image[face][level].x/y/width/height parameters for upload/blitting
- * are computed here.  \c pp_txfilter, \c pp_txformat, etc. will be set here
- * too.
- * 
- * \param rmesa Context pointer
- * \param tObj GL texture object whose images are to be posted to
- *                 hardware state.
- */
-static void radeonSetTexImages( radeonContextPtr rmesa,
-                               struct gl_texture_object *tObj )
-{
-   radeonTexObjPtr t = (radeonTexObjPtr)tObj->DriverData;
-   const struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel];
-   GLint curOffset, blitWidth;
-   GLint i, texelBytes;
-   GLint numLevels;
-   GLint log2Width, log2Height, log2Depth;
-
-   /* Set the hardware texture format
-    */
-   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;
-
-   /* Compute which mipmap levels we really want to send to the hardware.
-    */
-
-   if (tObj->Target != GL_TEXTURE_CUBE_MAP)
-      driCalculateTextureFirstLastLevel( (driTextureObject *) t );
-   else {
-      /* r100 can't handle mipmaps for cube/3d textures, so don't waste
-         memory for them */
-      t->base.firstLevel = t->base.lastLevel = tObj->BaseLevel;
-   }
-   log2Width  = tObj->Image[0][t->base.firstLevel]->WidthLog2;
-   log2Height = tObj->Image[0][t->base.firstLevel]->HeightLog2;
-   log2Depth  = tObj->Image[0][t->base.firstLevel]->DepthLog2;
-
-   numLevels = t->base.lastLevel - t->base.firstLevel + 1;
-
-   assert(numLevels <= RADEON_MAX_TEXTURE_LEVELS);
-
-   /* Calculate mipmap offsets and dimensions for blitting (uploading)
-    * The idea is that we lay out the mipmap levels within a block of
-    * memory organized as a rectangle of width BLIT_WIDTH_BYTES.
-    */
-   curOffset = 0;
-   blitWidth = BLIT_WIDTH_BYTES;
-   t->tile_bits = 0;
-
-   /* figure out if this texture is suitable for tiling. */
-   if (texelBytes && (tObj->Target != GL_TEXTURE_RECTANGLE_NV)) {
-      if (rmesa->texmicrotile && (baseImage->Height > 1)) {
-        /* allow 32 (bytes) x 1 mip (which will use two times the space
-           the non-tiled version would use) max if base texture is large enough */
-        if ((numLevels == 1) ||
-          (((baseImage->Width * texelBytes / baseImage->Height) <= 32) &&
-              (baseImage->Width * texelBytes > 64)) ||
-           ((baseImage->Width * texelBytes / baseImage->Height) <= 16)) {
-           /* R100 has two microtile bits (only the txoffset reg, not the blitter)
-              weird: X2 + OPT: 32bit correct, 16bit completely hosed
-                     X2: 32bit correct, 16bit correct
-                     OPT: 32bit large mips correct, small mips hosed, 16bit completely hosed */
-           t->tile_bits |= RADEON_TXO_MICRO_TILE_X2 /*| RADEON_TXO_MICRO_TILE_OPT*/;
-        }
-      }
-      if ((baseImage->Width * texelBytes >= 256) && (baseImage->Height >= 16)) {
-        /* R100 disables macro tiling only if mip width is smaller than 256 bytes, and not
-           in the case if height is smaller than 16 (not 100% sure), as does the r200,
-           so need to disable macro tiling in that case */
-        if ((numLevels == 1) || ((baseImage->Width * texelBytes / baseImage->Height) <= 4)) {
-           t->tile_bits |= RADEON_TXO_MACRO_TILE;
-        }
-      }
-   }
-
-   for (i = 0; i < numLevels; i++) {
-      const struct gl_texture_image *texImage;
-      GLuint size;
-
-      texImage = tObj->Image[0][i + t->base.firstLevel];
-      if ( !texImage )
-        break;
-
-      /* find image size in bytes */
-      if (texImage->IsCompressed) {
-      /* need to calculate the size AFTER padding even though the texture is
-         submitted without padding.
-         Only handle pot textures currently - don't know if npot is even possible,
-         size calculation would certainly need (trivial) adjustments.
-         Align (and later pad) to 32byte, not sure what that 64byte blit width is
-         good for? */
-         if ((t->pp_txformat & RADEON_TXFORMAT_FORMAT_MASK) == RADEON_TXFORMAT_DXT1) {
-            /* RGB_DXT1/RGBA_DXT1, 8 bytes per block */
-            if ((texImage->Width + 3) < 8) /* width one block */
-               size = texImage->CompressedSize * 4;
-            else if ((texImage->Width + 3) < 16)
-               size = texImage->CompressedSize * 2;
-            else size = texImage->CompressedSize;
-         }
-         else /* DXT3/5, 16 bytes per block */
-            if ((texImage->Width + 3) < 8)
-               size = texImage->CompressedSize * 2;
-            else size = texImage->CompressedSize;
-      }
-      else if (tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
-        size = ((texImage->Width * texelBytes + 63) & ~63) * texImage->Height;
-      }
-      else if (t->tile_bits & RADEON_TXO_MICRO_TILE_X2) {
-        /* tile pattern is 16 bytes x2. mipmaps stay 32 byte aligned,
-           though the actual offset may be different (if texture is less than
-           32 bytes width) to the untiled case */
-        int w = (texImage->Width * texelBytes * 2 + 31) & ~31;
-        size = (w * ((texImage->Height + 1) / 2)) * texImage->Depth;
-        blitWidth = MAX2(texImage->Width, 64 / texelBytes);
-      }
-      else {
-        int w = (texImage->Width * texelBytes + 31) & ~31;
-        size = w * texImage->Height * texImage->Depth;
-        blitWidth = MAX2(texImage->Width, 64 / texelBytes);
-      }
-      assert(size > 0);
-
-      /* Align to 32-byte offset.  It is faster to do this unconditionally
-       * (no branch penalty).
-       */
-
-      curOffset = (curOffset + 0x1f) & ~0x1f;
-
-      if (texelBytes) {
-        t->image[0][i].x = curOffset; /* fix x and y coords up later together with offset */
-        t->image[0][i].y = 0;
-        t->image[0][i].width = MIN2(size / texelBytes, blitWidth);
-        t->image[0][i].height = (size / texelBytes) / t->image[0][i].width;
-      }
-      else {
-         t->image[0][i].x = curOffset % BLIT_WIDTH_BYTES;
-         t->image[0][i].y = curOffset / BLIT_WIDTH_BYTES;
-         t->image[0][i].width  = MIN2(size, BLIT_WIDTH_BYTES);
-         t->image[0][i].height = size / t->image[0][i].width;     
-      }
-
-#if 0
-      /* for debugging only and only  applicable to non-rectangle targets */
-      assert(size % t->image[0][i].width == 0);
-      assert(t->image[0][i].x == 0
-             || (size < BLIT_WIDTH_BYTES && t->image[0][i].height == 1));
-#endif
-
-      if (0)
-         fprintf(stderr,
-                 "level %d: %dx%d x=%d y=%d w=%d h=%d size=%d at %d\n",
-                 i, texImage->Width, texImage->Height,
-                 t->image[0][i].x, t->image[0][i].y,
-                 t->image[0][i].width, t->image[0][i].height, size, curOffset);
-
-      curOffset += size;
-
-   }
-
-   /* Align the total size of texture memory block.
-    */
-   t->base.totalSize = (curOffset + RADEON_OFFSET_MASK) & ~RADEON_OFFSET_MASK;
-
-   /* Setup remaining cube face blits, if needed */
-   if (tObj->Target == GL_TEXTURE_CUBE_MAP) {
-      const GLuint faceSize = t->base.totalSize;
-      GLuint face;
-      /* reuse face 0 x/y/width/height - just update the offset when uploading */
-      for (face = 1; face < 6; face++) {
-         for (i = 0; i < numLevels; i++) {
-            t->image[face][i].x =  t->image[0][i].x;
-            t->image[face][i].y =  t->image[0][i].y;
-            t->image[face][i].width  = t->image[0][i].width;
-            t->image[face][i].height = t->image[0][i].height;
-         }
-      }
-      t->base.totalSize = 6 * faceSize; /* total texmem needed */
-   }
-
-   /* Hardware state:
-    */
-   t->pp_txfilter &= ~RADEON_MAX_MIP_LEVEL_MASK;
-   t->pp_txfilter |= (numLevels - 1) << RADEON_MAX_MIP_LEVEL_SHIFT;
-
-   t->pp_txformat &= ~(RADEON_TXFORMAT_WIDTH_MASK |
-                      RADEON_TXFORMAT_HEIGHT_MASK |
-                       RADEON_TXFORMAT_CUBIC_MAP_ENABLE |
-                       RADEON_TXFORMAT_F5_WIDTH_MASK |
-                       RADEON_TXFORMAT_F5_HEIGHT_MASK);
-   t->pp_txformat |= ((log2Width << RADEON_TXFORMAT_WIDTH_SHIFT) |
-                     (log2Height << RADEON_TXFORMAT_HEIGHT_SHIFT));
-
-   if (tObj->Target == GL_TEXTURE_CUBE_MAP) {
-      assert(log2Width == log2Height);
-      t->pp_txformat |= ((log2Width << RADEON_TXFORMAT_F5_WIDTH_SHIFT) |
-                         (log2Height << RADEON_TXFORMAT_F5_HEIGHT_SHIFT) |
-                         (RADEON_TXFORMAT_CUBIC_MAP_ENABLE));
-      t->pp_cubic_faces = ((log2Width << RADEON_FACE_WIDTH_1_SHIFT) |
-                           (log2Height << RADEON_FACE_HEIGHT_1_SHIFT) |
-                           (log2Width << RADEON_FACE_WIDTH_2_SHIFT) |
-                           (log2Height << RADEON_FACE_HEIGHT_2_SHIFT) |
-                           (log2Width << RADEON_FACE_WIDTH_3_SHIFT) |
-                           (log2Height << RADEON_FACE_HEIGHT_3_SHIFT) |
-                           (log2Width << RADEON_FACE_WIDTH_4_SHIFT) |
-                           (log2Height << RADEON_FACE_HEIGHT_4_SHIFT));
-   }
-
-   t->pp_txsize = (((tObj->Image[0][t->base.firstLevel]->Width - 1) << 0) |
-                   ((tObj->Image[0][t->base.firstLevel]->Height - 1) << 16));
-
-   /* Only need to round to nearest 32 for textures, but the blitter
-    * requires 64-byte aligned pitches, and we may/may not need the
-    * blitter.   NPOT only!
-    */
-   if ( !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;
-
-   /* FYI: radeonUploadTexImages( rmesa, t ); used to be called here */
-}
-
-
-
 /* ================================================================
  * Texture combine functions
  */
@@ -503,7 +260,7 @@ do {                                                        \
 
 static GLboolean radeonUpdateTextureEnv( GLcontext *ctx, int unit )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
    GLuint color_combine, alpha_combine;
    const GLuint color_combine0 = RADEON_COLOR_ARG_A_ZERO | RADEON_COLOR_ARG_B_ZERO
@@ -846,22 +603,21 @@ static GLboolean radeonUpdateTextureEnv( GLcontext *ctx, int unit )
 void radeonSetTexOffset(__DRIcontext * pDRICtx, GLint texname,
                         unsigned long long offset, GLint depth, GLuint pitch)
 {
-       radeonContextPtr rmesa = pDRICtx->driverPrivate;
+       r100ContextPtr rmesa = pDRICtx->driverPrivate;
        struct gl_texture_object *tObj =
-           _mesa_lookup_texture(rmesa->glCtx, texname);
-       radeonTexObjPtr t;
+           _mesa_lookup_texture(rmesa->radeon.glCtx, texname);
+       radeonTexObjPtr t = radeon_tex_obj(tObj);
 
        if (tObj == NULL)
                return;
 
-       t = (radeonTexObjPtr) tObj->DriverData;
-
        t->image_override = GL_TRUE;
 
        if (!offset)
                return;
-
-       t->pp_txoffset = offset;
+       
+       t->bo = NULL;
+       t->override_offset = offset;
        t->pp_txpitch = pitch - 32;
 
        switch (depth) {
@@ -881,6 +637,125 @@ void radeonSetTexOffset(__DRIcontext * pDRICtx, GLint texname,
        }
 }
 
+void radeonSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_format,
+                        __DRIdrawable *dPriv)
+{
+       struct gl_texture_unit *texUnit;
+       struct gl_texture_object *texObj;
+       struct gl_texture_image *texImage;
+       struct radeon_renderbuffer *rb;
+       radeon_texture_image *rImage;
+       radeonContextPtr radeon;
+       r100ContextPtr rmesa;
+       struct radeon_framebuffer *rfb;
+       radeonTexObjPtr t;
+       uint32_t pitch_val;
+       uint32_t internalFormat, type, format;
+
+       type = GL_BGRA;
+       format = GL_UNSIGNED_BYTE;
+       internalFormat = (glx_texture_format == GLX_TEXTURE_FORMAT_RGB_EXT ? 3 : 4);
+
+       radeon = pDRICtx->driverPrivate;
+       rmesa = pDRICtx->driverPrivate;
+
+       rfb = dPriv->driverPrivate;
+        texUnit = &radeon->glCtx->Texture.Unit[radeon->glCtx->Texture.CurrentUnit];
+       texObj = _mesa_select_tex_object(radeon->glCtx, texUnit, target);
+        texImage = _mesa_get_tex_image(radeon->glCtx, texObj, target, 0);
+
+       rImage = get_radeon_texture_image(texImage);
+       t = radeon_tex_obj(texObj);
+        if (t == NULL) {
+           return;
+       }
+
+       radeon_update_renderbuffers(pDRICtx, dPriv);
+       /* back & depth buffer are useless free them right away */
+       rb = (void*)rfb->base.Attachment[BUFFER_DEPTH].Renderbuffer;
+       if (rb && rb->bo) {
+               radeon_bo_unref(rb->bo);
+        rb->bo = NULL;
+       }
+       rb = (void*)rfb->base.Attachment[BUFFER_BACK_LEFT].Renderbuffer;
+       if (rb && rb->bo) {
+               radeon_bo_unref(rb->bo);
+               rb->bo = NULL;
+       }
+       rb = rfb->color_rb[0];
+       if (rb->bo == NULL) {
+               /* Failed to BO for the buffer */
+               return;
+       }
+       
+       _mesa_lock_texture(radeon->glCtx, texObj);
+       if (t->bo) {
+               radeon_bo_unref(t->bo);
+               t->bo = NULL;
+       }
+       if (rImage->bo) {
+               radeon_bo_unref(rImage->bo);
+               rImage->bo = NULL;
+       }
+       if (t->mt) {
+               radeon_miptree_unreference(t->mt);
+               t->mt = NULL;
+       }
+       if (rImage->mt) {
+               radeon_miptree_unreference(rImage->mt);
+               rImage->mt = NULL;
+       }
+       _mesa_init_teximage_fields(radeon->glCtx, target, texImage,
+                                  rb->width, rb->height, 1, 0, rb->cpp);
+       texImage->RowStride = rb->pitch / rb->cpp;
+       texImage->TexFormat = radeonChooseTextureFormat(radeon->glCtx,
+                                                       internalFormat,
+                                                       type, format, 0);
+       rImage->bo = rb->bo;
+       radeon_bo_ref(rImage->bo);
+       t->bo = rb->bo;
+       radeon_bo_ref(t->bo);
+       t->tile_bits = 0;
+       t->image_override = GL_TRUE;
+       t->override_offset = 0;
+       t->pp_txpitch &= (1 << 13) -1;
+       pitch_val = rb->pitch;
+       switch (rb->cpp) {
+       case 4:
+               if (glx_texture_format == GLX_TEXTURE_FORMAT_RGB_EXT)
+                       t->pp_txformat = tx_table[MESA_FORMAT_RGB888].format;
+               else
+                       t->pp_txformat = tx_table[MESA_FORMAT_ARGB8888].format;
+               t->pp_txfilter |= tx_table[MESA_FORMAT_ARGB8888].filter;
+               break;
+       case 3:
+       default:
+               t->pp_txformat = tx_table[MESA_FORMAT_RGB888].format;
+               t->pp_txfilter |= tx_table[MESA_FORMAT_RGB888].filter;
+               break;
+       case 2:
+               t->pp_txformat = tx_table[MESA_FORMAT_RGB565].format;
+               t->pp_txfilter |= tx_table[MESA_FORMAT_RGB565].filter;
+               break;
+       }
+        t->pp_txsize = ((rb->width - 1) << RADEON_TEX_USIZE_SHIFT)
+                  | ((rb->height - 1) << RADEON_TEX_VSIZE_SHIFT);
+        t->pp_txformat |= RADEON_TXFORMAT_NON_POWER2;
+       t->pp_txpitch = pitch_val;
+        t->pp_txpitch -= 32;
+
+       t->validated = GL_TRUE;
+       _mesa_unlock_texture(radeon->glCtx, texObj);
+       return;
+}
+
+
+void radeonSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
+{
+        radeonSetTexBuffer2(pDRICtx, target, GLX_TEXTURE_FORMAT_RGBA_EXT, dPriv);
+}
+
+
 #define TEXOBJ_TXFILTER_MASK (RADEON_MAX_MIP_LEVEL_MASK |      \
                              RADEON_MIN_FILTER_MASK |          \
                              RADEON_MAG_FILTER_MASK |          \
@@ -901,12 +776,53 @@ void radeonSetTexOffset(__DRIcontext * pDRICtx, GLint texname,
                               RADEON_TXFORMAT_NON_POWER2)
 
 
-static void import_tex_obj_state( radeonContextPtr rmesa,
+static void disable_tex_obj_state( r100ContextPtr rmesa, 
+                                  int unit )
+{
+   RADEON_STATECHANGE( rmesa, tex[unit] );
+
+   RADEON_STATECHANGE( rmesa, tcl );
+   rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] &= ~(RADEON_ST_BIT(unit) |
+                                            RADEON_Q_BIT(unit));
+   
+   if (rmesa->radeon.TclFallback & (RADEON_TCL_FALLBACK_TEXGEN_0<<unit)) {
+     TCL_FALLBACK( rmesa->radeon.glCtx, (RADEON_TCL_FALLBACK_TEXGEN_0<<unit), GL_FALSE);
+     rmesa->recheck_texgen[unit] = GL_TRUE;
+   }
+
+   if (rmesa->hw.tex[unit].cmd[TEX_PP_TXFORMAT] & RADEON_TXFORMAT_CUBIC_MAP_ENABLE) {
+     /* this seems to be a genuine (r100 only?) hw bug. Need to remove the
+       cubic_map bit on unit 2 when the unit is disabled, otherwise every
+       2nd (2d) mipmap on unit 0 will be broken (may not be needed for other
+       units, better be safe than sorry though).*/
+     RADEON_STATECHANGE( rmesa, tex[unit] );
+     rmesa->hw.tex[unit].cmd[TEX_PP_TXFORMAT] &= ~RADEON_TXFORMAT_CUBIC_MAP_ENABLE;
+   }
+
+   {
+      GLuint inputshift = RADEON_TEXGEN_0_INPUT_SHIFT + unit*4;
+      GLuint tmp = rmesa->TexGenEnabled;
+
+      rmesa->TexGenEnabled &= ~(RADEON_TEXGEN_TEXMAT_0_ENABLE<<unit);
+      rmesa->TexGenEnabled &= ~(RADEON_TEXMAT_0_ENABLE<<unit);
+      rmesa->TexGenEnabled &= ~(RADEON_TEXGEN_INPUT_MASK<<inputshift);
+      rmesa->TexGenNeedNormals[unit] = 0;
+      rmesa->TexGenEnabled |= 
+       (RADEON_TEXGEN_INPUT_TEXCOORD_0+unit) << inputshift;
+
+      if (tmp != rmesa->TexGenEnabled) {
+       rmesa->recheck_texgen[unit] = GL_TRUE;
+       rmesa->radeon.NewGLState |= _NEW_TEXTURE_MATRIX;
+      }
+   }
+}
+
+static void import_tex_obj_state( r100ContextPtr rmesa,
                                  int unit,
                                  radeonTexObjPtr texobj )
 {
 /* do not use RADEON_DB_STATE to avoid stale texture caches */
-   int *cmd = &rmesa->hw.tex[unit].cmd[TEX_CMD_0];
+   uint32_t *cmd = &rmesa->hw.tex[unit].cmd[TEX_CMD_0];
    GLuint se_coord_fmt = rmesa->hw.set.cmd[SET_SE_COORDFMT];
 
    RADEON_STATECHANGE( rmesa, tex[unit] );
@@ -915,10 +831,9 @@ static void import_tex_obj_state( radeonContextPtr rmesa,
    cmd[TEX_PP_TXFILTER] |= texobj->pp_txfilter & TEXOBJ_TXFILTER_MASK;
    cmd[TEX_PP_TXFORMAT] &= ~TEXOBJ_TXFORMAT_MASK;
    cmd[TEX_PP_TXFORMAT] |= texobj->pp_txformat & TEXOBJ_TXFORMAT_MASK;
-   cmd[TEX_PP_TXOFFSET] = texobj->pp_txoffset;
    cmd[TEX_PP_BORDER_COLOR] = texobj->pp_border_color;
 
-   if (texobj->base.tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
+   if (texobj->base.Target == GL_TEXTURE_RECTANGLE_NV) {
       GLuint *txr_cmd = RADEON_DB_STATE( txr[unit] );
       txr_cmd[TXR_PP_TEX_SIZE] = texobj->pp_txsize; /* NPOT only! */
       txr_cmd[TXR_PP_TEX_PITCH] = texobj->pp_txpitch; /* NPOT only! */
@@ -928,22 +843,12 @@ static void import_tex_obj_state( radeonContextPtr rmesa,
    else {
       se_coord_fmt &= ~(RADEON_VTX_ST0_NONPARAMETRIC << unit);
 
-      if (texobj->base.tObj->Target == GL_TEXTURE_CUBE_MAP) {
-        int *cube_cmd = &rmesa->hw.cube[unit].cmd[CUBE_CMD_0];
-        GLuint bytesPerFace = texobj->base.totalSize / 6;
-        ASSERT(texobj->base.totalSize % 6 == 0);
+      if (texobj->base.Target == GL_TEXTURE_CUBE_MAP) {
+        uint32_t *cube_cmd = &rmesa->hw.cube[unit].cmd[CUBE_CMD_0];
 
         RADEON_STATECHANGE( rmesa, cube[unit] );
         cube_cmd[CUBE_PP_CUBIC_FACES] = texobj->pp_cubic_faces;
-        /* dont know if this setup conforms to OpenGL.. 
-         * at least it matches the behavior of mesa software renderer
-         */
-        cube_cmd[CUBE_PP_CUBIC_OFFSET_0] = texobj->pp_txoffset; /* right */
-        cube_cmd[CUBE_PP_CUBIC_OFFSET_1] = texobj->pp_txoffset + 1 * bytesPerFace; /* left */
-        cube_cmd[CUBE_PP_CUBIC_OFFSET_2] = texobj->pp_txoffset + 2 * bytesPerFace; /* top */
-        cube_cmd[CUBE_PP_CUBIC_OFFSET_3] = texobj->pp_txoffset + 3 * bytesPerFace; /* bottom */
-        cube_cmd[CUBE_PP_CUBIC_OFFSET_4] = texobj->pp_txoffset + 4 * bytesPerFace; /* front */
-        cmd[TEX_PP_TXOFFSET] = texobj->pp_txoffset + 5 * bytesPerFace; /* back */
+        /* state filled out in the cube_emit */
       }
    }
 
@@ -952,13 +857,11 @@ static void import_tex_obj_state( radeonContextPtr rmesa,
       rmesa->hw.set.cmd[SET_SE_COORDFMT] = se_coord_fmt;
    }
 
-   texobj->dirty_state &= ~(1<<unit);
+   rmesa->radeon.NewGLState |= _NEW_TEXTURE_MATRIX;
 }
 
 
-
-
-static void set_texgen_matrix( radeonContextPtr rmesa, 
+static void set_texgen_matrix( r100ContextPtr rmesa, 
                               GLuint unit,
                               const GLfloat *s_plane,
                               const GLfloat *t_plane,
@@ -986,14 +889,14 @@ static void set_texgen_matrix( radeonContextPtr rmesa,
    rmesa->TexGenMatrix[unit].m[15] = q_plane[3];
 
    rmesa->TexGenEnabled |= RADEON_TEXMAT_0_ENABLE << unit;
-   rmesa->NewGLState |= _NEW_TEXTURE_MATRIX;
+   rmesa->radeon.NewGLState |= _NEW_TEXTURE_MATRIX;
 }
 
 /* Returns GL_FALSE if fallback required.
  */
 static GLboolean radeon_validate_texgen( GLcontext *ctx, GLuint unit )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
    GLuint inputshift = RADEON_TEXGEN_0_INPUT_SHIFT + unit*4;
    GLuint tmp = rmesa->TexGenEnabled;
@@ -1094,283 +997,187 @@ static GLboolean radeon_validate_texgen( GLcontext *ctx, GLuint unit )
    }
 
    if (tmp != rmesa->TexGenEnabled) {
-      rmesa->NewGLState |= _NEW_TEXTURE_MATRIX;
+      rmesa->radeon.NewGLState |= _NEW_TEXTURE_MATRIX;
    }
 
    return GL_TRUE;
 }
 
-
-static void disable_tex( GLcontext *ctx, int unit )
-{
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
-   if (rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (RADEON_TEX_0_ENABLE<<unit)) {
-      /* Texture unit disabled */
-      if ( rmesa->state.texture.unit[unit].texobj != NULL ) {
-        /* The old texture is no longer bound to this texture unit.
-         * Mark it as such.
-         */
-
-        rmesa->state.texture.unit[unit].texobj->base.bound &= ~(1UL << unit);
-        rmesa->state.texture.unit[unit].texobj = NULL;
-      }
-
-      RADEON_STATECHANGE( rmesa, ctx );
-      rmesa->hw.ctx.cmd[CTX_PP_CNTL] &= 
-         ~((RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE) << unit);
-
-      RADEON_STATECHANGE( rmesa, tcl );
-      rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] &= ~(RADEON_ST_BIT(unit) |
-                                               RADEON_Q_BIT(unit));
-
-      if (rmesa->TclFallback & (RADEON_TCL_FALLBACK_TEXGEN_0<<unit)) {
-        TCL_FALLBACK( ctx, (RADEON_TCL_FALLBACK_TEXGEN_0<<unit), GL_FALSE);
-        rmesa->recheck_texgen[unit] = GL_TRUE;
-      }
-
-      if (rmesa->hw.tex[unit].cmd[TEX_PP_TXFORMAT] & RADEON_TXFORMAT_CUBIC_MAP_ENABLE) {
-      /* this seems to be a genuine (r100 only?) hw bug. Need to remove the
-         cubic_map bit on unit 2 when the unit is disabled, otherwise every
-        2nd (2d) mipmap on unit 0 will be broken (may not be needed for other
-        units, better be safe than sorry though).*/
-        RADEON_STATECHANGE( rmesa, tex[unit] );
-        rmesa->hw.tex[unit].cmd[TEX_PP_TXFORMAT] &= ~RADEON_TXFORMAT_CUBIC_MAP_ENABLE;
-      }
-
-      {
-        GLuint inputshift = RADEON_TEXGEN_0_INPUT_SHIFT + unit*4;
-        GLuint tmp = rmesa->TexGenEnabled;
-
-        rmesa->TexGenEnabled &= ~(RADEON_TEXGEN_TEXMAT_0_ENABLE<<unit);
-        rmesa->TexGenEnabled &= ~(RADEON_TEXMAT_0_ENABLE<<unit);
-        rmesa->TexGenEnabled &= ~(RADEON_TEXGEN_INPUT_MASK<<inputshift);
-        rmesa->TexGenNeedNormals[unit] = 0;
-        rmesa->TexGenEnabled |= 
-            (RADEON_TEXGEN_INPUT_TEXCOORD_0+unit) << inputshift;
-
-        if (tmp != rmesa->TexGenEnabled) {
-           rmesa->recheck_texgen[unit] = GL_TRUE;
-           rmesa->NewGLState |= _NEW_TEXTURE_MATRIX;
-        }
-      }
-   }
-}
-
-static GLboolean enable_tex_2d( GLcontext *ctx, int unit )
-{
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-   struct gl_texture_object *tObj = texUnit->_Current;
-   radeonTexObjPtr t = (radeonTexObjPtr) tObj->DriverData;
-
-   /* Need to load the 2d images associated with this unit.
-    */
-   if (t->pp_txformat & RADEON_TXFORMAT_NON_POWER2) {
-      t->pp_txformat &= ~RADEON_TXFORMAT_NON_POWER2;
-      t->base.dirty_images[0] = ~0;
-   }
-
-   ASSERT(tObj->Target == GL_TEXTURE_2D || tObj->Target == GL_TEXTURE_1D);
-
-   if ( t->base.dirty_images[0] ) {
-      RADEON_FIREVERTICES( rmesa );
-      radeonSetTexImages( rmesa, tObj );
-      radeonUploadTexImages( rmesa, (radeonTexObjPtr) tObj->DriverData, 0 );
-      if ( !t->base.memBlock && !t->image_override ) 
-       return GL_FALSE;
-   }
-
-   return GL_TRUE;
-}
-
-static GLboolean enable_tex_cube( GLcontext *ctx, int unit )
+/**
+ * Compute the cached hardware register values for the given texture object.
+ *
+ * \param rmesa Context pointer
+ * \param t the r300 texture object
+ */
+static GLboolean setup_hardware_state(r100ContextPtr rmesa, radeonTexObj *t, int unit)
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-   struct gl_texture_object *tObj = texUnit->_Current;
-   radeonTexObjPtr t = (radeonTexObjPtr) tObj->DriverData;
-   GLuint face;
+   const struct gl_texture_image *firstImage;
+   GLint log2Width, log2Height, log2Depth, texelBytes;
 
-   /* Need to load the 2d images associated with this unit.
-    */
-   if (t->pp_txformat & RADEON_TXFORMAT_NON_POWER2) {
-      t->pp_txformat &= ~RADEON_TXFORMAT_NON_POWER2;
-      for (face = 0; face < 6; face++)
-         t->base.dirty_images[face] = ~0;
+   if ( t->bo ) {
+       return GL_TRUE;
    }
 
-   ASSERT(tObj->Target == GL_TEXTURE_CUBE_MAP);
+   firstImage = t->base.Image[0][t->mt->firstLevel];   
 
-   if ( t->base.dirty_images[0] || t->base.dirty_images[1] ||
-        t->base.dirty_images[2] || t->base.dirty_images[3] ||
-        t->base.dirty_images[4] || t->base.dirty_images[5] ) {
-      /* flush */
-      RADEON_FIREVERTICES( rmesa );
-      /* layout memory space, once for all faces */
-      radeonSetTexImages( rmesa, tObj );
+   if (firstImage->Border > 0) {
+      fprintf(stderr, "%s: border\n", __FUNCTION__);
+      return GL_FALSE;
    }
 
-   /* upload (per face) */
-   for (face = 0; face < 6; face++) {
-      if (t->base.dirty_images[face]) {
-         radeonUploadTexImages( rmesa, (radeonTexObjPtr) tObj->DriverData, face );
+   log2Width  = firstImage->WidthLog2;
+   log2Height = firstImage->HeightLog2;
+   log2Depth  = firstImage->DepthLog2;
+   texelBytes = firstImage->TexFormat->TexelBytes;
+
+   if (!t->image_override) {
+      if (VALID_FORMAT(firstImage->TexFormat->MesaFormat)) {
+       const struct tx_table *table = tx_table;
+
+        t->pp_txformat &= ~(RADEON_TXFORMAT_FORMAT_MASK |
+                            RADEON_TXFORMAT_ALPHA_IN_MAP);
+        t->pp_txfilter &= ~RADEON_YUV_TO_RGB;   
+        
+        t->pp_txformat |= table[ firstImage->TexFormat->MesaFormat ].format;
+        t->pp_txfilter |= table[ firstImage->TexFormat->MesaFormat ].filter;
+      } else {
+        _mesa_problem(NULL, "unexpected texture format in %s",
+                      __FUNCTION__);
+        return GL_FALSE;
       }
    }
-      
-   if ( !t->base.memBlock ) {
-      /* texmem alloc failed, use s/w fallback */
-      return GL_FALSE;
+   
+   t->pp_txfilter &= ~RADEON_MAX_MIP_LEVEL_MASK;
+   t->pp_txfilter |= (t->mt->lastLevel - t->mt->firstLevel) << RADEON_MAX_MIP_LEVEL_SHIFT;
+       
+   t->pp_txformat &= ~(RADEON_TXFORMAT_WIDTH_MASK |
+                      RADEON_TXFORMAT_HEIGHT_MASK |
+                      RADEON_TXFORMAT_CUBIC_MAP_ENABLE |
+                      RADEON_TXFORMAT_F5_WIDTH_MASK |
+                      RADEON_TXFORMAT_F5_HEIGHT_MASK);
+   t->pp_txformat |= ((log2Width << RADEON_TXFORMAT_WIDTH_SHIFT) |
+                     (log2Height << RADEON_TXFORMAT_HEIGHT_SHIFT));
+   
+   t->tile_bits = 0;
+   
+   if (t->base.Target == GL_TEXTURE_CUBE_MAP) {
+      ASSERT(log2Width == log2Height);
+      t->pp_txformat |= ((log2Width << RADEON_TXFORMAT_F5_WIDTH_SHIFT) |
+                        (log2Height << RADEON_TXFORMAT_F5_HEIGHT_SHIFT) |
+                        /* don't think we need this bit, if it exists at all - fglrx does not set it */
+                        (RADEON_TXFORMAT_CUBIC_MAP_ENABLE));
+      t->pp_cubic_faces = ((log2Width << RADEON_FACE_WIDTH_1_SHIFT) |
+                           (log2Height << RADEON_FACE_HEIGHT_1_SHIFT) |
+                           (log2Width << RADEON_FACE_WIDTH_2_SHIFT) |
+                           (log2Height << RADEON_FACE_HEIGHT_2_SHIFT) |
+                           (log2Width << RADEON_FACE_WIDTH_3_SHIFT) |
+                           (log2Height << RADEON_FACE_HEIGHT_3_SHIFT) |
+                           (log2Width << RADEON_FACE_WIDTH_4_SHIFT) |
+                           (log2Height << RADEON_FACE_HEIGHT_4_SHIFT));
    }
 
-   return GL_TRUE;
-}
-
-static GLboolean enable_tex_rect( GLcontext *ctx, int unit )
-{
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-   struct gl_texture_object *tObj = texUnit->_Current;
-   radeonTexObjPtr t = (radeonTexObjPtr) tObj->DriverData;
+   t->pp_txsize = (((firstImage->Width - 1) << RADEON_TEX_USIZE_SHIFT)
+                  | ((firstImage->Height - 1) << RADEON_TEX_VSIZE_SHIFT));
 
-   if (!(t->pp_txformat & RADEON_TXFORMAT_NON_POWER2)) {
-      t->pp_txformat |= RADEON_TXFORMAT_NON_POWER2;
-      t->base.dirty_images[0] = ~0;
+   if ( !t->image_override ) {
+      if (firstImage->IsCompressed)
+         t->pp_txpitch = (firstImage->Width + 63) & ~(63);
+      else
+         t->pp_txpitch = ((firstImage->Width * texelBytes) + 63) & ~(63);
+      t->pp_txpitch -= 32;
    }
 
-   ASSERT(tObj->Target == GL_TEXTURE_RECTANGLE_NV);
-
-   if ( t->base.dirty_images[0] ) {
-      RADEON_FIREVERTICES( rmesa );
-      radeonSetTexImages( rmesa, tObj );
-      radeonUploadTexImages( rmesa, (radeonTexObjPtr) tObj->DriverData, 0 );
-      if ( !t->base.memBlock &&
-           !t->image_override /* && !rmesa->prefer_gart_client_texturing  FIXME */ ) {
-        fprintf(stderr, "%s: upload failed\n", __FUNCTION__);
-        return GL_FALSE;
-      }
+   if (t->base.Target == GL_TEXTURE_RECTANGLE_NV) {
+      t->pp_txformat |= RADEON_TXFORMAT_NON_POWER2;
    }
 
    return GL_TRUE;
 }
 
-
-static GLboolean update_tex_common( GLcontext *ctx, int unit )
+static GLboolean radeon_validate_texture(GLcontext *ctx, struct gl_texture_object *texObj, int unit)
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-   struct gl_texture_object *tObj = texUnit->_Current;
-   radeonTexObjPtr t = (radeonTexObjPtr) tObj->DriverData;
-   GLenum format;
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
+   radeonTexObj *t = radeon_tex_obj(texObj);
+   int ret;
 
-   /* Fallback if there's a texture border */
-   if ( tObj->Image[0][tObj->BaseLevel]->Border > 0 ) {
-      fprintf(stderr, "%s: border\n", __FUNCTION__);
+   if (!radeon_validate_texture_miptree(ctx, texObj))
       return GL_FALSE;
-   }
+
+   ret = setup_hardware_state(rmesa, t, unit);
+   if (ret == GL_FALSE)
+     return GL_FALSE;
+
    /* yuv conversion only works in first unit */
    if (unit != 0 && (t->pp_txfilter & RADEON_YUV_TO_RGB))
       return GL_FALSE;
 
-   /* Update state if this is a different texture object to last
-    * time.
-    */
-   if ( rmesa->state.texture.unit[unit].texobj != t ) {
-      if ( rmesa->state.texture.unit[unit].texobj != NULL ) {
-        /* The old texture is no longer bound to this texture unit.
-         * Mark it as such.
-         */
-
-        rmesa->state.texture.unit[unit].texobj->base.bound &= 
-            ~(1UL << unit);
-      }
-
-      rmesa->state.texture.unit[unit].texobj = t;
-      t->base.bound |= (1UL << unit);
-      t->dirty_state |= 1<<unit;
-      driUpdateTextureLRU( (driTextureObject *) t ); /* XXX: should be locked! */
-   }
+   RADEON_STATECHANGE( rmesa, ctx );
+   rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= 
+     (RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE) << unit;
 
+   RADEON_STATECHANGE( rmesa, tcl );
+   rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_ST_BIT(unit);
 
-   /* Newly enabled?
-    */
-   if ( !(rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (RADEON_TEX_0_ENABLE<<unit))) {
-      RADEON_STATECHANGE( rmesa, ctx );
-      rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= 
-         (RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE) << unit;
+   rmesa->recheck_texgen[unit] = GL_TRUE;
 
-      RADEON_STATECHANGE( rmesa, tcl );
-
-      rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_ST_BIT(unit);
-
-      rmesa->recheck_texgen[unit] = GL_TRUE;
-   }
-
-   if (t->dirty_state & (1<<unit)) {
-      import_tex_obj_state( rmesa, unit, t );
-      /* may need to update texture matrix (for texrect adjustments) */
-      rmesa->NewGLState |= _NEW_TEXTURE_MATRIX;
-   }
+   import_tex_obj_state( rmesa, unit, t );
 
    if (rmesa->recheck_texgen[unit]) {
       GLboolean fallback = !radeon_validate_texgen( ctx, unit );
       TCL_FALLBACK( ctx, (RADEON_TCL_FALLBACK_TEXGEN_0<<unit), fallback);
       rmesa->recheck_texgen[unit] = 0;
-      rmesa->NewGLState |= _NEW_TEXTURE_MATRIX;
+      rmesa->radeon.NewGLState |= _NEW_TEXTURE_MATRIX;
    }
 
-   format = tObj->Image[0][tObj->BaseLevel]->_BaseFormat;
-   if ( rmesa->state.texture.unit[unit].format != format ||
-       rmesa->state.texture.unit[unit].envMode != texUnit->EnvMode ) {
-      rmesa->state.texture.unit[unit].format = format;
-      rmesa->state.texture.unit[unit].envMode = texUnit->EnvMode;
-      if ( ! radeonUpdateTextureEnv( ctx, unit ) ) {
-        return GL_FALSE;
-      }
+   if ( ! radeonUpdateTextureEnv( ctx, unit ) ) {
+     return GL_FALSE;
    }
-
    FALLBACK( rmesa, RADEON_FALLBACK_BORDER_MODE, t->border_fallback );
+
+   t->validated = GL_TRUE;
    return !t->border_fallback;
 }
 
-
-
 static GLboolean radeonUpdateTextureUnit( GLcontext *ctx, int unit )
 {
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
 
-   if ( texUnit->_ReallyEnabled & (TEXTURE_RECT_BIT) ) {
-      return (enable_tex_rect( ctx, unit ) &&
-             update_tex_common( ctx, unit ));
-   }
-   else if ( texUnit->_ReallyEnabled & (TEXTURE_1D_BIT | TEXTURE_2D_BIT) ) {
-      return (enable_tex_2d( ctx, unit ) &&
-             update_tex_common( ctx, unit ));
-   }
-   else if ( texUnit->_ReallyEnabled & (TEXTURE_CUBE_BIT) ) {
-      return (enable_tex_cube( ctx, unit ) &&
-             update_tex_common( ctx, unit ));
+   if (ctx->Texture.Unit[unit]._ReallyEnabled & TEXTURE_3D_BIT) {
+     return GL_FALSE;
    }
-   else if ( texUnit->_ReallyEnabled ) {
-      return GL_FALSE;
+
+   if (!ctx->Texture.Unit[unit]._ReallyEnabled) {
+     /* disable the unit */
+     disable_tex_obj_state(rmesa, unit);
+     return GL_TRUE;
    }
-   else {
-      disable_tex( ctx, unit );
-      return GL_TRUE;
+
+   if (!radeon_validate_texture(ctx, ctx->Texture.Unit[unit]._Current, unit)) {
+    _mesa_warning(ctx,
+                 "failed to validate texture for unit %d.\n",
+                 unit);
+    rmesa->state.texture.unit[unit].texobj = NULL;
+    return GL_FALSE;
    }
+   rmesa->state.texture.unit[unit].texobj = radeon_tex_obj(ctx->Texture.Unit[unit]._Current);
+   return GL_TRUE;
 }
 
 void radeonUpdateTextureState( GLcontext *ctx )
 {
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+   r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLboolean ok;
 
+   /* set the ctx all textures off */
+   RADEON_STATECHANGE( rmesa, ctx );
+   rmesa->hw.ctx.cmd[CTX_PP_CNTL] &= ~((RADEON_TEX_ENABLE_MASK) | (RADEON_TEX_BLEND_ENABLE_MASK));
+
    ok = (radeonUpdateTextureUnit( ctx, 0 ) &&
         radeonUpdateTextureUnit( ctx, 1 ) &&
         radeonUpdateTextureUnit( ctx, 2 ));
 
    FALLBACK( rmesa, RADEON_FALLBACK_TEXTURE, !ok );
 
-   if (rmesa->TclFallback)
+   if (rmesa->radeon.TclFallback)
       radeonChooseVertexState( ctx );
 }
diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c
new file mode 100644 (file)
index 0000000..429ad50
--- /dev/null
@@ -0,0 +1,1035 @@
+/*
+ * Copyright (C) 2008 Nicolai Haehnle.
+ * Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
+ *
+ * The Weather Channel (TM) funded Tungsten Graphics to develop the
+ * initial release of the Radeon 8500 driver under the XFree86 license.
+ * This notice must be preserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "main/glheader.h"
+#include "main/imports.h"
+#include "main/context.h"
+#include "main/convolve.h"
+#include "main/mipmap.h"
+#include "main/texcompress.h"
+#include "main/texformat.h"
+#include "main/texstore.h"
+#include "main/teximage.h"
+#include "main/texobj.h"
+#include "main/texgetimage.h"
+
+#include "xmlpool.h"           /* for symbolic values of enum-type options */
+
+#include "radeon_common.h"
+
+#include "radeon_mipmap_tree.h"
+
+
+static void copy_rows(void* dst, GLuint dststride, const void* src, GLuint srcstride,
+       GLuint numrows, GLuint rowsize)
+{
+       assert(rowsize <= dststride);
+       assert(rowsize <= srcstride);
+
+       if (rowsize == srcstride && rowsize == dststride) {
+               memcpy(dst, src, numrows*rowsize);
+       } else {
+               GLuint i;
+               for(i = 0; i < numrows; ++i) {
+                       memcpy(dst, src, rowsize);
+                       dst += dststride;
+                       src += srcstride;
+               }
+       }
+}
+
+/* textures */
+/**
+ * Allocate an empty texture image object.
+ */
+struct gl_texture_image *radeonNewTextureImage(GLcontext *ctx)
+{
+       return CALLOC(sizeof(radeon_texture_image));
+}
+
+/**
+ * Free memory associated with this texture image.
+ */
+void radeonFreeTexImageData(GLcontext *ctx, struct gl_texture_image *timage)
+{
+       radeon_texture_image* image = get_radeon_texture_image(timage);
+
+       if (image->mt) {
+               radeon_miptree_unreference(image->mt);
+               image->mt = 0;
+               assert(!image->base.Data);
+       } else {
+               _mesa_free_texture_image_data(ctx, timage);
+       }
+       if (image->bo) {
+               radeon_bo_unref(image->bo);
+               image->bo = NULL;
+       }
+       if (timage->Data) {
+               _mesa_free_texmemory(timage->Data);
+               timage->Data = NULL;
+       }
+}
+
+/* Set Data pointer and additional data for mapped texture image */
+static void teximage_set_map_data(radeon_texture_image *image)
+{
+       radeon_mipmap_level *lvl = &image->mt->levels[image->mtlevel];
+
+       image->base.Data = image->mt->bo->ptr + lvl->faces[image->mtface].offset;
+       image->base.RowStride = lvl->rowstride / image->mt->bpp;
+}
+
+
+/**
+ * Map a single texture image for glTexImage and friends.
+ */
+void radeon_teximage_map(radeon_texture_image *image, GLboolean write_enable)
+{
+       if (image->mt) {
+               assert(!image->base.Data);
+
+               radeon_bo_map(image->mt->bo, write_enable);
+               teximage_set_map_data(image);
+       }
+}
+
+
+void radeon_teximage_unmap(radeon_texture_image *image)
+{
+       if (image->mt) {
+               assert(image->base.Data);
+
+               image->base.Data = 0;
+               radeon_bo_unmap(image->mt->bo);
+       }
+}
+
+static void map_override(GLcontext *ctx, radeonTexObj *t)
+{
+       radeon_texture_image *img = get_radeon_texture_image(t->base.Image[0][0]);
+
+       radeon_bo_map(t->bo, GL_FALSE);
+
+       img->base.Data = t->bo->ptr;
+       _mesa_set_fetch_functions(&img->base, 2);
+}
+
+static void unmap_override(GLcontext *ctx, radeonTexObj *t)
+{
+       radeon_texture_image *img = get_radeon_texture_image(t->base.Image[0][0]);
+
+       radeon_bo_unmap(t->bo);
+
+       img->base.Data = NULL;
+}
+
+/**
+ * Map a validated texture for reading during software rendering.
+ */
+void radeonMapTexture(GLcontext *ctx, struct gl_texture_object *texObj)
+{
+       radeonTexObj* t = radeon_tex_obj(texObj);
+       int face, level;
+
+       if (!radeon_validate_texture_miptree(ctx, texObj))
+         return;
+
+       /* for r100 3D sw fallbacks don't have mt */
+       if (t->image_override && t->bo)
+               map_override(ctx, t);
+
+       if (!t->mt)
+               return;
+
+       radeon_bo_map(t->mt->bo, GL_FALSE);
+       for(face = 0; face < t->mt->faces; ++face) {
+               for(level = t->mt->firstLevel; level <= t->mt->lastLevel; ++level)
+                       teximage_set_map_data(get_radeon_texture_image(texObj->Image[face][level]));
+       }
+}
+
+void radeonUnmapTexture(GLcontext *ctx, struct gl_texture_object *texObj)
+{
+       radeonTexObj* t = radeon_tex_obj(texObj);
+       int face, level;
+
+       if (t->image_override && t->bo)
+               unmap_override(ctx, t);
+       /* for r100 3D sw fallbacks don't have mt */
+       if (!t->mt)
+         return;
+
+       for(face = 0; face < t->mt->faces; ++face) {
+               for(level = t->mt->firstLevel; level <= t->mt->lastLevel; ++level)
+                       texObj->Image[face][level]->Data = 0;
+       }
+       radeon_bo_unmap(t->mt->bo);
+}
+
+GLuint radeon_face_for_target(GLenum target)
+{
+       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:
+               return (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+       default:
+               return 0;
+       }
+}
+
+/**
+ * Wraps Mesa's implementation to ensure that the base level image is mapped.
+ *
+ * This relies on internal details of _mesa_generate_mipmap, in particular
+ * the fact that the memory for recreated texture images is always freed.
+ */
+static void radeon_generate_mipmap(GLcontext *ctx, GLenum target,
+                                  struct gl_texture_object *texObj)
+{
+       radeonTexObj* t = radeon_tex_obj(texObj);
+       GLuint nr_faces = (t->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
+       int i, face;
+
+
+       _mesa_generate_mipmap(ctx, target, texObj);
+
+       for (face = 0; face < nr_faces; face++) {
+               for (i = texObj->BaseLevel + 1; i < texObj->MaxLevel; i++) {
+                       radeon_texture_image *image;
+
+                       image = get_radeon_texture_image(texObj->Image[face][i]);
+
+                       if (image == NULL)
+                               break;
+
+                       image->mtlevel = i;
+                       image->mtface = face;
+
+                       radeon_miptree_unreference(image->mt);
+                       image->mt = NULL;
+               }
+       }
+       
+}
+
+void radeonGenerateMipmap(GLcontext* ctx, GLenum target, struct gl_texture_object *texObj)
+{
+       GLuint face = radeon_face_for_target(target);
+       radeon_texture_image *baseimage = get_radeon_texture_image(texObj->Image[face][texObj->BaseLevel]);
+
+       radeon_teximage_map(baseimage, GL_FALSE);
+       radeon_generate_mipmap(ctx, target, texObj);
+       radeon_teximage_unmap(baseimage);
+}
+
+
+/* try to find a format which will only need a memcopy */
+static const struct gl_texture_format *radeonChoose8888TexFormat(radeonContextPtr rmesa,
+                                                                GLenum srcFormat,
+                                                                GLenum srcType, GLboolean fbo)
+{
+       const GLuint ui = 1;
+       const GLubyte littleEndian = *((const GLubyte *)&ui);
+
+       /* r100 can only do this */
+       if (IS_R100_CLASS(rmesa->radeonScreen) || fbo)
+         return _dri_texformat_argb8888;
+
+       if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
+           (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
+           (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
+           (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && littleEndian)) {
+               return &_mesa_texformat_rgba8888;
+       } else if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
+                  (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && littleEndian) ||
+                  (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
+                  (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && !littleEndian)) {
+               return &_mesa_texformat_rgba8888_rev;
+       } else if (IS_R200_CLASS(rmesa->radeonScreen)) {
+               return _dri_texformat_argb8888;
+       } else if (srcFormat == GL_BGRA && ((srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
+                                           srcType == GL_UNSIGNED_INT_8_8_8_8)) {
+               return &_mesa_texformat_argb8888_rev;
+       } else if (srcFormat == GL_BGRA && ((srcType == GL_UNSIGNED_BYTE && littleEndian) ||
+                                           srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) {
+               return &_mesa_texformat_argb8888;
+       } else
+               return _dri_texformat_argb8888;
+}
+
+const struct gl_texture_format *radeonChooseTextureFormat_mesa(GLcontext * ctx,
+                                                         GLint internalFormat,
+                                                         GLenum format,
+                                                         GLenum type)
+{
+       return radeonChooseTextureFormat(ctx, internalFormat, format,
+                                        type, 0);
+}
+
+const struct gl_texture_format *radeonChooseTextureFormat(GLcontext * ctx,
+                                                         GLint internalFormat,
+                                                         GLenum format,
+                                                         GLenum type, GLboolean fbo)
+{
+       radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+       const GLboolean do32bpt =
+           (rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32);
+       const GLboolean force16bpt =
+           (rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16);
+       (void)format;
+
+#if 0
+       fprintf(stderr, "InternalFormat=%s(%d) type=%s format=%s\n",
+               _mesa_lookup_enum_by_nr(internalFormat), internalFormat,
+               _mesa_lookup_enum_by_nr(type), _mesa_lookup_enum_by_nr(format));
+       fprintf(stderr, "do32bpt=%d force16bpt=%d\n", do32bpt, force16bpt);
+#endif
+
+       switch (internalFormat) {
+       case 4:
+       case GL_RGBA:
+       case GL_COMPRESSED_RGBA:
+               switch (type) {
+               case GL_UNSIGNED_INT_10_10_10_2:
+               case GL_UNSIGNED_INT_2_10_10_10_REV:
+                       return do32bpt ? _dri_texformat_argb8888 :
+                           _dri_texformat_argb1555;
+               case GL_UNSIGNED_SHORT_4_4_4_4:
+               case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+                       return _dri_texformat_argb4444;
+               case GL_UNSIGNED_SHORT_5_5_5_1:
+               case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+                       return _dri_texformat_argb1555;
+               default:
+                       return do32bpt ? radeonChoose8888TexFormat(rmesa, format, type, fbo) :
+                           _dri_texformat_argb4444;
+               }
+
+       case 3:
+       case GL_RGB:
+       case GL_COMPRESSED_RGB:
+               switch (type) {
+               case GL_UNSIGNED_SHORT_4_4_4_4:
+               case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+                       return _dri_texformat_argb4444;
+               case GL_UNSIGNED_SHORT_5_5_5_1:
+               case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+                       return _dri_texformat_argb1555;
+               case GL_UNSIGNED_SHORT_5_6_5:
+               case GL_UNSIGNED_SHORT_5_6_5_REV:
+                       return _dri_texformat_rgb565;
+               default:
+                       return do32bpt ? _dri_texformat_argb8888 :
+                           _dri_texformat_rgb565;
+               }
+
+       case GL_RGBA8:
+       case GL_RGB10_A2:
+       case GL_RGBA12:
+       case GL_RGBA16:
+               return !force16bpt ?
+                       radeonChoose8888TexFormat(rmesa, format, type, fbo) :
+                       _dri_texformat_argb4444;
+
+       case GL_RGBA4:
+       case GL_RGBA2:
+               return _dri_texformat_argb4444;
+
+       case GL_RGB5_A1:
+               return _dri_texformat_argb1555;
+
+       case GL_RGB8:
+       case GL_RGB10:
+       case GL_RGB12:
+       case GL_RGB16:
+               return !force16bpt ? _dri_texformat_argb8888 :
+                   _dri_texformat_rgb565;
+
+       case GL_RGB5:
+       case GL_RGB4:
+       case GL_R3_G3_B2:
+               return _dri_texformat_rgb565;
+
+       case GL_ALPHA:
+       case GL_ALPHA4:
+       case GL_ALPHA8:
+       case GL_ALPHA12:
+       case GL_ALPHA16:
+       case GL_COMPRESSED_ALPHA:
+               /* r200: can't use a8 format since interpreting hw I8 as a8 would result
+                  in wrong rgb values (same as alpha value instead of 0). */
+               if (IS_R200_CLASS(rmesa->radeonScreen))
+                       return _dri_texformat_al88;
+               else
+                       return _dri_texformat_a8;
+       case 1:
+       case GL_LUMINANCE:
+       case GL_LUMINANCE4:
+       case GL_LUMINANCE8:
+       case GL_LUMINANCE12:
+       case GL_LUMINANCE16:
+       case GL_COMPRESSED_LUMINANCE:
+               return _dri_texformat_l8;
+
+       case 2:
+       case GL_LUMINANCE_ALPHA:
+       case GL_LUMINANCE4_ALPHA4:
+       case GL_LUMINANCE6_ALPHA2:
+       case GL_LUMINANCE8_ALPHA8:
+       case GL_LUMINANCE12_ALPHA4:
+       case GL_LUMINANCE12_ALPHA12:
+       case GL_LUMINANCE16_ALPHA16:
+       case GL_COMPRESSED_LUMINANCE_ALPHA:
+               return _dri_texformat_al88;
+
+       case GL_INTENSITY:
+       case GL_INTENSITY4:
+       case GL_INTENSITY8:
+       case GL_INTENSITY12:
+       case GL_INTENSITY16:
+       case GL_COMPRESSED_INTENSITY:
+               return _dri_texformat_i8;
+
+       case GL_YCBCR_MESA:
+               if (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
+                   type == GL_UNSIGNED_BYTE)
+                       return &_mesa_texformat_ycbcr;
+               else
+                       return &_mesa_texformat_ycbcr_rev;
+
+       case GL_RGB_S3TC:
+       case GL_RGB4_S3TC:
+       case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+               return &_mesa_texformat_rgb_dxt1;
+
+       case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+               return &_mesa_texformat_rgba_dxt1;
+
+       case GL_RGBA_S3TC:
+       case GL_RGBA4_S3TC:
+       case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+               return &_mesa_texformat_rgba_dxt3;
+
+       case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+               return &_mesa_texformat_rgba_dxt5;
+
+       case GL_ALPHA16F_ARB:
+               return &_mesa_texformat_alpha_float16;
+       case GL_ALPHA32F_ARB:
+               return &_mesa_texformat_alpha_float32;
+       case GL_LUMINANCE16F_ARB:
+               return &_mesa_texformat_luminance_float16;
+       case GL_LUMINANCE32F_ARB:
+               return &_mesa_texformat_luminance_float32;
+       case GL_LUMINANCE_ALPHA16F_ARB:
+               return &_mesa_texformat_luminance_alpha_float16;
+       case GL_LUMINANCE_ALPHA32F_ARB:
+               return &_mesa_texformat_luminance_alpha_float32;
+       case GL_INTENSITY16F_ARB:
+               return &_mesa_texformat_intensity_float16;
+       case GL_INTENSITY32F_ARB:
+               return &_mesa_texformat_intensity_float32;
+       case GL_RGB16F_ARB:
+               return &_mesa_texformat_rgba_float16;
+       case GL_RGB32F_ARB:
+               return &_mesa_texformat_rgba_float32;
+       case GL_RGBA16F_ARB:
+               return &_mesa_texformat_rgba_float16;
+       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:
+       case GL_DEPTH_STENCIL_EXT:
+       case GL_DEPTH24_STENCIL8_EXT:
+               return &_mesa_texformat_s8_z24;
+
+       /* EXT_texture_sRGB */
+       case GL_SRGB:
+       case GL_SRGB8:
+       case GL_SRGB_ALPHA:
+       case GL_SRGB8_ALPHA8:
+       case GL_COMPRESSED_SRGB:
+       case GL_COMPRESSED_SRGB_ALPHA:
+               return &_mesa_texformat_srgba8;
+
+       case GL_SLUMINANCE:
+       case GL_SLUMINANCE8:
+       case GL_COMPRESSED_SLUMINANCE:
+               return &_mesa_texformat_sl8;
+
+       case GL_SLUMINANCE_ALPHA:
+       case GL_SLUMINANCE8_ALPHA8:
+       case GL_COMPRESSED_SLUMINANCE_ALPHA:
+               return &_mesa_texformat_sla8;
+
+       default:
+               _mesa_problem(ctx,
+                             "unexpected internalFormat 0x%x in %s",
+                             (int)internalFormat, __func__);
+               return NULL;
+       }
+
+       return NULL;            /* never get here */
+}
+
+/**
+ * All glTexImage calls go through this function.
+ */
+static void radeon_teximage(
+       GLcontext *ctx, int dims,
+       GLint face, GLint level,
+       GLint internalFormat,
+       GLint width, GLint height, GLint depth,
+       GLsizei imageSize,
+       GLenum format, GLenum type, const GLvoid * pixels,
+       const struct gl_pixelstore_attrib *packing,
+       struct gl_texture_object *texObj,
+       struct gl_texture_image *texImage,
+       int compressed)
+{
+       radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+       radeonTexObj* t = radeon_tex_obj(texObj);
+       radeon_texture_image* image = get_radeon_texture_image(texImage);
+       GLuint dstRowStride;
+       GLint postConvWidth = width;
+       GLint postConvHeight = height;
+       GLuint texelBytes;
+
+       radeon_firevertices(rmesa);
+
+       t->validated = GL_FALSE;
+
+       if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) {
+              _mesa_adjust_image_for_convolution(ctx, dims, &postConvWidth,
+                                                 &postConvHeight);
+       }
+
+       /* Choose and fill in the texture format for this image */
+       texImage->TexFormat = radeonChooseTextureFormat(ctx, internalFormat, format, type, 0);
+       _mesa_set_fetch_functions(texImage, dims);
+
+       if (texImage->TexFormat->TexelBytes == 0) {
+               texelBytes = 0;
+               texImage->IsCompressed = GL_TRUE;
+               texImage->CompressedSize =
+                       ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
+                                          texImage->Height, texImage->Depth,
+                                          texImage->TexFormat->MesaFormat);
+       } else {
+               texImage->IsCompressed = GL_FALSE;
+               texImage->CompressedSize = 0;
+
+               texelBytes = texImage->TexFormat->TexelBytes;
+               /* Minimum pitch of 32 bytes */
+               if (postConvWidth * texelBytes < 32) {
+                 postConvWidth = 32 / texelBytes;
+                 texImage->RowStride = postConvWidth;
+               }
+               if (!image->mt) {      
+                       assert(texImage->RowStride == postConvWidth);
+               }
+       }
+
+       /* Allocate memory for image */
+       radeonFreeTexImageData(ctx, texImage); /* Mesa core only clears texImage->Data but not image->mt */
+
+       if (t->mt &&
+           t->mt->firstLevel == level &&
+           t->mt->lastLevel == level &&
+           t->mt->target != GL_TEXTURE_CUBE_MAP_ARB &&
+           !radeon_miptree_matches_image(t->mt, texImage, face, level)) {
+         radeon_miptree_unreference(t->mt);
+         t->mt = NULL;
+       }
+
+       if (!t->mt)
+               radeon_try_alloc_miptree(rmesa, t, texImage, face, level);
+       if (t->mt && radeon_miptree_matches_image(t->mt, texImage, face, level)) {
+               radeon_mipmap_level *lvl;
+               image->mt = t->mt;
+               image->mtlevel = level - t->mt->firstLevel;
+               image->mtface = face;
+               radeon_miptree_reference(t->mt);
+               lvl = &image->mt->levels[image->mtlevel];
+               dstRowStride = lvl->rowstride;
+       } else {
+               int size;
+               if (texImage->IsCompressed) {
+                       size = texImage->CompressedSize;
+               } else {
+                       size = texImage->Width * texImage->Height * texImage->Depth * texImage->TexFormat->TexelBytes;
+               }
+               texImage->Data = _mesa_alloc_texmemory(size);
+       }
+
+       /* Upload texture image; note that the spec allows pixels to be NULL */
+       if (compressed) {
+               pixels = _mesa_validate_pbo_compressed_teximage(
+                       ctx, imageSize, pixels, packing, "glCompressedTexImage");
+       } else {
+               pixels = _mesa_validate_pbo_teximage(
+                       ctx, dims, width, height, depth,
+                       format, type, pixels, packing, "glTexImage");
+       }
+
+       if (pixels) {
+               radeon_teximage_map(image, GL_TRUE);
+
+               if (compressed) {
+                       memcpy(texImage->Data, pixels, imageSize);
+               } else {
+                       GLuint dstRowStride;
+                       GLuint *dstImageOffsets;
+
+                       if (image->mt) {
+                               radeon_mipmap_level *lvl = &image->mt->levels[image->mtlevel];
+                               dstRowStride = lvl->rowstride;
+                       } else {
+                               dstRowStride = texImage->Width * texImage->TexFormat->TexelBytes;
+                       }
+
+                       if (dims == 3) {
+                               int i;
+
+                               dstImageOffsets = _mesa_malloc(depth * sizeof(GLuint)) ;
+                               if (!dstImageOffsets)
+                                       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
+
+                               for (i = 0; i < depth; ++i) {
+                                       dstImageOffsets[i] = dstRowStride/texImage->TexFormat->TexelBytes * height * i;
+                               }
+                       } else {
+                               dstImageOffsets = texImage->ImageOffsets;
+                       }
+
+                       if (!texImage->TexFormat->StoreImage(ctx, dims,
+                                               texImage->_BaseFormat,
+                                               texImage->TexFormat,
+                                               texImage->Data, 0, 0, 0, /* dstX/Y/Zoffset */
+                                               dstRowStride,
+                                               dstImageOffsets,
+                                               width, height, depth,
+                                               format, type, pixels, packing))
+                               _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
+
+                       if (dims == 3)
+                               _mesa_free(dstImageOffsets);
+               }
+
+               /* SGIS_generate_mipmap */
+               if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+                       radeon_generate_mipmap(ctx, texObj->Target, texObj);
+               }
+       }
+
+       _mesa_unmap_teximage_pbo(ctx, packing);
+
+       if (pixels)
+         radeon_teximage_unmap(image);
+
+
+}
+
+void radeonTexImage1D(GLcontext * ctx, GLenum target, GLint level,
+                     GLint internalFormat,
+                     GLint width, GLint border,
+                     GLenum format, GLenum type, const GLvoid * pixels,
+                     const struct gl_pixelstore_attrib *packing,
+                     struct gl_texture_object *texObj,
+                     struct gl_texture_image *texImage)
+{
+       radeon_teximage(ctx, 1, 0, level, internalFormat, width, 1, 1,
+               0, format, type, pixels, packing, texObj, texImage, 0);
+}
+
+void radeonTexImage2D(GLcontext * ctx, GLenum target, GLint level,
+                          GLint internalFormat,
+                          GLint width, GLint height, GLint border,
+                          GLenum format, GLenum type, const GLvoid * pixels,
+                          const struct gl_pixelstore_attrib *packing,
+                          struct gl_texture_object *texObj,
+                          struct gl_texture_image *texImage)
+
+{
+       GLuint face = radeon_face_for_target(target);
+
+       radeon_teximage(ctx, 2, face, level, internalFormat, width, height, 1,
+               0, format, type, pixels, packing, texObj, texImage, 0);
+}
+
+void radeonCompressedTexImage2D(GLcontext * ctx, GLenum target,
+                                    GLint level, GLint internalFormat,
+                                    GLint width, GLint height, GLint border,
+                                    GLsizei imageSize, const GLvoid * data,
+                                    struct gl_texture_object *texObj,
+                                    struct gl_texture_image *texImage)
+{
+       GLuint face = radeon_face_for_target(target);
+
+       radeon_teximage(ctx, 2, face, level, internalFormat, width, height, 1,
+               imageSize, 0, 0, data, &ctx->Unpack, texObj, texImage, 1);
+}
+
+void radeonTexImage3D(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)
+{
+       radeon_teximage(ctx, 3, 0, level, internalFormat, width, height, depth,
+               0, format, type, pixels, packing, texObj, texImage, 0);
+}
+
+/**
+ * Update a subregion of the given texture image.
+ */
+static void radeon_texsubimage(GLcontext* ctx, int dims, int level,
+               GLint xoffset, GLint yoffset, GLint zoffset,
+               GLsizei width, GLsizei height, GLsizei depth,
+               GLsizei imageSize,
+               GLenum format, GLenum type,
+               const GLvoid * pixels,
+               const struct gl_pixelstore_attrib *packing,
+               struct gl_texture_object *texObj,
+               struct gl_texture_image *texImage,
+               int compressed)
+{
+       radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+       radeonTexObj* t = radeon_tex_obj(texObj);
+       radeon_texture_image* image = get_radeon_texture_image(texImage);
+
+       radeon_firevertices(rmesa);
+
+       t->validated = GL_FALSE;
+       if (compressed) {
+               pixels = _mesa_validate_pbo_compressed_teximage(
+                       ctx, imageSize, pixels, packing, "glCompressedTexImage");
+       } else {
+               pixels = _mesa_validate_pbo_teximage(ctx, dims,
+                       width, height, depth, format, type, pixels, packing, "glTexSubImage1D");
+       }
+
+       if (pixels) {
+               GLint dstRowStride;
+               radeon_teximage_map(image, GL_TRUE);
+
+               if (image->mt) {
+                       radeon_mipmap_level *lvl = &image->mt->levels[image->mtlevel];
+                       dstRowStride = lvl->rowstride;
+               } else {
+                       dstRowStride = texImage->RowStride * texImage->TexFormat->TexelBytes;
+               }
+
+               if (compressed) {
+                       uint32_t srcRowStride, bytesPerRow, rows; 
+                       dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, texImage->Width);
+                       srcRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
+                       bytesPerRow = srcRowStride;
+                       rows = height / 4;
+
+                       copy_rows(texImage->Data, dstRowStride,  image->base.Data, srcRowStride, rows,
+                                 bytesPerRow);
+                       
+               } else {
+                       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, "glTexSubImage");
+               }
+
+               /* GL_SGIS_generate_mipmap */
+               if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+                       radeon_generate_mipmap(ctx, texObj->Target, texObj);
+               }
+       }
+
+       radeon_teximage_unmap(image);
+
+       _mesa_unmap_teximage_pbo(ctx, packing);
+
+
+}
+
+void radeonTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
+                        GLint xoffset,
+                        GLsizei width,
+                        GLenum format, GLenum type,
+                        const GLvoid * pixels,
+                        const struct gl_pixelstore_attrib *packing,
+                        struct gl_texture_object *texObj,
+                        struct gl_texture_image *texImage)
+{
+       radeon_texsubimage(ctx, 1, level, xoffset, 0, 0, width, 1, 1, 0,
+               format, type, pixels, packing, texObj, texImage, 0);
+}
+
+void radeonTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
+                        GLint xoffset, GLint yoffset,
+                        GLsizei width, GLsizei height,
+                        GLenum format, GLenum type,
+                        const GLvoid * pixels,
+                        const struct gl_pixelstore_attrib *packing,
+                        struct gl_texture_object *texObj,
+                        struct gl_texture_image *texImage)
+{
+       radeon_texsubimage(ctx, 2, level, xoffset, yoffset, 0, width, height, 1,
+                          0, format, type, pixels, packing, texObj, texImage,
+                          0);
+}
+
+void radeonCompressedTexSubImage2D(GLcontext * ctx, GLenum target,
+                                  GLint level, GLint xoffset,
+                                  GLint yoffset, GLsizei width,
+                                  GLsizei height, GLenum format,
+                                  GLsizei imageSize, const GLvoid * data,
+                                  struct gl_texture_object *texObj,
+                                  struct gl_texture_image *texImage)
+{
+       radeon_texsubimage(ctx, 2, level, xoffset, yoffset, 0, width, height, 1,
+               imageSize, format, 0, data, &ctx->Unpack, texObj, texImage, 1);
+}
+
+
+void radeonTexSubImage3D(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)
+{
+       radeon_texsubimage(ctx, 3, level, xoffset, yoffset, zoffset, width, height, depth, 0,
+               format, type, pixels, packing, texObj, texImage, 0);
+}
+
+
+
+/**
+ * Ensure that the given image is stored in the given miptree from now on.
+ */
+static void migrate_image_to_miptree(radeon_mipmap_tree *mt, radeon_texture_image *image, int face, int level)
+{
+       radeon_mipmap_level *dstlvl = &mt->levels[level - mt->firstLevel];
+       unsigned char *dest;
+
+       assert(image->mt != mt);
+       assert(dstlvl->width == image->base.Width);
+       assert(dstlvl->height == image->base.Height);
+       assert(dstlvl->depth == image->base.Depth);
+
+
+       radeon_bo_map(mt->bo, GL_TRUE);
+       dest = mt->bo->ptr + dstlvl->faces[face].offset;
+
+       if (image->mt) {
+               /* Format etc. should match, so we really just need a memcpy().
+                * In fact, that memcpy() could be done by the hardware in many
+                * cases, provided that we have a proper memory manager.
+                */
+               radeon_mipmap_level *srclvl = &image->mt->levels[image->mtlevel-image->mt->firstLevel];
+
+               assert(srclvl->size == dstlvl->size);
+               assert(srclvl->rowstride == dstlvl->rowstride);
+
+               radeon_bo_map(image->mt->bo, GL_FALSE);
+
+               memcpy(dest,
+                       image->mt->bo->ptr + srclvl->faces[face].offset,
+                       dstlvl->size);
+               radeon_bo_unmap(image->mt->bo);
+
+               radeon_miptree_unreference(image->mt);
+       } else {
+               uint32_t srcrowstride;
+               uint32_t height;
+               /* need to confirm this value is correct */
+               if (mt->compressed) {
+                       height = image->base.Height / 4;
+                       srcrowstride = image->base.RowStride * mt->bpp;
+               } else {
+                       height = image->base.Height * image->base.Depth;
+                       srcrowstride = image->base.Width * image->base.TexFormat->TexelBytes;
+               }
+
+//             if (mt->tilebits)
+//                     WARN_ONCE("%s: tiling not supported yet", __FUNCTION__);
+
+               copy_rows(dest, dstlvl->rowstride, image->base.Data, srcrowstride,
+                         height, srcrowstride);
+
+               _mesa_free_texmemory(image->base.Data);
+               image->base.Data = 0;
+       }
+
+       radeon_bo_unmap(mt->bo);
+
+       image->mt = mt;
+       image->mtface = face;
+       image->mtlevel = level;
+       radeon_miptree_reference(image->mt);
+}
+
+int radeon_validate_texture_miptree(GLcontext * ctx, struct gl_texture_object *texObj)
+{
+       radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+       radeonTexObj *t = radeon_tex_obj(texObj);
+       radeon_texture_image *baseimage = get_radeon_texture_image(texObj->Image[0][texObj->BaseLevel]);
+       int face, level;
+
+       if (t->validated || t->image_override)
+               return GL_TRUE;
+
+       if (RADEON_DEBUG & DEBUG_TEXTURE)
+               fprintf(stderr, "%s: Validating texture %p now\n", __FUNCTION__, texObj);
+
+       if (baseimage->base.Border > 0)
+               return GL_FALSE;
+
+       /* Ensure a matching miptree exists.
+        *
+        * Differing mipmap trees can result when the app uses TexImage to
+        * change texture dimensions.
+        *
+        * Prefer to use base image's miptree if it
+        * exists, since that most likely contains more valid data (remember
+        * that the base level is usually significantly larger than the rest
+        * of the miptree, so cubemaps are the only possible exception).
+        */
+       if (baseimage->mt &&
+           baseimage->mt != t->mt &&
+           radeon_miptree_matches_texture(baseimage->mt, &t->base)) {
+               radeon_miptree_unreference(t->mt);
+               t->mt = baseimage->mt;
+               radeon_miptree_reference(t->mt);
+       } else if (t->mt && !radeon_miptree_matches_texture(t->mt, &t->base)) {
+               radeon_miptree_unreference(t->mt);
+               t->mt = 0;
+       }
+
+       if (!t->mt) {
+               if (RADEON_DEBUG & DEBUG_TEXTURE)
+                       fprintf(stderr, " Allocate new miptree\n");
+               radeon_try_alloc_miptree(rmesa, t, &baseimage->base, 0, texObj->BaseLevel);
+               if (!t->mt) {
+                       _mesa_problem(ctx, "r300_validate_texture failed to alloc miptree");
+                       return GL_FALSE;
+               }
+       }
+
+       /* Ensure all images are stored in the single main miptree */
+       for(face = 0; face < t->mt->faces; ++face) {
+               for(level = t->mt->firstLevel; level <= t->mt->lastLevel; ++level) {
+                       radeon_texture_image *image = get_radeon_texture_image(texObj->Image[face][level]);
+                       if (RADEON_DEBUG & DEBUG_TEXTURE)
+                               fprintf(stderr, " face %i, level %i... %p vs %p ", face, level, t->mt, image->mt);
+                       if (t->mt == image->mt) {
+                               if (RADEON_DEBUG & DEBUG_TEXTURE)
+                                       fprintf(stderr, "OK\n");
+                               continue;
+                       }
+
+                       if (RADEON_DEBUG & DEBUG_TEXTURE)
+                               fprintf(stderr, "migrating\n");
+                       migrate_image_to_miptree(t->mt, image, face, level);
+               }
+       }
+
+       return GL_TRUE;
+}
+
+
+/**
+ * Need to map texture image into memory before copying image data,
+ * then unmap it.
+ */
+static void
+radeon_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)
+{
+       radeon_texture_image *image = get_radeon_texture_image(texImage);
+
+       if (image->mt) {
+               /* Map the texture image read-only */
+               radeon_teximage_map(image, GL_FALSE);
+       } else {
+               /* Image hasn't been uploaded to a miptree yet */
+               assert(image->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);
+       }
+     
+       if (image->mt) {
+               radeon_teximage_unmap(image);
+       }
+}
+
+void
+radeonGetTexImage(GLcontext * ctx, GLenum target, GLint level,
+                 GLenum format, GLenum type, GLvoid * pixels,
+                 struct gl_texture_object *texObj,
+                 struct gl_texture_image *texImage)
+{
+       radeon_get_tex_image(ctx, target, level, format, type, pixels,
+                            texObj, texImage, 0);
+}
+
+void
+radeonGetCompressedTexImage(GLcontext *ctx, GLenum target, GLint level,
+                           GLvoid *pixels,
+                           struct gl_texture_object *texObj,
+                           struct gl_texture_image *texImage)
+{
+       radeon_get_tex_image(ctx, target, level, 0, 0, pixels,
+                            texObj, texImage, 1);
+}
diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.h b/src/mesa/drivers/dri/radeon/radeon_texture.h
new file mode 100644 (file)
index 0000000..888a55b
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2008 Nicolai Haehnle.
+ * Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
+ *
+ * The Weather Channel (TM) funded Tungsten Graphics to develop the
+ * initial release of the Radeon 8500 driver under the XFree86 license.
+ * This notice must be preserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef RADEON_TEXTURE_H
+#define RADEON_TEXTURE_H
+struct gl_texture_image *radeonNewTextureImage(GLcontext *ctx);
+void radeonFreeTexImageData(GLcontext *ctx, struct gl_texture_image *timage);
+
+void radeon_teximage_map(radeon_texture_image *image, GLboolean write_enable);
+void radeon_teximage_unmap(radeon_texture_image *image);
+void radeonMapTexture(GLcontext *ctx, struct gl_texture_object *texObj);
+void radeonUnmapTexture(GLcontext *ctx, struct gl_texture_object *texObj);
+void radeonGenerateMipmap(GLcontext* ctx, GLenum target, struct gl_texture_object *texObj);
+int radeon_validate_texture_miptree(GLcontext * ctx, struct gl_texture_object *texObj);
+GLuint radeon_face_for_target(GLenum target);
+const struct gl_texture_format *radeonChooseTextureFormat_mesa(GLcontext * ctx,
+                                                         GLint internalFormat,
+                                                         GLenum format,
+                                                         GLenum type);
+const struct gl_texture_format *radeonChooseTextureFormat(GLcontext * ctx,
+                                                         GLint internalFormat,
+                                                         GLenum format,
+                                                         GLenum type, GLboolean fbo);
+
+void radeonTexImage1D(GLcontext * ctx, GLenum target, GLint level,
+                     GLint internalFormat,
+                     GLint width, GLint border,
+                     GLenum format, GLenum type, const GLvoid * pixels,
+                     const struct gl_pixelstore_attrib *packing,
+                     struct gl_texture_object *texObj,
+                     struct gl_texture_image *texImage);
+void radeonTexImage2D(GLcontext * ctx, GLenum target, GLint level,
+                     GLint internalFormat,
+                     GLint width, GLint height, GLint border,
+                     GLenum format, GLenum type, const GLvoid * pixels,
+                     const struct gl_pixelstore_attrib *packing,
+                     struct gl_texture_object *texObj,
+                     struct gl_texture_image *texImage);
+void radeonCompressedTexImage2D(GLcontext * ctx, GLenum target,
+                               GLint level, GLint internalFormat,
+                               GLint width, GLint height, GLint border,
+                               GLsizei imageSize, const GLvoid * data,
+                               struct gl_texture_object *texObj,
+                               struct gl_texture_image *texImage);
+void radeonTexImage3D(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);
+void radeonTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
+                        GLint xoffset,
+                        GLsizei width,
+                        GLenum format, GLenum type,
+                        const GLvoid * pixels,
+                        const struct gl_pixelstore_attrib *packing,
+                        struct gl_texture_object *texObj,
+                        struct gl_texture_image *texImage);
+void radeonTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
+                               GLint xoffset, GLint yoffset,
+                               GLsizei width, GLsizei height,
+                               GLenum format, GLenum type,
+                               const GLvoid * pixels,
+                               const struct gl_pixelstore_attrib *packing,
+                               struct gl_texture_object *texObj,
+                               struct gl_texture_image *texImage);
+void radeonCompressedTexSubImage2D(GLcontext * ctx, GLenum target,
+                                  GLint level, GLint xoffset,
+                                  GLint yoffset, GLsizei width,
+                                  GLsizei height, GLenum format,
+                                  GLsizei imageSize, const GLvoid * data,
+                                  struct gl_texture_object *texObj,
+                                  struct gl_texture_image *texImage);
+
+void radeonTexSubImage3D(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 radeonGetTexImage(GLcontext * ctx, GLenum target, GLint level,
+                      GLenum format, GLenum type, GLvoid * pixels,
+                      struct gl_texture_object *texObj,
+                      struct gl_texture_image *texImage);
+void radeonGetCompressedTexImage(GLcontext *ctx, GLenum target, GLint level,
+                                GLvoid *pixels,
+                                struct gl_texture_object *texObj,
+                                struct gl_texture_image *texImage);
+
+#endif
index ae2ccdf292a099694d5f0b84976b404a05591cbe..866807462a4302c8c6983a52d06020417e839d4c 100644 (file)
 #define RADEON_CP_PACKET3_3D_DRAW_INDX              0xC0002A00
 #define RADEON_CP_PACKET3_LOAD_PALETTE              0xC0002C00
 #define RADEON_CP_PACKET3_3D_LOAD_VBPNTR            0xC0002F00
+#define R200_CP_CMD_3D_DRAW_VBUF_2      0xC0003400
+#define R200_CP_CMD_3D_DRAW_IMMD_2      0xC0003500
+#define R200_CP_CMD_3D_DRAW_INDX_2      0xC0003600
 #define RADEON_CP_PACKET3_CNTL_PAINT                0xC0009100
 #define RADEON_CP_PACKET3_CNTL_BITBLT               0xC0009200
 #define RADEON_CP_PACKET3_CNTL_SMALLTEXT            0xC0009300
index 305df548fa277cf18b7c7c59681e9d0f2c49e83e..9a01465bdf9420b88cf2c2a306feb01f260bc3cc 100644 (file)
@@ -912,8 +912,9 @@ xmesa_update_state( GLcontext *ctx, GLbitfield new_state )
    /*
     * GL_DITHER, GL_READ/DRAW_BUFFER, buffer binding state, etc. effect
     * renderbuffer span/clear funcs.
+    * Check _NEW_COLOR to detect dither enable/disable.
     */
-   if (new_state & (_NEW_COLOR | _NEW_PIXEL | _NEW_BUFFERS)) {
+   if (new_state & (_NEW_COLOR | _NEW_BUFFERS)) {
       XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
       struct xmesa_renderbuffer *front_xrb, *back_xrb;
 
diff --git a/src/mesa/glapi/ARB_copy_buffer.xml b/src/mesa/glapi/ARB_copy_buffer.xml
new file mode 100644 (file)
index 0000000..719816d
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
+
+<!-- Note: no GLX protocol info yet. -->
+
+
+<OpenGLAPI>
+
+<category name="GL_ARB_copy_buffer" number="59">
+
+    <enum name="COPY_READ_BUFFER"   value="0x8F36"/>
+    <enum name="COPY_WRITE_BUFFER"  value="0x8F37"/>
+
+    <function name="CopyBufferSubData" offset="assign">
+        <param name="readTarget" type="GLenum"/>
+        <param name="writeTarget" type="GLenum"/>
+        <param name="readOffset" type="GLintptr"/>
+        <param name="writeOffset" type="GLintptr"/>
+        <param name="size" type="GLsizeiptr"/>
+    </function>
+
+</category>
+
+</OpenGLAPI>
diff --git a/src/mesa/glapi/ARB_map_buffer_range.xml b/src/mesa/glapi/ARB_map_buffer_range.xml
new file mode 100644 (file)
index 0000000..afcb9b6
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
+
+<!-- Note: no GLX protocol info yet. -->
+
+
+<OpenGLAPI>
+
+<category name="GL_ARB_map_buffer_range" number="50">
+
+    <enum name="MAP_READ_BIT"                value="0x0001"/>
+    <enum name="MAP_WRITE_BIT"               value="0x0002"/>
+    <enum name="MAP_INVALIDATE_RANGE_BIT"    value="0x0004"/>
+    <enum name="MAP_INVALIDATE_BUFFER_BIT"   value="0x0008"/>
+    <enum name="MAP_FLUSH_EXPLICIT_BIT"      value="0x0010"/>
+    <enum name="MAP_UNSYNCHRONIZED_BIT"      value="0x0020"/>
+
+    <function name="MapBufferRange" offset="assign">
+        <param name="target" type="GLenum"/>
+        <param name="offset" type="GLintptr"/>
+        <param name="length" type="GLsizeiptr"/>
+        <param name="access" type="GLbitfield"/>
+        <return type="GLvoid *"/>
+    </function>
+
+    <function name="FlushMappedBufferRange" offset="assign">
+        <param name="target" type="GLenum"/>
+        <param name="offset" type="GLintptr"/>
+        <param name="length" type="GLsizeiptr"/>
+    </function>
+
+</category>
+
+</OpenGLAPI>
index f524167a47565cc8fb3372e35fefcc68074aedca..b5363500680508e126affa2901afe8f6556a1d8d 100644 (file)
@@ -47,7 +47,9 @@ SERVER_OUTPUTS = \
 
 API_XML = gl_API.xml \
        EXT_framebuffer_object.xml \
+       ARB_copy_buffer.xml \
        ARB_framebuffer_object.xml \
+       ARB_map_buffer_range.xml \
        APPLE_vertex_array_object.xml
 
 COMMON = gl_XML.py glX_XML.py license.py $(API_XML) typeexpr.py
index 45b2fa077ae05c899b01f9f6879e878f89cd5e49..0ceec40284ec62a54bcdb802a90524c870b14c69 100644 (file)
 #define CALL_RenderbufferStorageMultisample(disp, parameters) (*((disp)->RenderbufferStorageMultisample)) parameters
 #define GET_RenderbufferStorageMultisample(disp) ((disp)->RenderbufferStorageMultisample)
 #define SET_RenderbufferStorageMultisample(disp, fn) ((disp)->RenderbufferStorageMultisample = fn)
+#define CALL_FlushMappedBufferRange(disp, parameters) (*((disp)->FlushMappedBufferRange)) parameters
+#define GET_FlushMappedBufferRange(disp) ((disp)->FlushMappedBufferRange)
+#define SET_FlushMappedBufferRange(disp, fn) ((disp)->FlushMappedBufferRange = fn)
+#define CALL_MapBufferRange(disp, parameters) (*((disp)->MapBufferRange)) parameters
+#define GET_MapBufferRange(disp) ((disp)->MapBufferRange)
+#define SET_MapBufferRange(disp, fn) ((disp)->MapBufferRange = fn)
+#define CALL_CopyBufferSubData(disp, parameters) (*((disp)->CopyBufferSubData)) parameters
+#define GET_CopyBufferSubData(disp) ((disp)->CopyBufferSubData)
+#define SET_CopyBufferSubData(disp, fn) ((disp)->CopyBufferSubData = fn)
 #define CALL_PolygonOffsetEXT(disp, parameters) (*((disp)->PolygonOffsetEXT)) parameters
 #define GET_PolygonOffsetEXT(disp) ((disp)->PolygonOffsetEXT)
 #define SET_PolygonOffsetEXT(disp, fn) ((disp)->PolygonOffsetEXT = fn)
 
 #else
 
-#define driDispatchRemapTable_size 367
+#define driDispatchRemapTable_size 370
 extern int driDispatchRemapTable[ driDispatchRemapTable_size ];
 
 #define AttachShader_remap_index 0
@@ -2545,219 +2554,222 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ];
 #define GetAttribLocationARB_remap_index 151
 #define DrawBuffersARB_remap_index 152
 #define RenderbufferStorageMultisample_remap_index 153
-#define PolygonOffsetEXT_remap_index 154
-#define GetPixelTexGenParameterfvSGIS_remap_index 155
-#define GetPixelTexGenParameterivSGIS_remap_index 156
-#define PixelTexGenParameterfSGIS_remap_index 157
-#define PixelTexGenParameterfvSGIS_remap_index 158
-#define PixelTexGenParameteriSGIS_remap_index 159
-#define PixelTexGenParameterivSGIS_remap_index 160
-#define SampleMaskSGIS_remap_index 161
-#define SamplePatternSGIS_remap_index 162
-#define ColorPointerEXT_remap_index 163
-#define EdgeFlagPointerEXT_remap_index 164
-#define IndexPointerEXT_remap_index 165
-#define NormalPointerEXT_remap_index 166
-#define TexCoordPointerEXT_remap_index 167
-#define VertexPointerEXT_remap_index 168
-#define PointParameterfEXT_remap_index 169
-#define PointParameterfvEXT_remap_index 170
-#define LockArraysEXT_remap_index 171
-#define UnlockArraysEXT_remap_index 172
-#define CullParameterdvEXT_remap_index 173
-#define CullParameterfvEXT_remap_index 174
-#define SecondaryColor3bEXT_remap_index 175
-#define SecondaryColor3bvEXT_remap_index 176
-#define SecondaryColor3dEXT_remap_index 177
-#define SecondaryColor3dvEXT_remap_index 178
-#define SecondaryColor3fEXT_remap_index 179
-#define SecondaryColor3fvEXT_remap_index 180
-#define SecondaryColor3iEXT_remap_index 181
-#define SecondaryColor3ivEXT_remap_index 182
-#define SecondaryColor3sEXT_remap_index 183
-#define SecondaryColor3svEXT_remap_index 184
-#define SecondaryColor3ubEXT_remap_index 185
-#define SecondaryColor3ubvEXT_remap_index 186
-#define SecondaryColor3uiEXT_remap_index 187
-#define SecondaryColor3uivEXT_remap_index 188
-#define SecondaryColor3usEXT_remap_index 189
-#define SecondaryColor3usvEXT_remap_index 190
-#define SecondaryColorPointerEXT_remap_index 191
-#define MultiDrawArraysEXT_remap_index 192
-#define MultiDrawElementsEXT_remap_index 193
-#define FogCoordPointerEXT_remap_index 194
-#define FogCoorddEXT_remap_index 195
-#define FogCoorddvEXT_remap_index 196
-#define FogCoordfEXT_remap_index 197
-#define FogCoordfvEXT_remap_index 198
-#define PixelTexGenSGIX_remap_index 199
-#define BlendFuncSeparateEXT_remap_index 200
-#define FlushVertexArrayRangeNV_remap_index 201
-#define VertexArrayRangeNV_remap_index 202
-#define CombinerInputNV_remap_index 203
-#define CombinerOutputNV_remap_index 204
-#define CombinerParameterfNV_remap_index 205
-#define CombinerParameterfvNV_remap_index 206
-#define CombinerParameteriNV_remap_index 207
-#define CombinerParameterivNV_remap_index 208
-#define FinalCombinerInputNV_remap_index 209
-#define GetCombinerInputParameterfvNV_remap_index 210
-#define GetCombinerInputParameterivNV_remap_index 211
-#define GetCombinerOutputParameterfvNV_remap_index 212
-#define GetCombinerOutputParameterivNV_remap_index 213
-#define GetFinalCombinerInputParameterfvNV_remap_index 214
-#define GetFinalCombinerInputParameterivNV_remap_index 215
-#define ResizeBuffersMESA_remap_index 216
-#define WindowPos2dMESA_remap_index 217
-#define WindowPos2dvMESA_remap_index 218
-#define WindowPos2fMESA_remap_index 219
-#define WindowPos2fvMESA_remap_index 220
-#define WindowPos2iMESA_remap_index 221
-#define WindowPos2ivMESA_remap_index 222
-#define WindowPos2sMESA_remap_index 223
-#define WindowPos2svMESA_remap_index 224
-#define WindowPos3dMESA_remap_index 225
-#define WindowPos3dvMESA_remap_index 226
-#define WindowPos3fMESA_remap_index 227
-#define WindowPos3fvMESA_remap_index 228
-#define WindowPos3iMESA_remap_index 229
-#define WindowPos3ivMESA_remap_index 230
-#define WindowPos3sMESA_remap_index 231
-#define WindowPos3svMESA_remap_index 232
-#define WindowPos4dMESA_remap_index 233
-#define WindowPos4dvMESA_remap_index 234
-#define WindowPos4fMESA_remap_index 235
-#define WindowPos4fvMESA_remap_index 236
-#define WindowPos4iMESA_remap_index 237
-#define WindowPos4ivMESA_remap_index 238
-#define WindowPos4sMESA_remap_index 239
-#define WindowPos4svMESA_remap_index 240
-#define MultiModeDrawArraysIBM_remap_index 241
-#define MultiModeDrawElementsIBM_remap_index 242
-#define DeleteFencesNV_remap_index 243
-#define FinishFenceNV_remap_index 244
-#define GenFencesNV_remap_index 245
-#define GetFenceivNV_remap_index 246
-#define IsFenceNV_remap_index 247
-#define SetFenceNV_remap_index 248
-#define TestFenceNV_remap_index 249
-#define AreProgramsResidentNV_remap_index 250
-#define BindProgramNV_remap_index 251
-#define DeleteProgramsNV_remap_index 252
-#define ExecuteProgramNV_remap_index 253
-#define GenProgramsNV_remap_index 254
-#define GetProgramParameterdvNV_remap_index 255
-#define GetProgramParameterfvNV_remap_index 256
-#define GetProgramStringNV_remap_index 257
-#define GetProgramivNV_remap_index 258
-#define GetTrackMatrixivNV_remap_index 259
-#define GetVertexAttribPointervNV_remap_index 260
-#define GetVertexAttribdvNV_remap_index 261
-#define GetVertexAttribfvNV_remap_index 262
-#define GetVertexAttribivNV_remap_index 263
-#define IsProgramNV_remap_index 264
-#define LoadProgramNV_remap_index 265
-#define ProgramParameters4dvNV_remap_index 266
-#define ProgramParameters4fvNV_remap_index 267
-#define RequestResidentProgramsNV_remap_index 268
-#define TrackMatrixNV_remap_index 269
-#define VertexAttrib1dNV_remap_index 270
-#define VertexAttrib1dvNV_remap_index 271
-#define VertexAttrib1fNV_remap_index 272
-#define VertexAttrib1fvNV_remap_index 273
-#define VertexAttrib1sNV_remap_index 274
-#define VertexAttrib1svNV_remap_index 275
-#define VertexAttrib2dNV_remap_index 276
-#define VertexAttrib2dvNV_remap_index 277
-#define VertexAttrib2fNV_remap_index 278
-#define VertexAttrib2fvNV_remap_index 279
-#define VertexAttrib2sNV_remap_index 280
-#define VertexAttrib2svNV_remap_index 281
-#define VertexAttrib3dNV_remap_index 282
-#define VertexAttrib3dvNV_remap_index 283
-#define VertexAttrib3fNV_remap_index 284
-#define VertexAttrib3fvNV_remap_index 285
-#define VertexAttrib3sNV_remap_index 286
-#define VertexAttrib3svNV_remap_index 287
-#define VertexAttrib4dNV_remap_index 288
-#define VertexAttrib4dvNV_remap_index 289
-#define VertexAttrib4fNV_remap_index 290
-#define VertexAttrib4fvNV_remap_index 291
-#define VertexAttrib4sNV_remap_index 292
-#define VertexAttrib4svNV_remap_index 293
-#define VertexAttrib4ubNV_remap_index 294
-#define VertexAttrib4ubvNV_remap_index 295
-#define VertexAttribPointerNV_remap_index 296
-#define VertexAttribs1dvNV_remap_index 297
-#define VertexAttribs1fvNV_remap_index 298
-#define VertexAttribs1svNV_remap_index 299
-#define VertexAttribs2dvNV_remap_index 300
-#define VertexAttribs2fvNV_remap_index 301
-#define VertexAttribs2svNV_remap_index 302
-#define VertexAttribs3dvNV_remap_index 303
-#define VertexAttribs3fvNV_remap_index 304
-#define VertexAttribs3svNV_remap_index 305
-#define VertexAttribs4dvNV_remap_index 306
-#define VertexAttribs4fvNV_remap_index 307
-#define VertexAttribs4svNV_remap_index 308
-#define VertexAttribs4ubvNV_remap_index 309
-#define GetTexBumpParameterfvATI_remap_index 310
-#define GetTexBumpParameterivATI_remap_index 311
-#define TexBumpParameterfvATI_remap_index 312
-#define TexBumpParameterivATI_remap_index 313
-#define AlphaFragmentOp1ATI_remap_index 314
-#define AlphaFragmentOp2ATI_remap_index 315
-#define AlphaFragmentOp3ATI_remap_index 316
-#define BeginFragmentShaderATI_remap_index 317
-#define BindFragmentShaderATI_remap_index 318
-#define ColorFragmentOp1ATI_remap_index 319
-#define ColorFragmentOp2ATI_remap_index 320
-#define ColorFragmentOp3ATI_remap_index 321
-#define DeleteFragmentShaderATI_remap_index 322
-#define EndFragmentShaderATI_remap_index 323
-#define GenFragmentShadersATI_remap_index 324
-#define PassTexCoordATI_remap_index 325
-#define SampleMapATI_remap_index 326
-#define SetFragmentShaderConstantATI_remap_index 327
-#define PointParameteriNV_remap_index 328
-#define PointParameterivNV_remap_index 329
-#define ActiveStencilFaceEXT_remap_index 330
-#define BindVertexArrayAPPLE_remap_index 331
-#define DeleteVertexArraysAPPLE_remap_index 332
-#define GenVertexArraysAPPLE_remap_index 333
-#define IsVertexArrayAPPLE_remap_index 334
-#define GetProgramNamedParameterdvNV_remap_index 335
-#define GetProgramNamedParameterfvNV_remap_index 336
-#define ProgramNamedParameter4dNV_remap_index 337
-#define ProgramNamedParameter4dvNV_remap_index 338
-#define ProgramNamedParameter4fNV_remap_index 339
-#define ProgramNamedParameter4fvNV_remap_index 340
-#define DepthBoundsEXT_remap_index 341
-#define BlendEquationSeparateEXT_remap_index 342
-#define BindFramebufferEXT_remap_index 343
-#define BindRenderbufferEXT_remap_index 344
-#define CheckFramebufferStatusEXT_remap_index 345
-#define DeleteFramebuffersEXT_remap_index 346
-#define DeleteRenderbuffersEXT_remap_index 347
-#define FramebufferRenderbufferEXT_remap_index 348
-#define FramebufferTexture1DEXT_remap_index 349
-#define FramebufferTexture2DEXT_remap_index 350
-#define FramebufferTexture3DEXT_remap_index 351
-#define GenFramebuffersEXT_remap_index 352
-#define GenRenderbuffersEXT_remap_index 353
-#define GenerateMipmapEXT_remap_index 354
-#define GetFramebufferAttachmentParameterivEXT_remap_index 355
-#define GetRenderbufferParameterivEXT_remap_index 356
-#define IsFramebufferEXT_remap_index 357
-#define IsRenderbufferEXT_remap_index 358
-#define RenderbufferStorageEXT_remap_index 359
-#define BlitFramebufferEXT_remap_index 360
-#define FramebufferTextureLayerEXT_remap_index 361
-#define StencilFuncSeparateATI_remap_index 362
-#define ProgramEnvParameters4fvEXT_remap_index 363
-#define ProgramLocalParameters4fvEXT_remap_index 364
-#define GetQueryObjecti64vEXT_remap_index 365
-#define GetQueryObjectui64vEXT_remap_index 366
+#define FlushMappedBufferRange_remap_index 154
+#define MapBufferRange_remap_index 155
+#define CopyBufferSubData_remap_index 156
+#define PolygonOffsetEXT_remap_index 157
+#define GetPixelTexGenParameterfvSGIS_remap_index 158
+#define GetPixelTexGenParameterivSGIS_remap_index 159
+#define PixelTexGenParameterfSGIS_remap_index 160
+#define PixelTexGenParameterfvSGIS_remap_index 161
+#define PixelTexGenParameteriSGIS_remap_index 162
+#define PixelTexGenParameterivSGIS_remap_index 163
+#define SampleMaskSGIS_remap_index 164
+#define SamplePatternSGIS_remap_index 165
+#define ColorPointerEXT_remap_index 166
+#define EdgeFlagPointerEXT_remap_index 167
+#define IndexPointerEXT_remap_index 168
+#define NormalPointerEXT_remap_index 169
+#define TexCoordPointerEXT_remap_index 170
+#define VertexPointerEXT_remap_index 171
+#define PointParameterfEXT_remap_index 172
+#define PointParameterfvEXT_remap_index 173
+#define LockArraysEXT_remap_index 174
+#define UnlockArraysEXT_remap_index 175
+#define CullParameterdvEXT_remap_index 176
+#define CullParameterfvEXT_remap_index 177
+#define SecondaryColor3bEXT_remap_index 178
+#define SecondaryColor3bvEXT_remap_index 179
+#define SecondaryColor3dEXT_remap_index 180
+#define SecondaryColor3dvEXT_remap_index 181
+#define SecondaryColor3fEXT_remap_index 182
+#define SecondaryColor3fvEXT_remap_index 183
+#define SecondaryColor3iEXT_remap_index 184
+#define SecondaryColor3ivEXT_remap_index 185
+#define SecondaryColor3sEXT_remap_index 186
+#define SecondaryColor3svEXT_remap_index 187
+#define SecondaryColor3ubEXT_remap_index 188
+#define SecondaryColor3ubvEXT_remap_index 189
+#define SecondaryColor3uiEXT_remap_index 190
+#define SecondaryColor3uivEXT_remap_index 191
+#define SecondaryColor3usEXT_remap_index 192
+#define SecondaryColor3usvEXT_remap_index 193
+#define SecondaryColorPointerEXT_remap_index 194
+#define MultiDrawArraysEXT_remap_index 195
+#define MultiDrawElementsEXT_remap_index 196
+#define FogCoordPointerEXT_remap_index 197
+#define FogCoorddEXT_remap_index 198
+#define FogCoorddvEXT_remap_index 199
+#define FogCoordfEXT_remap_index 200
+#define FogCoordfvEXT_remap_index 201
+#define PixelTexGenSGIX_remap_index 202
+#define BlendFuncSeparateEXT_remap_index 203
+#define FlushVertexArrayRangeNV_remap_index 204
+#define VertexArrayRangeNV_remap_index 205
+#define CombinerInputNV_remap_index 206
+#define CombinerOutputNV_remap_index 207
+#define CombinerParameterfNV_remap_index 208
+#define CombinerParameterfvNV_remap_index 209
+#define CombinerParameteriNV_remap_index 210
+#define CombinerParameterivNV_remap_index 211
+#define FinalCombinerInputNV_remap_index 212
+#define GetCombinerInputParameterfvNV_remap_index 213
+#define GetCombinerInputParameterivNV_remap_index 214
+#define GetCombinerOutputParameterfvNV_remap_index 215
+#define GetCombinerOutputParameterivNV_remap_index 216
+#define GetFinalCombinerInputParameterfvNV_remap_index 217
+#define GetFinalCombinerInputParameterivNV_remap_index 218
+#define ResizeBuffersMESA_remap_index 219
+#define WindowPos2dMESA_remap_index 220
+#define WindowPos2dvMESA_remap_index 221
+#define WindowPos2fMESA_remap_index 222
+#define WindowPos2fvMESA_remap_index 223
+#define WindowPos2iMESA_remap_index 224
+#define WindowPos2ivMESA_remap_index 225
+#define WindowPos2sMESA_remap_index 226
+#define WindowPos2svMESA_remap_index 227
+#define WindowPos3dMESA_remap_index 228
+#define WindowPos3dvMESA_remap_index 229
+#define WindowPos3fMESA_remap_index 230
+#define WindowPos3fvMESA_remap_index 231
+#define WindowPos3iMESA_remap_index 232
+#define WindowPos3ivMESA_remap_index 233
+#define WindowPos3sMESA_remap_index 234
+#define WindowPos3svMESA_remap_index 235
+#define WindowPos4dMESA_remap_index 236
+#define WindowPos4dvMESA_remap_index 237
+#define WindowPos4fMESA_remap_index 238
+#define WindowPos4fvMESA_remap_index 239
+#define WindowPos4iMESA_remap_index 240
+#define WindowPos4ivMESA_remap_index 241
+#define WindowPos4sMESA_remap_index 242
+#define WindowPos4svMESA_remap_index 243
+#define MultiModeDrawArraysIBM_remap_index 244
+#define MultiModeDrawElementsIBM_remap_index 245
+#define DeleteFencesNV_remap_index 246
+#define FinishFenceNV_remap_index 247
+#define GenFencesNV_remap_index 248
+#define GetFenceivNV_remap_index 249
+#define IsFenceNV_remap_index 250
+#define SetFenceNV_remap_index 251
+#define TestFenceNV_remap_index 252
+#define AreProgramsResidentNV_remap_index 253
+#define BindProgramNV_remap_index 254
+#define DeleteProgramsNV_remap_index 255
+#define ExecuteProgramNV_remap_index 256
+#define GenProgramsNV_remap_index 257
+#define GetProgramParameterdvNV_remap_index 258
+#define GetProgramParameterfvNV_remap_index 259
+#define GetProgramStringNV_remap_index 260
+#define GetProgramivNV_remap_index 261
+#define GetTrackMatrixivNV_remap_index 262
+#define GetVertexAttribPointervNV_remap_index 263
+#define GetVertexAttribdvNV_remap_index 264
+#define GetVertexAttribfvNV_remap_index 265
+#define GetVertexAttribivNV_remap_index 266
+#define IsProgramNV_remap_index 267
+#define LoadProgramNV_remap_index 268
+#define ProgramParameters4dvNV_remap_index 269
+#define ProgramParameters4fvNV_remap_index 270
+#define RequestResidentProgramsNV_remap_index 271
+#define TrackMatrixNV_remap_index 272
+#define VertexAttrib1dNV_remap_index 273
+#define VertexAttrib1dvNV_remap_index 274
+#define VertexAttrib1fNV_remap_index 275
+#define VertexAttrib1fvNV_remap_index 276
+#define VertexAttrib1sNV_remap_index 277
+#define VertexAttrib1svNV_remap_index 278
+#define VertexAttrib2dNV_remap_index 279
+#define VertexAttrib2dvNV_remap_index 280
+#define VertexAttrib2fNV_remap_index 281
+#define VertexAttrib2fvNV_remap_index 282
+#define VertexAttrib2sNV_remap_index 283
+#define VertexAttrib2svNV_remap_index 284
+#define VertexAttrib3dNV_remap_index 285
+#define VertexAttrib3dvNV_remap_index 286
+#define VertexAttrib3fNV_remap_index 287
+#define VertexAttrib3fvNV_remap_index 288
+#define VertexAttrib3sNV_remap_index 289
+#define VertexAttrib3svNV_remap_index 290
+#define VertexAttrib4dNV_remap_index 291
+#define VertexAttrib4dvNV_remap_index 292
+#define VertexAttrib4fNV_remap_index 293
+#define VertexAttrib4fvNV_remap_index 294
+#define VertexAttrib4sNV_remap_index 295
+#define VertexAttrib4svNV_remap_index 296
+#define VertexAttrib4ubNV_remap_index 297
+#define VertexAttrib4ubvNV_remap_index 298
+#define VertexAttribPointerNV_remap_index 299
+#define VertexAttribs1dvNV_remap_index 300
+#define VertexAttribs1fvNV_remap_index 301
+#define VertexAttribs1svNV_remap_index 302
+#define VertexAttribs2dvNV_remap_index 303
+#define VertexAttribs2fvNV_remap_index 304
+#define VertexAttribs2svNV_remap_index 305
+#define VertexAttribs3dvNV_remap_index 306
+#define VertexAttribs3fvNV_remap_index 307
+#define VertexAttribs3svNV_remap_index 308
+#define VertexAttribs4dvNV_remap_index 309
+#define VertexAttribs4fvNV_remap_index 310
+#define VertexAttribs4svNV_remap_index 311
+#define VertexAttribs4ubvNV_remap_index 312
+#define GetTexBumpParameterfvATI_remap_index 313
+#define GetTexBumpParameterivATI_remap_index 314
+#define TexBumpParameterfvATI_remap_index 315
+#define TexBumpParameterivATI_remap_index 316
+#define AlphaFragmentOp1ATI_remap_index 317
+#define AlphaFragmentOp2ATI_remap_index 318
+#define AlphaFragmentOp3ATI_remap_index 319
+#define BeginFragmentShaderATI_remap_index 320
+#define BindFragmentShaderATI_remap_index 321
+#define ColorFragmentOp1ATI_remap_index 322
+#define ColorFragmentOp2ATI_remap_index 323
+#define ColorFragmentOp3ATI_remap_index 324
+#define DeleteFragmentShaderATI_remap_index 325
+#define EndFragmentShaderATI_remap_index 326
+#define GenFragmentShadersATI_remap_index 327
+#define PassTexCoordATI_remap_index 328
+#define SampleMapATI_remap_index 329
+#define SetFragmentShaderConstantATI_remap_index 330
+#define PointParameteriNV_remap_index 331
+#define PointParameterivNV_remap_index 332
+#define ActiveStencilFaceEXT_remap_index 333
+#define BindVertexArrayAPPLE_remap_index 334
+#define DeleteVertexArraysAPPLE_remap_index 335
+#define GenVertexArraysAPPLE_remap_index 336
+#define IsVertexArrayAPPLE_remap_index 337
+#define GetProgramNamedParameterdvNV_remap_index 338
+#define GetProgramNamedParameterfvNV_remap_index 339
+#define ProgramNamedParameter4dNV_remap_index 340
+#define ProgramNamedParameter4dvNV_remap_index 341
+#define ProgramNamedParameter4fNV_remap_index 342
+#define ProgramNamedParameter4fvNV_remap_index 343
+#define DepthBoundsEXT_remap_index 344
+#define BlendEquationSeparateEXT_remap_index 345
+#define BindFramebufferEXT_remap_index 346
+#define BindRenderbufferEXT_remap_index 347
+#define CheckFramebufferStatusEXT_remap_index 348
+#define DeleteFramebuffersEXT_remap_index 349
+#define DeleteRenderbuffersEXT_remap_index 350
+#define FramebufferRenderbufferEXT_remap_index 351
+#define FramebufferTexture1DEXT_remap_index 352
+#define FramebufferTexture2DEXT_remap_index 353
+#define FramebufferTexture3DEXT_remap_index 354
+#define GenFramebuffersEXT_remap_index 355
+#define GenRenderbuffersEXT_remap_index 356
+#define GenerateMipmapEXT_remap_index 357
+#define GetFramebufferAttachmentParameterivEXT_remap_index 358
+#define GetRenderbufferParameterivEXT_remap_index 359
+#define IsFramebufferEXT_remap_index 360
+#define IsRenderbufferEXT_remap_index 361
+#define RenderbufferStorageEXT_remap_index 362
+#define BlitFramebufferEXT_remap_index 363
+#define FramebufferTextureLayerEXT_remap_index 364
+#define StencilFuncSeparateATI_remap_index 365
+#define ProgramEnvParameters4fvEXT_remap_index 366
+#define ProgramLocalParameters4fvEXT_remap_index 367
+#define GetQueryObjecti64vEXT_remap_index 368
+#define GetQueryObjectui64vEXT_remap_index 369
 
 #define CALL_AttachShader(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint)), driDispatchRemapTable[AttachShader_remap_index], parameters)
 #define GET_AttachShader(disp) GET_by_offset(disp, driDispatchRemapTable[AttachShader_remap_index])
@@ -3221,6 +3233,15 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ];
 #define CALL_RenderbufferStorageMultisample(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLenum, GLsizei, GLsizei)), driDispatchRemapTable[RenderbufferStorageMultisample_remap_index], parameters)
 #define GET_RenderbufferStorageMultisample(disp) GET_by_offset(disp, driDispatchRemapTable[RenderbufferStorageMultisample_remap_index])
 #define SET_RenderbufferStorageMultisample(disp, fn) SET_by_offset(disp, driDispatchRemapTable[RenderbufferStorageMultisample_remap_index], fn)
+#define CALL_FlushMappedBufferRange(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLintptr, GLsizeiptr)), driDispatchRemapTable[FlushMappedBufferRange_remap_index], parameters)
+#define GET_FlushMappedBufferRange(disp) GET_by_offset(disp, driDispatchRemapTable[FlushMappedBufferRange_remap_index])
+#define SET_FlushMappedBufferRange(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FlushMappedBufferRange_remap_index], fn)
+#define CALL_MapBufferRange(disp, parameters) CALL_by_offset(disp, (GLvoid * (GLAPIENTRYP)(GLenum, GLintptr, GLsizeiptr, GLbitfield)), driDispatchRemapTable[MapBufferRange_remap_index], parameters)
+#define GET_MapBufferRange(disp) GET_by_offset(disp, driDispatchRemapTable[MapBufferRange_remap_index])
+#define SET_MapBufferRange(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MapBufferRange_remap_index], fn)
+#define CALL_CopyBufferSubData(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr)), driDispatchRemapTable[CopyBufferSubData_remap_index], parameters)
+#define GET_CopyBufferSubData(disp) GET_by_offset(disp, driDispatchRemapTable[CopyBufferSubData_remap_index])
+#define SET_CopyBufferSubData(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CopyBufferSubData_remap_index], fn)
 #define CALL_PolygonOffsetEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat)), driDispatchRemapTable[PolygonOffsetEXT_remap_index], parameters)
 #define GET_PolygonOffsetEXT(disp) GET_by_offset(disp, driDispatchRemapTable[PolygonOffsetEXT_remap_index])
 #define SET_PolygonOffsetEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PolygonOffsetEXT_remap_index], fn)
index 501706acc774af67650bad8c212f42c103965f33..daca1b767a3cbcaf47d3eed20430f91de61b058f 100644 (file)
@@ -373,9 +373,13 @@ const GLuint __glXDefaultPixelStore[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 };
                                print '{'
                                print '    __GLXcontext * const gc = __glXGetCurrentContext();'
                                print ''
+                               print '#ifdef GLX_DIRECT_RENDERING'
                                print '    if (gc->driContext) {'
                                print '    %sCALL_%s(GET_DISPATCH(), (%s));' % (ret_string, func.name, func.get_called_parameter_string())
-                               print '    } else {'
+                               print '    } else'
+                               print '#endif'
+                               print '    {'
+
                                footer = '}\n}\n'
                        else:
                                print '#define %s %d' % (func.opcode_name(), func.opcode_value())
index 4b66793e1cfbc9bcc067d430a26e6a90309faa90..1de1c91edb9721ce05749daf77863ab5c5e4b8fc 100644 (file)
 
 <xi:include href="ARB_framebuffer_object.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
 
+<xi:include href="ARB_copy_buffer.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+
+<xi:include href="ARB_map_buffer_range.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+
 
 <!-- Non-ARB extensions sorted by extension number. -->
 
index 14f305f0256290c8cdffa146044c0a83e5702795..580b6b66bcc3b08af2f275fb7349e2cc73de1dc5 100644 (file)
 #define _gloffset_GetAttribLocationARB 559
 #define _gloffset_DrawBuffersARB 560
 #define _gloffset_RenderbufferStorageMultisample 561
-#define _gloffset_PolygonOffsetEXT 562
-#define _gloffset_GetPixelTexGenParameterfvSGIS 563
-#define _gloffset_GetPixelTexGenParameterivSGIS 564
-#define _gloffset_PixelTexGenParameterfSGIS 565
-#define _gloffset_PixelTexGenParameterfvSGIS 566
-#define _gloffset_PixelTexGenParameteriSGIS 567
-#define _gloffset_PixelTexGenParameterivSGIS 568
-#define _gloffset_SampleMaskSGIS 569
-#define _gloffset_SamplePatternSGIS 570
-#define _gloffset_ColorPointerEXT 571
-#define _gloffset_EdgeFlagPointerEXT 572
-#define _gloffset_IndexPointerEXT 573
-#define _gloffset_NormalPointerEXT 574
-#define _gloffset_TexCoordPointerEXT 575
-#define _gloffset_VertexPointerEXT 576
-#define _gloffset_PointParameterfEXT 577
-#define _gloffset_PointParameterfvEXT 578
-#define _gloffset_LockArraysEXT 579
-#define _gloffset_UnlockArraysEXT 580
-#define _gloffset_CullParameterdvEXT 581
-#define _gloffset_CullParameterfvEXT 582
-#define _gloffset_SecondaryColor3bEXT 583
-#define _gloffset_SecondaryColor3bvEXT 584
-#define _gloffset_SecondaryColor3dEXT 585
-#define _gloffset_SecondaryColor3dvEXT 586
-#define _gloffset_SecondaryColor3fEXT 587
-#define _gloffset_SecondaryColor3fvEXT 588
-#define _gloffset_SecondaryColor3iEXT 589
-#define _gloffset_SecondaryColor3ivEXT 590
-#define _gloffset_SecondaryColor3sEXT 591
-#define _gloffset_SecondaryColor3svEXT 592
-#define _gloffset_SecondaryColor3ubEXT 593
-#define _gloffset_SecondaryColor3ubvEXT 594
-#define _gloffset_SecondaryColor3uiEXT 595
-#define _gloffset_SecondaryColor3uivEXT 596
-#define _gloffset_SecondaryColor3usEXT 597
-#define _gloffset_SecondaryColor3usvEXT 598
-#define _gloffset_SecondaryColorPointerEXT 599
-#define _gloffset_MultiDrawArraysEXT 600
-#define _gloffset_MultiDrawElementsEXT 601
-#define _gloffset_FogCoordPointerEXT 602
-#define _gloffset_FogCoorddEXT 603
-#define _gloffset_FogCoorddvEXT 604
-#define _gloffset_FogCoordfEXT 605
-#define _gloffset_FogCoordfvEXT 606
-#define _gloffset_PixelTexGenSGIX 607
-#define _gloffset_BlendFuncSeparateEXT 608
-#define _gloffset_FlushVertexArrayRangeNV 609
-#define _gloffset_VertexArrayRangeNV 610
-#define _gloffset_CombinerInputNV 611
-#define _gloffset_CombinerOutputNV 612
-#define _gloffset_CombinerParameterfNV 613
-#define _gloffset_CombinerParameterfvNV 614
-#define _gloffset_CombinerParameteriNV 615
-#define _gloffset_CombinerParameterivNV 616
-#define _gloffset_FinalCombinerInputNV 617
-#define _gloffset_GetCombinerInputParameterfvNV 618
-#define _gloffset_GetCombinerInputParameterivNV 619
-#define _gloffset_GetCombinerOutputParameterfvNV 620
-#define _gloffset_GetCombinerOutputParameterivNV 621
-#define _gloffset_GetFinalCombinerInputParameterfvNV 622
-#define _gloffset_GetFinalCombinerInputParameterivNV 623
-#define _gloffset_ResizeBuffersMESA 624
-#define _gloffset_WindowPos2dMESA 625
-#define _gloffset_WindowPos2dvMESA 626
-#define _gloffset_WindowPos2fMESA 627
-#define _gloffset_WindowPos2fvMESA 628
-#define _gloffset_WindowPos2iMESA 629
-#define _gloffset_WindowPos2ivMESA 630
-#define _gloffset_WindowPos2sMESA 631
-#define _gloffset_WindowPos2svMESA 632
-#define _gloffset_WindowPos3dMESA 633
-#define _gloffset_WindowPos3dvMESA 634
-#define _gloffset_WindowPos3fMESA 635
-#define _gloffset_WindowPos3fvMESA 636
-#define _gloffset_WindowPos3iMESA 637
-#define _gloffset_WindowPos3ivMESA 638
-#define _gloffset_WindowPos3sMESA 639
-#define _gloffset_WindowPos3svMESA 640
-#define _gloffset_WindowPos4dMESA 641
-#define _gloffset_WindowPos4dvMESA 642
-#define _gloffset_WindowPos4fMESA 643
-#define _gloffset_WindowPos4fvMESA 644
-#define _gloffset_WindowPos4iMESA 645
-#define _gloffset_WindowPos4ivMESA 646
-#define _gloffset_WindowPos4sMESA 647
-#define _gloffset_WindowPos4svMESA 648
-#define _gloffset_MultiModeDrawArraysIBM 649
-#define _gloffset_MultiModeDrawElementsIBM 650
-#define _gloffset_DeleteFencesNV 651
-#define _gloffset_FinishFenceNV 652
-#define _gloffset_GenFencesNV 653
-#define _gloffset_GetFenceivNV 654
-#define _gloffset_IsFenceNV 655
-#define _gloffset_SetFenceNV 656
-#define _gloffset_TestFenceNV 657
-#define _gloffset_AreProgramsResidentNV 658
-#define _gloffset_BindProgramNV 659
-#define _gloffset_DeleteProgramsNV 660
-#define _gloffset_ExecuteProgramNV 661
-#define _gloffset_GenProgramsNV 662
-#define _gloffset_GetProgramParameterdvNV 663
-#define _gloffset_GetProgramParameterfvNV 664
-#define _gloffset_GetProgramStringNV 665
-#define _gloffset_GetProgramivNV 666
-#define _gloffset_GetTrackMatrixivNV 667
-#define _gloffset_GetVertexAttribPointervNV 668
-#define _gloffset_GetVertexAttribdvNV 669
-#define _gloffset_GetVertexAttribfvNV 670
-#define _gloffset_GetVertexAttribivNV 671
-#define _gloffset_IsProgramNV 672
-#define _gloffset_LoadProgramNV 673
-#define _gloffset_ProgramParameters4dvNV 674
-#define _gloffset_ProgramParameters4fvNV 675
-#define _gloffset_RequestResidentProgramsNV 676
-#define _gloffset_TrackMatrixNV 677
-#define _gloffset_VertexAttrib1dNV 678
-#define _gloffset_VertexAttrib1dvNV 679
-#define _gloffset_VertexAttrib1fNV 680
-#define _gloffset_VertexAttrib1fvNV 681
-#define _gloffset_VertexAttrib1sNV 682
-#define _gloffset_VertexAttrib1svNV 683
-#define _gloffset_VertexAttrib2dNV 684
-#define _gloffset_VertexAttrib2dvNV 685
-#define _gloffset_VertexAttrib2fNV 686
-#define _gloffset_VertexAttrib2fvNV 687
-#define _gloffset_VertexAttrib2sNV 688
-#define _gloffset_VertexAttrib2svNV 689
-#define _gloffset_VertexAttrib3dNV 690
-#define _gloffset_VertexAttrib3dvNV 691
-#define _gloffset_VertexAttrib3fNV 692
-#define _gloffset_VertexAttrib3fvNV 693
-#define _gloffset_VertexAttrib3sNV 694
-#define _gloffset_VertexAttrib3svNV 695
-#define _gloffset_VertexAttrib4dNV 696
-#define _gloffset_VertexAttrib4dvNV 697
-#define _gloffset_VertexAttrib4fNV 698
-#define _gloffset_VertexAttrib4fvNV 699
-#define _gloffset_VertexAttrib4sNV 700
-#define _gloffset_VertexAttrib4svNV 701
-#define _gloffset_VertexAttrib4ubNV 702
-#define _gloffset_VertexAttrib4ubvNV 703
-#define _gloffset_VertexAttribPointerNV 704
-#define _gloffset_VertexAttribs1dvNV 705
-#define _gloffset_VertexAttribs1fvNV 706
-#define _gloffset_VertexAttribs1svNV 707
-#define _gloffset_VertexAttribs2dvNV 708
-#define _gloffset_VertexAttribs2fvNV 709
-#define _gloffset_VertexAttribs2svNV 710
-#define _gloffset_VertexAttribs3dvNV 711
-#define _gloffset_VertexAttribs3fvNV 712
-#define _gloffset_VertexAttribs3svNV 713
-#define _gloffset_VertexAttribs4dvNV 714
-#define _gloffset_VertexAttribs4fvNV 715
-#define _gloffset_VertexAttribs4svNV 716
-#define _gloffset_VertexAttribs4ubvNV 717
-#define _gloffset_GetTexBumpParameterfvATI 718
-#define _gloffset_GetTexBumpParameterivATI 719
-#define _gloffset_TexBumpParameterfvATI 720
-#define _gloffset_TexBumpParameterivATI 721
-#define _gloffset_AlphaFragmentOp1ATI 722
-#define _gloffset_AlphaFragmentOp2ATI 723
-#define _gloffset_AlphaFragmentOp3ATI 724
-#define _gloffset_BeginFragmentShaderATI 725
-#define _gloffset_BindFragmentShaderATI 726
-#define _gloffset_ColorFragmentOp1ATI 727
-#define _gloffset_ColorFragmentOp2ATI 728
-#define _gloffset_ColorFragmentOp3ATI 729
-#define _gloffset_DeleteFragmentShaderATI 730
-#define _gloffset_EndFragmentShaderATI 731
-#define _gloffset_GenFragmentShadersATI 732
-#define _gloffset_PassTexCoordATI 733
-#define _gloffset_SampleMapATI 734
-#define _gloffset_SetFragmentShaderConstantATI 735
-#define _gloffset_PointParameteriNV 736
-#define _gloffset_PointParameterivNV 737
-#define _gloffset_ActiveStencilFaceEXT 738
-#define _gloffset_BindVertexArrayAPPLE 739
-#define _gloffset_DeleteVertexArraysAPPLE 740
-#define _gloffset_GenVertexArraysAPPLE 741
-#define _gloffset_IsVertexArrayAPPLE 742
-#define _gloffset_GetProgramNamedParameterdvNV 743
-#define _gloffset_GetProgramNamedParameterfvNV 744
-#define _gloffset_ProgramNamedParameter4dNV 745
-#define _gloffset_ProgramNamedParameter4dvNV 746
-#define _gloffset_ProgramNamedParameter4fNV 747
-#define _gloffset_ProgramNamedParameter4fvNV 748
-#define _gloffset_DepthBoundsEXT 749
-#define _gloffset_BlendEquationSeparateEXT 750
-#define _gloffset_BindFramebufferEXT 751
-#define _gloffset_BindRenderbufferEXT 752
-#define _gloffset_CheckFramebufferStatusEXT 753
-#define _gloffset_DeleteFramebuffersEXT 754
-#define _gloffset_DeleteRenderbuffersEXT 755
-#define _gloffset_FramebufferRenderbufferEXT 756
-#define _gloffset_FramebufferTexture1DEXT 757
-#define _gloffset_FramebufferTexture2DEXT 758
-#define _gloffset_FramebufferTexture3DEXT 759
-#define _gloffset_GenFramebuffersEXT 760
-#define _gloffset_GenRenderbuffersEXT 761
-#define _gloffset_GenerateMipmapEXT 762
-#define _gloffset_GetFramebufferAttachmentParameterivEXT 763
-#define _gloffset_GetRenderbufferParameterivEXT 764
-#define _gloffset_IsFramebufferEXT 765
-#define _gloffset_IsRenderbufferEXT 766
-#define _gloffset_RenderbufferStorageEXT 767
-#define _gloffset_BlitFramebufferEXT 768
-#define _gloffset_FramebufferTextureLayerEXT 769
-#define _gloffset_StencilFuncSeparateATI 770
-#define _gloffset_ProgramEnvParameters4fvEXT 771
-#define _gloffset_ProgramLocalParameters4fvEXT 772
-#define _gloffset_GetQueryObjecti64vEXT 773
-#define _gloffset_GetQueryObjectui64vEXT 774
-#define _gloffset_FIRST_DYNAMIC 775
+#define _gloffset_FlushMappedBufferRange 562
+#define _gloffset_MapBufferRange 563
+#define _gloffset_CopyBufferSubData 564
+#define _gloffset_PolygonOffsetEXT 565
+#define _gloffset_GetPixelTexGenParameterfvSGIS 566
+#define _gloffset_GetPixelTexGenParameterivSGIS 567
+#define _gloffset_PixelTexGenParameterfSGIS 568
+#define _gloffset_PixelTexGenParameterfvSGIS 569
+#define _gloffset_PixelTexGenParameteriSGIS 570
+#define _gloffset_PixelTexGenParameterivSGIS 571
+#define _gloffset_SampleMaskSGIS 572
+#define _gloffset_SamplePatternSGIS 573
+#define _gloffset_ColorPointerEXT 574
+#define _gloffset_EdgeFlagPointerEXT 575
+#define _gloffset_IndexPointerEXT 576
+#define _gloffset_NormalPointerEXT 577
+#define _gloffset_TexCoordPointerEXT 578
+#define _gloffset_VertexPointerEXT 579
+#define _gloffset_PointParameterfEXT 580
+#define _gloffset_PointParameterfvEXT 581
+#define _gloffset_LockArraysEXT 582
+#define _gloffset_UnlockArraysEXT 583
+#define _gloffset_CullParameterdvEXT 584
+#define _gloffset_CullParameterfvEXT 585
+#define _gloffset_SecondaryColor3bEXT 586
+#define _gloffset_SecondaryColor3bvEXT 587
+#define _gloffset_SecondaryColor3dEXT 588
+#define _gloffset_SecondaryColor3dvEXT 589
+#define _gloffset_SecondaryColor3fEXT 590
+#define _gloffset_SecondaryColor3fvEXT 591
+#define _gloffset_SecondaryColor3iEXT 592
+#define _gloffset_SecondaryColor3ivEXT 593
+#define _gloffset_SecondaryColor3sEXT 594
+#define _gloffset_SecondaryColor3svEXT 595
+#define _gloffset_SecondaryColor3ubEXT 596
+#define _gloffset_SecondaryColor3ubvEXT 597
+#define _gloffset_SecondaryColor3uiEXT 598
+#define _gloffset_SecondaryColor3uivEXT 599
+#define _gloffset_SecondaryColor3usEXT 600
+#define _gloffset_SecondaryColor3usvEXT 601
+#define _gloffset_SecondaryColorPointerEXT 602
+#define _gloffset_MultiDrawArraysEXT 603
+#define _gloffset_MultiDrawElementsEXT 604
+#define _gloffset_FogCoordPointerEXT 605
+#define _gloffset_FogCoorddEXT 606
+#define _gloffset_FogCoorddvEXT 607
+#define _gloffset_FogCoordfEXT 608
+#define _gloffset_FogCoordfvEXT 609
+#define _gloffset_PixelTexGenSGIX 610
+#define _gloffset_BlendFuncSeparateEXT 611
+#define _gloffset_FlushVertexArrayRangeNV 612
+#define _gloffset_VertexArrayRangeNV 613
+#define _gloffset_CombinerInputNV 614
+#define _gloffset_CombinerOutputNV 615
+#define _gloffset_CombinerParameterfNV 616
+#define _gloffset_CombinerParameterfvNV 617
+#define _gloffset_CombinerParameteriNV 618
+#define _gloffset_CombinerParameterivNV 619
+#define _gloffset_FinalCombinerInputNV 620
+#define _gloffset_GetCombinerInputParameterfvNV 621
+#define _gloffset_GetCombinerInputParameterivNV 622
+#define _gloffset_GetCombinerOutputParameterfvNV 623
+#define _gloffset_GetCombinerOutputParameterivNV 624
+#define _gloffset_GetFinalCombinerInputParameterfvNV 625
+#define _gloffset_GetFinalCombinerInputParameterivNV 626
+#define _gloffset_ResizeBuffersMESA 627
+#define _gloffset_WindowPos2dMESA 628
+#define _gloffset_WindowPos2dvMESA 629
+#define _gloffset_WindowPos2fMESA 630
+#define _gloffset_WindowPos2fvMESA 631
+#define _gloffset_WindowPos2iMESA 632
+#define _gloffset_WindowPos2ivMESA 633
+#define _gloffset_WindowPos2sMESA 634
+#define _gloffset_WindowPos2svMESA 635
+#define _gloffset_WindowPos3dMESA 636
+#define _gloffset_WindowPos3dvMESA 637
+#define _gloffset_WindowPos3fMESA 638
+#define _gloffset_WindowPos3fvMESA 639
+#define _gloffset_WindowPos3iMESA 640
+#define _gloffset_WindowPos3ivMESA 641
+#define _gloffset_WindowPos3sMESA 642
+#define _gloffset_WindowPos3svMESA 643
+#define _gloffset_WindowPos4dMESA 644
+#define _gloffset_WindowPos4dvMESA 645
+#define _gloffset_WindowPos4fMESA 646
+#define _gloffset_WindowPos4fvMESA 647
+#define _gloffset_WindowPos4iMESA 648
+#define _gloffset_WindowPos4ivMESA 649
+#define _gloffset_WindowPos4sMESA 650
+#define _gloffset_WindowPos4svMESA 651
+#define _gloffset_MultiModeDrawArraysIBM 652
+#define _gloffset_MultiModeDrawElementsIBM 653
+#define _gloffset_DeleteFencesNV 654
+#define _gloffset_FinishFenceNV 655
+#define _gloffset_GenFencesNV 656
+#define _gloffset_GetFenceivNV 657
+#define _gloffset_IsFenceNV 658
+#define _gloffset_SetFenceNV 659
+#define _gloffset_TestFenceNV 660
+#define _gloffset_AreProgramsResidentNV 661
+#define _gloffset_BindProgramNV 662
+#define _gloffset_DeleteProgramsNV 663
+#define _gloffset_ExecuteProgramNV 664
+#define _gloffset_GenProgramsNV 665
+#define _gloffset_GetProgramParameterdvNV 666
+#define _gloffset_GetProgramParameterfvNV 667
+#define _gloffset_GetProgramStringNV 668
+#define _gloffset_GetProgramivNV 669
+#define _gloffset_GetTrackMatrixivNV 670
+#define _gloffset_GetVertexAttribPointervNV 671
+#define _gloffset_GetVertexAttribdvNV 672
+#define _gloffset_GetVertexAttribfvNV 673
+#define _gloffset_GetVertexAttribivNV 674
+#define _gloffset_IsProgramNV 675
+#define _gloffset_LoadProgramNV 676
+#define _gloffset_ProgramParameters4dvNV 677
+#define _gloffset_ProgramParameters4fvNV 678
+#define _gloffset_RequestResidentProgramsNV 679
+#define _gloffset_TrackMatrixNV 680
+#define _gloffset_VertexAttrib1dNV 681
+#define _gloffset_VertexAttrib1dvNV 682
+#define _gloffset_VertexAttrib1fNV 683
+#define _gloffset_VertexAttrib1fvNV 684
+#define _gloffset_VertexAttrib1sNV 685
+#define _gloffset_VertexAttrib1svNV 686
+#define _gloffset_VertexAttrib2dNV 687
+#define _gloffset_VertexAttrib2dvNV 688
+#define _gloffset_VertexAttrib2fNV 689
+#define _gloffset_VertexAttrib2fvNV 690
+#define _gloffset_VertexAttrib2sNV 691
+#define _gloffset_VertexAttrib2svNV 692
+#define _gloffset_VertexAttrib3dNV 693
+#define _gloffset_VertexAttrib3dvNV 694
+#define _gloffset_VertexAttrib3fNV 695
+#define _gloffset_VertexAttrib3fvNV 696
+#define _gloffset_VertexAttrib3sNV 697
+#define _gloffset_VertexAttrib3svNV 698
+#define _gloffset_VertexAttrib4dNV 699
+#define _gloffset_VertexAttrib4dvNV 700
+#define _gloffset_VertexAttrib4fNV 701
+#define _gloffset_VertexAttrib4fvNV 702
+#define _gloffset_VertexAttrib4sNV 703
+#define _gloffset_VertexAttrib4svNV 704
+#define _gloffset_VertexAttrib4ubNV 705
+#define _gloffset_VertexAttrib4ubvNV 706
+#define _gloffset_VertexAttribPointerNV 707
+#define _gloffset_VertexAttribs1dvNV 708
+#define _gloffset_VertexAttribs1fvNV 709
+#define _gloffset_VertexAttribs1svNV 710
+#define _gloffset_VertexAttribs2dvNV 711
+#define _gloffset_VertexAttribs2fvNV 712
+#define _gloffset_VertexAttribs2svNV 713
+#define _gloffset_VertexAttribs3dvNV 714
+#define _gloffset_VertexAttribs3fvNV 715
+#define _gloffset_VertexAttribs3svNV 716
+#define _gloffset_VertexAttribs4dvNV 717
+#define _gloffset_VertexAttribs4fvNV 718
+#define _gloffset_VertexAttribs4svNV 719
+#define _gloffset_VertexAttribs4ubvNV 720
+#define _gloffset_GetTexBumpParameterfvATI 721
+#define _gloffset_GetTexBumpParameterivATI 722
+#define _gloffset_TexBumpParameterfvATI 723
+#define _gloffset_TexBumpParameterivATI 724
+#define _gloffset_AlphaFragmentOp1ATI 725
+#define _gloffset_AlphaFragmentOp2ATI 726
+#define _gloffset_AlphaFragmentOp3ATI 727
+#define _gloffset_BeginFragmentShaderATI 728
+#define _gloffset_BindFragmentShaderATI 729
+#define _gloffset_ColorFragmentOp1ATI 730
+#define _gloffset_ColorFragmentOp2ATI 731
+#define _gloffset_ColorFragmentOp3ATI 732
+#define _gloffset_DeleteFragmentShaderATI 733
+#define _gloffset_EndFragmentShaderATI 734
+#define _gloffset_GenFragmentShadersATI 735
+#define _gloffset_PassTexCoordATI 736
+#define _gloffset_SampleMapATI 737
+#define _gloffset_SetFragmentShaderConstantATI 738
+#define _gloffset_PointParameteriNV 739
+#define _gloffset_PointParameterivNV 740
+#define _gloffset_ActiveStencilFaceEXT 741
+#define _gloffset_BindVertexArrayAPPLE 742
+#define _gloffset_DeleteVertexArraysAPPLE 743
+#define _gloffset_GenVertexArraysAPPLE 744
+#define _gloffset_IsVertexArrayAPPLE 745
+#define _gloffset_GetProgramNamedParameterdvNV 746
+#define _gloffset_GetProgramNamedParameterfvNV 747
+#define _gloffset_ProgramNamedParameter4dNV 748
+#define _gloffset_ProgramNamedParameter4dvNV 749
+#define _gloffset_ProgramNamedParameter4fNV 750
+#define _gloffset_ProgramNamedParameter4fvNV 751
+#define _gloffset_DepthBoundsEXT 752
+#define _gloffset_BlendEquationSeparateEXT 753
+#define _gloffset_BindFramebufferEXT 754
+#define _gloffset_BindRenderbufferEXT 755
+#define _gloffset_CheckFramebufferStatusEXT 756
+#define _gloffset_DeleteFramebuffersEXT 757
+#define _gloffset_DeleteRenderbuffersEXT 758
+#define _gloffset_FramebufferRenderbufferEXT 759
+#define _gloffset_FramebufferTexture1DEXT 760
+#define _gloffset_FramebufferTexture2DEXT 761
+#define _gloffset_FramebufferTexture3DEXT 762
+#define _gloffset_GenFramebuffersEXT 763
+#define _gloffset_GenRenderbuffersEXT 764
+#define _gloffset_GenerateMipmapEXT 765
+#define _gloffset_GetFramebufferAttachmentParameterivEXT 766
+#define _gloffset_GetRenderbufferParameterivEXT 767
+#define _gloffset_IsFramebufferEXT 768
+#define _gloffset_IsRenderbufferEXT 769
+#define _gloffset_RenderbufferStorageEXT 770
+#define _gloffset_BlitFramebufferEXT 771
+#define _gloffset_FramebufferTextureLayerEXT 772
+#define _gloffset_StencilFuncSeparateATI 773
+#define _gloffset_ProgramEnvParameters4fvEXT 774
+#define _gloffset_ProgramLocalParameters4fvEXT 775
+#define _gloffset_GetQueryObjecti64vEXT 776
+#define _gloffset_GetQueryObjectui64vEXT 777
+#define _gloffset_FIRST_DYNAMIC 778
 
 #else
 
 #define _gloffset_GetAttribLocationARB driDispatchRemapTable[GetAttribLocationARB_remap_index]
 #define _gloffset_DrawBuffersARB driDispatchRemapTable[DrawBuffersARB_remap_index]
 #define _gloffset_RenderbufferStorageMultisample driDispatchRemapTable[RenderbufferStorageMultisample_remap_index]
+#define _gloffset_FlushMappedBufferRange driDispatchRemapTable[FlushMappedBufferRange_remap_index]
+#define _gloffset_MapBufferRange driDispatchRemapTable[MapBufferRange_remap_index]
+#define _gloffset_CopyBufferSubData driDispatchRemapTable[CopyBufferSubData_remap_index]
 #define _gloffset_PolygonOffsetEXT driDispatchRemapTable[PolygonOffsetEXT_remap_index]
 #define _gloffset_GetPixelTexGenParameterfvSGIS driDispatchRemapTable[GetPixelTexGenParameterfvSGIS_remap_index]
 #define _gloffset_GetPixelTexGenParameterivSGIS driDispatchRemapTable[GetPixelTexGenParameterivSGIS_remap_index]
index 9ecb0364614a24ae2f5285b2595da560fe19e223..f4c36234cee8d052ea31e2f7f253d16417a54b29 100644 (file)
@@ -602,219 +602,222 @@ struct _glapi_table
    GLint (GLAPIENTRYP GetAttribLocationARB)(GLhandleARB program, const GLcharARB * name); /* 559 */
    void (GLAPIENTRYP DrawBuffersARB)(GLsizei n, const GLenum * bufs); /* 560 */
    void (GLAPIENTRYP RenderbufferStorageMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); /* 561 */
-   void (GLAPIENTRYP PolygonOffsetEXT)(GLfloat factor, GLfloat bias); /* 562 */
-   void (GLAPIENTRYP GetPixelTexGenParameterfvSGIS)(GLenum pname, GLfloat * params); /* 563 */
-   void (GLAPIENTRYP GetPixelTexGenParameterivSGIS)(GLenum pname, GLint * params); /* 564 */
-   void (GLAPIENTRYP PixelTexGenParameterfSGIS)(GLenum pname, GLfloat param); /* 565 */
-   void (GLAPIENTRYP PixelTexGenParameterfvSGIS)(GLenum pname, const GLfloat * params); /* 566 */
-   void (GLAPIENTRYP PixelTexGenParameteriSGIS)(GLenum pname, GLint param); /* 567 */
-   void (GLAPIENTRYP PixelTexGenParameterivSGIS)(GLenum pname, const GLint * params); /* 568 */
-   void (GLAPIENTRYP SampleMaskSGIS)(GLclampf value, GLboolean invert); /* 569 */
-   void (GLAPIENTRYP SamplePatternSGIS)(GLenum pattern); /* 570 */
-   void (GLAPIENTRYP ColorPointerEXT)(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); /* 571 */
-   void (GLAPIENTRYP EdgeFlagPointerEXT)(GLsizei stride, GLsizei count, const GLboolean * pointer); /* 572 */
-   void (GLAPIENTRYP IndexPointerEXT)(GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); /* 573 */
-   void (GLAPIENTRYP NormalPointerEXT)(GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); /* 574 */
-   void (GLAPIENTRYP TexCoordPointerEXT)(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); /* 575 */
-   void (GLAPIENTRYP VertexPointerEXT)(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); /* 576 */
-   void (GLAPIENTRYP PointParameterfEXT)(GLenum pname, GLfloat param); /* 577 */
-   void (GLAPIENTRYP PointParameterfvEXT)(GLenum pname, const GLfloat * params); /* 578 */
-   void (GLAPIENTRYP LockArraysEXT)(GLint first, GLsizei count); /* 579 */
-   void (GLAPIENTRYP UnlockArraysEXT)(void); /* 580 */
-   void (GLAPIENTRYP CullParameterdvEXT)(GLenum pname, GLdouble * params); /* 581 */
-   void (GLAPIENTRYP CullParameterfvEXT)(GLenum pname, GLfloat * params); /* 582 */
-   void (GLAPIENTRYP SecondaryColor3bEXT)(GLbyte red, GLbyte green, GLbyte blue); /* 583 */
-   void (GLAPIENTRYP SecondaryColor3bvEXT)(const GLbyte * v); /* 584 */
-   void (GLAPIENTRYP SecondaryColor3dEXT)(GLdouble red, GLdouble green, GLdouble blue); /* 585 */
-   void (GLAPIENTRYP SecondaryColor3dvEXT)(const GLdouble * v); /* 586 */
-   void (GLAPIENTRYP SecondaryColor3fEXT)(GLfloat red, GLfloat green, GLfloat blue); /* 587 */
-   void (GLAPIENTRYP SecondaryColor3fvEXT)(const GLfloat * v); /* 588 */
-   void (GLAPIENTRYP SecondaryColor3iEXT)(GLint red, GLint green, GLint blue); /* 589 */
-   void (GLAPIENTRYP SecondaryColor3ivEXT)(const GLint * v); /* 590 */
-   void (GLAPIENTRYP SecondaryColor3sEXT)(GLshort red, GLshort green, GLshort blue); /* 591 */
-   void (GLAPIENTRYP SecondaryColor3svEXT)(const GLshort * v); /* 592 */
-   void (GLAPIENTRYP SecondaryColor3ubEXT)(GLubyte red, GLubyte green, GLubyte blue); /* 593 */
-   void (GLAPIENTRYP SecondaryColor3ubvEXT)(const GLubyte * v); /* 594 */
-   void (GLAPIENTRYP SecondaryColor3uiEXT)(GLuint red, GLuint green, GLuint blue); /* 595 */
-   void (GLAPIENTRYP SecondaryColor3uivEXT)(const GLuint * v); /* 596 */
-   void (GLAPIENTRYP SecondaryColor3usEXT)(GLushort red, GLushort green, GLushort blue); /* 597 */
-   void (GLAPIENTRYP SecondaryColor3usvEXT)(const GLushort * v); /* 598 */
-   void (GLAPIENTRYP SecondaryColorPointerEXT)(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); /* 599 */
-   void (GLAPIENTRYP MultiDrawArraysEXT)(GLenum mode, GLint * first, GLsizei * count, GLsizei primcount); /* 600 */
-   void (GLAPIENTRYP MultiDrawElementsEXT)(GLenum mode, const GLsizei * count, GLenum type, const GLvoid ** indices, GLsizei primcount); /* 601 */
-   void (GLAPIENTRYP FogCoordPointerEXT)(GLenum type, GLsizei stride, const GLvoid * pointer); /* 602 */
-   void (GLAPIENTRYP FogCoorddEXT)(GLdouble coord); /* 603 */
-   void (GLAPIENTRYP FogCoorddvEXT)(const GLdouble * coord); /* 604 */
-   void (GLAPIENTRYP FogCoordfEXT)(GLfloat coord); /* 605 */
-   void (GLAPIENTRYP FogCoordfvEXT)(const GLfloat * coord); /* 606 */
-   void (GLAPIENTRYP PixelTexGenSGIX)(GLenum mode); /* 607 */
-   void (GLAPIENTRYP BlendFuncSeparateEXT)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); /* 608 */
-   void (GLAPIENTRYP FlushVertexArrayRangeNV)(void); /* 609 */
-   void (GLAPIENTRYP VertexArrayRangeNV)(GLsizei length, const GLvoid * pointer); /* 610 */
-   void (GLAPIENTRYP CombinerInputNV)(GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); /* 611 */
-   void (GLAPIENTRYP CombinerOutputNV)(GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); /* 612 */
-   void (GLAPIENTRYP CombinerParameterfNV)(GLenum pname, GLfloat param); /* 613 */
-   void (GLAPIENTRYP CombinerParameterfvNV)(GLenum pname, const GLfloat * params); /* 614 */
-   void (GLAPIENTRYP CombinerParameteriNV)(GLenum pname, GLint param); /* 615 */
-   void (GLAPIENTRYP CombinerParameterivNV)(GLenum pname, const GLint * params); /* 616 */
-   void (GLAPIENTRYP FinalCombinerInputNV)(GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); /* 617 */
-   void (GLAPIENTRYP GetCombinerInputParameterfvNV)(GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat * params); /* 618 */
-   void (GLAPIENTRYP GetCombinerInputParameterivNV)(GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint * params); /* 619 */
-   void (GLAPIENTRYP GetCombinerOutputParameterfvNV)(GLenum stage, GLenum portion, GLenum pname, GLfloat * params); /* 620 */
-   void (GLAPIENTRYP GetCombinerOutputParameterivNV)(GLenum stage, GLenum portion, GLenum pname, GLint * params); /* 621 */
-   void (GLAPIENTRYP GetFinalCombinerInputParameterfvNV)(GLenum variable, GLenum pname, GLfloat * params); /* 622 */
-   void (GLAPIENTRYP GetFinalCombinerInputParameterivNV)(GLenum variable, GLenum pname, GLint * params); /* 623 */
-   void (GLAPIENTRYP ResizeBuffersMESA)(void); /* 624 */
-   void (GLAPIENTRYP WindowPos2dMESA)(GLdouble x, GLdouble y); /* 625 */
-   void (GLAPIENTRYP WindowPos2dvMESA)(const GLdouble * v); /* 626 */
-   void (GLAPIENTRYP WindowPos2fMESA)(GLfloat x, GLfloat y); /* 627 */
-   void (GLAPIENTRYP WindowPos2fvMESA)(const GLfloat * v); /* 628 */
-   void (GLAPIENTRYP WindowPos2iMESA)(GLint x, GLint y); /* 629 */
-   void (GLAPIENTRYP WindowPos2ivMESA)(const GLint * v); /* 630 */
-   void (GLAPIENTRYP WindowPos2sMESA)(GLshort x, GLshort y); /* 631 */
-   void (GLAPIENTRYP WindowPos2svMESA)(const GLshort * v); /* 632 */
-   void (GLAPIENTRYP WindowPos3dMESA)(GLdouble x, GLdouble y, GLdouble z); /* 633 */
-   void (GLAPIENTRYP WindowPos3dvMESA)(const GLdouble * v); /* 634 */
-   void (GLAPIENTRYP WindowPos3fMESA)(GLfloat x, GLfloat y, GLfloat z); /* 635 */
-   void (GLAPIENTRYP WindowPos3fvMESA)(const GLfloat * v); /* 636 */
-   void (GLAPIENTRYP WindowPos3iMESA)(GLint x, GLint y, GLint z); /* 637 */
-   void (GLAPIENTRYP WindowPos3ivMESA)(const GLint * v); /* 638 */
-   void (GLAPIENTRYP WindowPos3sMESA)(GLshort x, GLshort y, GLshort z); /* 639 */
-   void (GLAPIENTRYP WindowPos3svMESA)(const GLshort * v); /* 640 */
-   void (GLAPIENTRYP WindowPos4dMESA)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); /* 641 */
-   void (GLAPIENTRYP WindowPos4dvMESA)(const GLdouble * v); /* 642 */
-   void (GLAPIENTRYP WindowPos4fMESA)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); /* 643 */
-   void (GLAPIENTRYP WindowPos4fvMESA)(const GLfloat * v); /* 644 */
-   void (GLAPIENTRYP WindowPos4iMESA)(GLint x, GLint y, GLint z, GLint w); /* 645 */
-   void (GLAPIENTRYP WindowPos4ivMESA)(const GLint * v); /* 646 */
-   void (GLAPIENTRYP WindowPos4sMESA)(GLshort x, GLshort y, GLshort z, GLshort w); /* 647 */
-   void (GLAPIENTRYP WindowPos4svMESA)(const GLshort * v); /* 648 */
-   void (GLAPIENTRYP MultiModeDrawArraysIBM)(const GLenum * mode, const GLint * first, const GLsizei * count, GLsizei primcount, GLint modestride); /* 649 */
-   void (GLAPIENTRYP MultiModeDrawElementsIBM)(const GLenum * mode, const GLsizei * count, GLenum type, const GLvoid * const * indices, GLsizei primcount, GLint modestride); /* 650 */
-   void (GLAPIENTRYP DeleteFencesNV)(GLsizei n, const GLuint * fences); /* 651 */
-   void (GLAPIENTRYP FinishFenceNV)(GLuint fence); /* 652 */
-   void (GLAPIENTRYP GenFencesNV)(GLsizei n, GLuint * fences); /* 653 */
-   void (GLAPIENTRYP GetFenceivNV)(GLuint fence, GLenum pname, GLint * params); /* 654 */
-   GLboolean (GLAPIENTRYP IsFenceNV)(GLuint fence); /* 655 */
-   void (GLAPIENTRYP SetFenceNV)(GLuint fence, GLenum condition); /* 656 */
-   GLboolean (GLAPIENTRYP TestFenceNV)(GLuint fence); /* 657 */
-   GLboolean (GLAPIENTRYP AreProgramsResidentNV)(GLsizei n, const GLuint * ids, GLboolean * residences); /* 658 */
-   void (GLAPIENTRYP BindProgramNV)(GLenum target, GLuint program); /* 659 */
-   void (GLAPIENTRYP DeleteProgramsNV)(GLsizei n, const GLuint * programs); /* 660 */
-   void (GLAPIENTRYP ExecuteProgramNV)(GLenum target, GLuint id, const GLfloat * params); /* 661 */
-   void (GLAPIENTRYP GenProgramsNV)(GLsizei n, GLuint * programs); /* 662 */
-   void (GLAPIENTRYP GetProgramParameterdvNV)(GLenum target, GLuint index, GLenum pname, GLdouble * params); /* 663 */
-   void (GLAPIENTRYP GetProgramParameterfvNV)(GLenum target, GLuint index, GLenum pname, GLfloat * params); /* 664 */
-   void (GLAPIENTRYP GetProgramStringNV)(GLuint id, GLenum pname, GLubyte * program); /* 665 */
-   void (GLAPIENTRYP GetProgramivNV)(GLuint id, GLenum pname, GLint * params); /* 666 */
-   void (GLAPIENTRYP GetTrackMatrixivNV)(GLenum target, GLuint address, GLenum pname, GLint * params); /* 667 */
-   void (GLAPIENTRYP GetVertexAttribPointervNV)(GLuint index, GLenum pname, GLvoid ** pointer); /* 668 */
-   void (GLAPIENTRYP GetVertexAttribdvNV)(GLuint index, GLenum pname, GLdouble * params); /* 669 */
-   void (GLAPIENTRYP GetVertexAttribfvNV)(GLuint index, GLenum pname, GLfloat * params); /* 670 */
-   void (GLAPIENTRYP GetVertexAttribivNV)(GLuint index, GLenum pname, GLint * params); /* 671 */
-   GLboolean (GLAPIENTRYP IsProgramNV)(GLuint program); /* 672 */
-   void (GLAPIENTRYP LoadProgramNV)(GLenum target, GLuint id, GLsizei len, const GLubyte * program); /* 673 */
-   void (GLAPIENTRYP ProgramParameters4dvNV)(GLenum target, GLuint index, GLuint num, const GLdouble * params); /* 674 */
-   void (GLAPIENTRYP ProgramParameters4fvNV)(GLenum target, GLuint index, GLuint num, const GLfloat * params); /* 675 */
-   void (GLAPIENTRYP RequestResidentProgramsNV)(GLsizei n, const GLuint * ids); /* 676 */
-   void (GLAPIENTRYP TrackMatrixNV)(GLenum target, GLuint address, GLenum matrix, GLenum transform); /* 677 */
-   void (GLAPIENTRYP VertexAttrib1dNV)(GLuint index, GLdouble x); /* 678 */
-   void (GLAPIENTRYP VertexAttrib1dvNV)(GLuint index, const GLdouble * v); /* 679 */
-   void (GLAPIENTRYP VertexAttrib1fNV)(GLuint index, GLfloat x); /* 680 */
-   void (GLAPIENTRYP VertexAttrib1fvNV)(GLuint index, const GLfloat * v); /* 681 */
-   void (GLAPIENTRYP VertexAttrib1sNV)(GLuint index, GLshort x); /* 682 */
-   void (GLAPIENTRYP VertexAttrib1svNV)(GLuint index, const GLshort * v); /* 683 */
-   void (GLAPIENTRYP VertexAttrib2dNV)(GLuint index, GLdouble x, GLdouble y); /* 684 */
-   void (GLAPIENTRYP VertexAttrib2dvNV)(GLuint index, const GLdouble * v); /* 685 */
-   void (GLAPIENTRYP VertexAttrib2fNV)(GLuint index, GLfloat x, GLfloat y); /* 686 */
-   void (GLAPIENTRYP VertexAttrib2fvNV)(GLuint index, const GLfloat * v); /* 687 */
-   void (GLAPIENTRYP VertexAttrib2sNV)(GLuint index, GLshort x, GLshort y); /* 688 */
-   void (GLAPIENTRYP VertexAttrib2svNV)(GLuint index, const GLshort * v); /* 689 */
-   void (GLAPIENTRYP VertexAttrib3dNV)(GLuint index, GLdouble x, GLdouble y, GLdouble z); /* 690 */
-   void (GLAPIENTRYP VertexAttrib3dvNV)(GLuint index, const GLdouble * v); /* 691 */
-   void (GLAPIENTRYP VertexAttrib3fNV)(GLuint index, GLfloat x, GLfloat y, GLfloat z); /* 692 */
-   void (GLAPIENTRYP VertexAttrib3fvNV)(GLuint index, const GLfloat * v); /* 693 */
-   void (GLAPIENTRYP VertexAttrib3sNV)(GLuint index, GLshort x, GLshort y, GLshort z); /* 694 */
-   void (GLAPIENTRYP VertexAttrib3svNV)(GLuint index, const GLshort * v); /* 695 */
-   void (GLAPIENTRYP VertexAttrib4dNV)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); /* 696 */
-   void (GLAPIENTRYP VertexAttrib4dvNV)(GLuint index, const GLdouble * v); /* 697 */
-   void (GLAPIENTRYP VertexAttrib4fNV)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); /* 698 */
-   void (GLAPIENTRYP VertexAttrib4fvNV)(GLuint index, const GLfloat * v); /* 699 */
-   void (GLAPIENTRYP VertexAttrib4sNV)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); /* 700 */
-   void (GLAPIENTRYP VertexAttrib4svNV)(GLuint index, const GLshort * v); /* 701 */
-   void (GLAPIENTRYP VertexAttrib4ubNV)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); /* 702 */
-   void (GLAPIENTRYP VertexAttrib4ubvNV)(GLuint index, const GLubyte * v); /* 703 */
-   void (GLAPIENTRYP VertexAttribPointerNV)(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); /* 704 */
-   void (GLAPIENTRYP VertexAttribs1dvNV)(GLuint index, GLsizei n, const GLdouble * v); /* 705 */
-   void (GLAPIENTRYP VertexAttribs1fvNV)(GLuint index, GLsizei n, const GLfloat * v); /* 706 */
-   void (GLAPIENTRYP VertexAttribs1svNV)(GLuint index, GLsizei n, const GLshort * v); /* 707 */
-   void (GLAPIENTRYP VertexAttribs2dvNV)(GLuint index, GLsizei n, const GLdouble * v); /* 708 */
-   void (GLAPIENTRYP VertexAttribs2fvNV)(GLuint index, GLsizei n, const GLfloat * v); /* 709 */
-   void (GLAPIENTRYP VertexAttribs2svNV)(GLuint index, GLsizei n, const GLshort * v); /* 710 */
-   void (GLAPIENTRYP VertexAttribs3dvNV)(GLuint index, GLsizei n, const GLdouble * v); /* 711 */
-   void (GLAPIENTRYP VertexAttribs3fvNV)(GLuint index, GLsizei n, const GLfloat * v); /* 712 */
-   void (GLAPIENTRYP VertexAttribs3svNV)(GLuint index, GLsizei n, const GLshort * v); /* 713 */
-   void (GLAPIENTRYP VertexAttribs4dvNV)(GLuint index, GLsizei n, const GLdouble * v); /* 714 */
-   void (GLAPIENTRYP VertexAttribs4fvNV)(GLuint index, GLsizei n, const GLfloat * v); /* 715 */
-   void (GLAPIENTRYP VertexAttribs4svNV)(GLuint index, GLsizei n, const GLshort * v); /* 716 */
-   void (GLAPIENTRYP VertexAttribs4ubvNV)(GLuint index, GLsizei n, const GLubyte * v); /* 717 */
-   void (GLAPIENTRYP GetTexBumpParameterfvATI)(GLenum pname, GLfloat * param); /* 718 */
-   void (GLAPIENTRYP GetTexBumpParameterivATI)(GLenum pname, GLint * param); /* 719 */
-   void (GLAPIENTRYP TexBumpParameterfvATI)(GLenum pname, const GLfloat * param); /* 720 */
-   void (GLAPIENTRYP TexBumpParameterivATI)(GLenum pname, const GLint * param); /* 721 */
-   void (GLAPIENTRYP AlphaFragmentOp1ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); /* 722 */
-   void (GLAPIENTRYP AlphaFragmentOp2ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); /* 723 */
-   void (GLAPIENTRYP AlphaFragmentOp3ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); /* 724 */
-   void (GLAPIENTRYP BeginFragmentShaderATI)(void); /* 725 */
-   void (GLAPIENTRYP BindFragmentShaderATI)(GLuint id); /* 726 */
-   void (GLAPIENTRYP ColorFragmentOp1ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); /* 727 */
-   void (GLAPIENTRYP ColorFragmentOp2ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); /* 728 */
-   void (GLAPIENTRYP ColorFragmentOp3ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); /* 729 */
-   void (GLAPIENTRYP DeleteFragmentShaderATI)(GLuint id); /* 730 */
-   void (GLAPIENTRYP EndFragmentShaderATI)(void); /* 731 */
-   GLuint (GLAPIENTRYP GenFragmentShadersATI)(GLuint range); /* 732 */
-   void (GLAPIENTRYP PassTexCoordATI)(GLuint dst, GLuint coord, GLenum swizzle); /* 733 */
-   void (GLAPIENTRYP SampleMapATI)(GLuint dst, GLuint interp, GLenum swizzle); /* 734 */
-   void (GLAPIENTRYP SetFragmentShaderConstantATI)(GLuint dst, const GLfloat * value); /* 735 */
-   void (GLAPIENTRYP PointParameteriNV)(GLenum pname, GLint param); /* 736 */
-   void (GLAPIENTRYP PointParameterivNV)(GLenum pname, const GLint * params); /* 737 */
-   void (GLAPIENTRYP ActiveStencilFaceEXT)(GLenum face); /* 738 */
-   void (GLAPIENTRYP BindVertexArrayAPPLE)(GLuint array); /* 739 */
-   void (GLAPIENTRYP DeleteVertexArraysAPPLE)(GLsizei n, const GLuint * arrays); /* 740 */
-   void (GLAPIENTRYP GenVertexArraysAPPLE)(GLsizei n, GLuint * arrays); /* 741 */
-   GLboolean (GLAPIENTRYP IsVertexArrayAPPLE)(GLuint array); /* 742 */
-   void (GLAPIENTRYP GetProgramNamedParameterdvNV)(GLuint id, GLsizei len, const GLubyte * name, GLdouble * params); /* 743 */
-   void (GLAPIENTRYP GetProgramNamedParameterfvNV)(GLuint id, GLsizei len, const GLubyte * name, GLfloat * params); /* 744 */
-   void (GLAPIENTRYP ProgramNamedParameter4dNV)(GLuint id, GLsizei len, const GLubyte * name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); /* 745 */
-   void (GLAPIENTRYP ProgramNamedParameter4dvNV)(GLuint id, GLsizei len, const GLubyte * name, const GLdouble * v); /* 746 */
-   void (GLAPIENTRYP ProgramNamedParameter4fNV)(GLuint id, GLsizei len, const GLubyte * name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); /* 747 */
-   void (GLAPIENTRYP ProgramNamedParameter4fvNV)(GLuint id, GLsizei len, const GLubyte * name, const GLfloat * v); /* 748 */
-   void (GLAPIENTRYP DepthBoundsEXT)(GLclampd zmin, GLclampd zmax); /* 749 */
-   void (GLAPIENTRYP BlendEquationSeparateEXT)(GLenum modeRGB, GLenum modeA); /* 750 */
-   void (GLAPIENTRYP BindFramebufferEXT)(GLenum target, GLuint framebuffer); /* 751 */
-   void (GLAPIENTRYP BindRenderbufferEXT)(GLenum target, GLuint renderbuffer); /* 752 */
-   GLenum (GLAPIENTRYP CheckFramebufferStatusEXT)(GLenum target); /* 753 */
-   void (GLAPIENTRYP DeleteFramebuffersEXT)(GLsizei n, const GLuint * framebuffers); /* 754 */
-   void (GLAPIENTRYP DeleteRenderbuffersEXT)(GLsizei n, const GLuint * renderbuffers); /* 755 */
-   void (GLAPIENTRYP FramebufferRenderbufferEXT)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); /* 756 */
-   void (GLAPIENTRYP FramebufferTexture1DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); /* 757 */
-   void (GLAPIENTRYP FramebufferTexture2DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); /* 758 */
-   void (GLAPIENTRYP FramebufferTexture3DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); /* 759 */
-   void (GLAPIENTRYP GenFramebuffersEXT)(GLsizei n, GLuint * framebuffers); /* 760 */
-   void (GLAPIENTRYP GenRenderbuffersEXT)(GLsizei n, GLuint * renderbuffers); /* 761 */
-   void (GLAPIENTRYP GenerateMipmapEXT)(GLenum target); /* 762 */
-   void (GLAPIENTRYP GetFramebufferAttachmentParameterivEXT)(GLenum target, GLenum attachment, GLenum pname, GLint * params); /* 763 */
-   void (GLAPIENTRYP GetRenderbufferParameterivEXT)(GLenum target, GLenum pname, GLint * params); /* 764 */
-   GLboolean (GLAPIENTRYP IsFramebufferEXT)(GLuint framebuffer); /* 765 */
-   GLboolean (GLAPIENTRYP IsRenderbufferEXT)(GLuint renderbuffer); /* 766 */
-   void (GLAPIENTRYP RenderbufferStorageEXT)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); /* 767 */
-   void (GLAPIENTRYP BlitFramebufferEXT)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); /* 768 */
-   void (GLAPIENTRYP FramebufferTextureLayerEXT)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); /* 769 */
-   void (GLAPIENTRYP StencilFuncSeparateATI)(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); /* 770 */
-   void (GLAPIENTRYP ProgramEnvParameters4fvEXT)(GLenum target, GLuint index, GLsizei count, const GLfloat * params); /* 771 */
-   void (GLAPIENTRYP ProgramLocalParameters4fvEXT)(GLenum target, GLuint index, GLsizei count, const GLfloat * params); /* 772 */
-   void (GLAPIENTRYP GetQueryObjecti64vEXT)(GLuint id, GLenum pname, GLint64EXT * params); /* 773 */
-   void (GLAPIENTRYP GetQueryObjectui64vEXT)(GLuint id, GLenum pname, GLuint64EXT * params); /* 774 */
+   void (GLAPIENTRYP FlushMappedBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length); /* 562 */
+   GLvoid * (GLAPIENTRYP MapBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); /* 563 */
+   void (GLAPIENTRYP CopyBufferSubData)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); /* 564 */
+   void (GLAPIENTRYP PolygonOffsetEXT)(GLfloat factor, GLfloat bias); /* 565 */
+   void (GLAPIENTRYP GetPixelTexGenParameterfvSGIS)(GLenum pname, GLfloat * params); /* 566 */
+   void (GLAPIENTRYP GetPixelTexGenParameterivSGIS)(GLenum pname, GLint * params); /* 567 */
+   void (GLAPIENTRYP PixelTexGenParameterfSGIS)(GLenum pname, GLfloat param); /* 568 */
+   void (GLAPIENTRYP PixelTexGenParameterfvSGIS)(GLenum pname, const GLfloat * params); /* 569 */
+   void (GLAPIENTRYP PixelTexGenParameteriSGIS)(GLenum pname, GLint param); /* 570 */
+   void (GLAPIENTRYP PixelTexGenParameterivSGIS)(GLenum pname, const GLint * params); /* 571 */
+   void (GLAPIENTRYP SampleMaskSGIS)(GLclampf value, GLboolean invert); /* 572 */
+   void (GLAPIENTRYP SamplePatternSGIS)(GLenum pattern); /* 573 */
+   void (GLAPIENTRYP ColorPointerEXT)(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); /* 574 */
+   void (GLAPIENTRYP EdgeFlagPointerEXT)(GLsizei stride, GLsizei count, const GLboolean * pointer); /* 575 */
+   void (GLAPIENTRYP IndexPointerEXT)(GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); /* 576 */
+   void (GLAPIENTRYP NormalPointerEXT)(GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); /* 577 */
+   void (GLAPIENTRYP TexCoordPointerEXT)(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); /* 578 */
+   void (GLAPIENTRYP VertexPointerEXT)(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); /* 579 */
+   void (GLAPIENTRYP PointParameterfEXT)(GLenum pname, GLfloat param); /* 580 */
+   void (GLAPIENTRYP PointParameterfvEXT)(GLenum pname, const GLfloat * params); /* 581 */
+   void (GLAPIENTRYP LockArraysEXT)(GLint first, GLsizei count); /* 582 */
+   void (GLAPIENTRYP UnlockArraysEXT)(void); /* 583 */
+   void (GLAPIENTRYP CullParameterdvEXT)(GLenum pname, GLdouble * params); /* 584 */
+   void (GLAPIENTRYP CullParameterfvEXT)(GLenum pname, GLfloat * params); /* 585 */
+   void (GLAPIENTRYP SecondaryColor3bEXT)(GLbyte red, GLbyte green, GLbyte blue); /* 586 */
+   void (GLAPIENTRYP SecondaryColor3bvEXT)(const GLbyte * v); /* 587 */
+   void (GLAPIENTRYP SecondaryColor3dEXT)(GLdouble red, GLdouble green, GLdouble blue); /* 588 */
+   void (GLAPIENTRYP SecondaryColor3dvEXT)(const GLdouble * v); /* 589 */
+   void (GLAPIENTRYP SecondaryColor3fEXT)(GLfloat red, GLfloat green, GLfloat blue); /* 590 */
+   void (GLAPIENTRYP SecondaryColor3fvEXT)(const GLfloat * v); /* 591 */
+   void (GLAPIENTRYP SecondaryColor3iEXT)(GLint red, GLint green, GLint blue); /* 592 */
+   void (GLAPIENTRYP SecondaryColor3ivEXT)(const GLint * v); /* 593 */
+   void (GLAPIENTRYP SecondaryColor3sEXT)(GLshort red, GLshort green, GLshort blue); /* 594 */
+   void (GLAPIENTRYP SecondaryColor3svEXT)(const GLshort * v); /* 595 */
+   void (GLAPIENTRYP SecondaryColor3ubEXT)(GLubyte red, GLubyte green, GLubyte blue); /* 596 */
+   void (GLAPIENTRYP SecondaryColor3ubvEXT)(const GLubyte * v); /* 597 */
+   void (GLAPIENTRYP SecondaryColor3uiEXT)(GLuint red, GLuint green, GLuint blue); /* 598 */
+   void (GLAPIENTRYP SecondaryColor3uivEXT)(const GLuint * v); /* 599 */
+   void (GLAPIENTRYP SecondaryColor3usEXT)(GLushort red, GLushort green, GLushort blue); /* 600 */
+   void (GLAPIENTRYP SecondaryColor3usvEXT)(const GLushort * v); /* 601 */
+   void (GLAPIENTRYP SecondaryColorPointerEXT)(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); /* 602 */
+   void (GLAPIENTRYP MultiDrawArraysEXT)(GLenum mode, GLint * first, GLsizei * count, GLsizei primcount); /* 603 */
+   void (GLAPIENTRYP MultiDrawElementsEXT)(GLenum mode, const GLsizei * count, GLenum type, const GLvoid ** indices, GLsizei primcount); /* 604 */
+   void (GLAPIENTRYP FogCoordPointerEXT)(GLenum type, GLsizei stride, const GLvoid * pointer); /* 605 */
+   void (GLAPIENTRYP FogCoorddEXT)(GLdouble coord); /* 606 */
+   void (GLAPIENTRYP FogCoorddvEXT)(const GLdouble * coord); /* 607 */
+   void (GLAPIENTRYP FogCoordfEXT)(GLfloat coord); /* 608 */
+   void (GLAPIENTRYP FogCoordfvEXT)(const GLfloat * coord); /* 609 */
+   void (GLAPIENTRYP PixelTexGenSGIX)(GLenum mode); /* 610 */
+   void (GLAPIENTRYP BlendFuncSeparateEXT)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); /* 611 */
+   void (GLAPIENTRYP FlushVertexArrayRangeNV)(void); /* 612 */
+   void (GLAPIENTRYP VertexArrayRangeNV)(GLsizei length, const GLvoid * pointer); /* 613 */
+   void (GLAPIENTRYP CombinerInputNV)(GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); /* 614 */
+   void (GLAPIENTRYP CombinerOutputNV)(GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); /* 615 */
+   void (GLAPIENTRYP CombinerParameterfNV)(GLenum pname, GLfloat param); /* 616 */
+   void (GLAPIENTRYP CombinerParameterfvNV)(GLenum pname, const GLfloat * params); /* 617 */
+   void (GLAPIENTRYP CombinerParameteriNV)(GLenum pname, GLint param); /* 618 */
+   void (GLAPIENTRYP CombinerParameterivNV)(GLenum pname, const GLint * params); /* 619 */
+   void (GLAPIENTRYP FinalCombinerInputNV)(GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); /* 620 */
+   void (GLAPIENTRYP GetCombinerInputParameterfvNV)(GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat * params); /* 621 */
+   void (GLAPIENTRYP GetCombinerInputParameterivNV)(GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint * params); /* 622 */
+   void (GLAPIENTRYP GetCombinerOutputParameterfvNV)(GLenum stage, GLenum portion, GLenum pname, GLfloat * params); /* 623 */
+   void (GLAPIENTRYP GetCombinerOutputParameterivNV)(GLenum stage, GLenum portion, GLenum pname, GLint * params); /* 624 */
+   void (GLAPIENTRYP GetFinalCombinerInputParameterfvNV)(GLenum variable, GLenum pname, GLfloat * params); /* 625 */
+   void (GLAPIENTRYP GetFinalCombinerInputParameterivNV)(GLenum variable, GLenum pname, GLint * params); /* 626 */
+   void (GLAPIENTRYP ResizeBuffersMESA)(void); /* 627 */
+   void (GLAPIENTRYP WindowPos2dMESA)(GLdouble x, GLdouble y); /* 628 */
+   void (GLAPIENTRYP WindowPos2dvMESA)(const GLdouble * v); /* 629 */
+   void (GLAPIENTRYP WindowPos2fMESA)(GLfloat x, GLfloat y); /* 630 */
+   void (GLAPIENTRYP WindowPos2fvMESA)(const GLfloat * v); /* 631 */
+   void (GLAPIENTRYP WindowPos2iMESA)(GLint x, GLint y); /* 632 */
+   void (GLAPIENTRYP WindowPos2ivMESA)(const GLint * v); /* 633 */
+   void (GLAPIENTRYP WindowPos2sMESA)(GLshort x, GLshort y); /* 634 */
+   void (GLAPIENTRYP WindowPos2svMESA)(const GLshort * v); /* 635 */
+   void (GLAPIENTRYP WindowPos3dMESA)(GLdouble x, GLdouble y, GLdouble z); /* 636 */
+   void (GLAPIENTRYP WindowPos3dvMESA)(const GLdouble * v); /* 637 */
+   void (GLAPIENTRYP WindowPos3fMESA)(GLfloat x, GLfloat y, GLfloat z); /* 638 */
+   void (GLAPIENTRYP WindowPos3fvMESA)(const GLfloat * v); /* 639 */
+   void (GLAPIENTRYP WindowPos3iMESA)(GLint x, GLint y, GLint z); /* 640 */
+   void (GLAPIENTRYP WindowPos3ivMESA)(const GLint * v); /* 641 */
+   void (GLAPIENTRYP WindowPos3sMESA)(GLshort x, GLshort y, GLshort z); /* 642 */
+   void (GLAPIENTRYP WindowPos3svMESA)(const GLshort * v); /* 643 */
+   void (GLAPIENTRYP WindowPos4dMESA)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); /* 644 */
+   void (GLAPIENTRYP WindowPos4dvMESA)(const GLdouble * v); /* 645 */
+   void (GLAPIENTRYP WindowPos4fMESA)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); /* 646 */
+   void (GLAPIENTRYP WindowPos4fvMESA)(const GLfloat * v); /* 647 */
+   void (GLAPIENTRYP WindowPos4iMESA)(GLint x, GLint y, GLint z, GLint w); /* 648 */
+   void (GLAPIENTRYP WindowPos4ivMESA)(const GLint * v); /* 649 */
+   void (GLAPIENTRYP WindowPos4sMESA)(GLshort x, GLshort y, GLshort z, GLshort w); /* 650 */
+   void (GLAPIENTRYP WindowPos4svMESA)(const GLshort * v); /* 651 */
+   void (GLAPIENTRYP MultiModeDrawArraysIBM)(const GLenum * mode, const GLint * first, const GLsizei * count, GLsizei primcount, GLint modestride); /* 652 */
+   void (GLAPIENTRYP MultiModeDrawElementsIBM)(const GLenum * mode, const GLsizei * count, GLenum type, const GLvoid * const * indices, GLsizei primcount, GLint modestride); /* 653 */
+   void (GLAPIENTRYP DeleteFencesNV)(GLsizei n, const GLuint * fences); /* 654 */
+   void (GLAPIENTRYP FinishFenceNV)(GLuint fence); /* 655 */
+   void (GLAPIENTRYP GenFencesNV)(GLsizei n, GLuint * fences); /* 656 */
+   void (GLAPIENTRYP GetFenceivNV)(GLuint fence, GLenum pname, GLint * params); /* 657 */
+   GLboolean (GLAPIENTRYP IsFenceNV)(GLuint fence); /* 658 */
+   void (GLAPIENTRYP SetFenceNV)(GLuint fence, GLenum condition); /* 659 */
+   GLboolean (GLAPIENTRYP TestFenceNV)(GLuint fence); /* 660 */
+   GLboolean (GLAPIENTRYP AreProgramsResidentNV)(GLsizei n, const GLuint * ids, GLboolean * residences); /* 661 */
+   void (GLAPIENTRYP BindProgramNV)(GLenum target, GLuint program); /* 662 */
+   void (GLAPIENTRYP DeleteProgramsNV)(GLsizei n, const GLuint * programs); /* 663 */
+   void (GLAPIENTRYP ExecuteProgramNV)(GLenum target, GLuint id, const GLfloat * params); /* 664 */
+   void (GLAPIENTRYP GenProgramsNV)(GLsizei n, GLuint * programs); /* 665 */
+   void (GLAPIENTRYP GetProgramParameterdvNV)(GLenum target, GLuint index, GLenum pname, GLdouble * params); /* 666 */
+   void (GLAPIENTRYP GetProgramParameterfvNV)(GLenum target, GLuint index, GLenum pname, GLfloat * params); /* 667 */
+   void (GLAPIENTRYP GetProgramStringNV)(GLuint id, GLenum pname, GLubyte * program); /* 668 */
+   void (GLAPIENTRYP GetProgramivNV)(GLuint id, GLenum pname, GLint * params); /* 669 */
+   void (GLAPIENTRYP GetTrackMatrixivNV)(GLenum target, GLuint address, GLenum pname, GLint * params); /* 670 */
+   void (GLAPIENTRYP GetVertexAttribPointervNV)(GLuint index, GLenum pname, GLvoid ** pointer); /* 671 */
+   void (GLAPIENTRYP GetVertexAttribdvNV)(GLuint index, GLenum pname, GLdouble * params); /* 672 */
+   void (GLAPIENTRYP GetVertexAttribfvNV)(GLuint index, GLenum pname, GLfloat * params); /* 673 */
+   void (GLAPIENTRYP GetVertexAttribivNV)(GLuint index, GLenum pname, GLint * params); /* 674 */
+   GLboolean (GLAPIENTRYP IsProgramNV)(GLuint program); /* 675 */
+   void (GLAPIENTRYP LoadProgramNV)(GLenum target, GLuint id, GLsizei len, const GLubyte * program); /* 676 */
+   void (GLAPIENTRYP ProgramParameters4dvNV)(GLenum target, GLuint index, GLuint num, const GLdouble * params); /* 677 */
+   void (GLAPIENTRYP ProgramParameters4fvNV)(GLenum target, GLuint index, GLuint num, const GLfloat * params); /* 678 */
+   void (GLAPIENTRYP RequestResidentProgramsNV)(GLsizei n, const GLuint * ids); /* 679 */
+   void (GLAPIENTRYP TrackMatrixNV)(GLenum target, GLuint address, GLenum matrix, GLenum transform); /* 680 */
+   void (GLAPIENTRYP VertexAttrib1dNV)(GLuint index, GLdouble x); /* 681 */
+   void (GLAPIENTRYP VertexAttrib1dvNV)(GLuint index, const GLdouble * v); /* 682 */
+   void (GLAPIENTRYP VertexAttrib1fNV)(GLuint index, GLfloat x); /* 683 */
+   void (GLAPIENTRYP VertexAttrib1fvNV)(GLuint index, const GLfloat * v); /* 684 */
+   void (GLAPIENTRYP VertexAttrib1sNV)(GLuint index, GLshort x); /* 685 */
+   void (GLAPIENTRYP VertexAttrib1svNV)(GLuint index, const GLshort * v); /* 686 */
+   void (GLAPIENTRYP VertexAttrib2dNV)(GLuint index, GLdouble x, GLdouble y); /* 687 */
+   void (GLAPIENTRYP VertexAttrib2dvNV)(GLuint index, const GLdouble * v); /* 688 */
+   void (GLAPIENTRYP VertexAttrib2fNV)(GLuint index, GLfloat x, GLfloat y); /* 689 */
+   void (GLAPIENTRYP VertexAttrib2fvNV)(GLuint index, const GLfloat * v); /* 690 */
+   void (GLAPIENTRYP VertexAttrib2sNV)(GLuint index, GLshort x, GLshort y); /* 691 */
+   void (GLAPIENTRYP VertexAttrib2svNV)(GLuint index, const GLshort * v); /* 692 */
+   void (GLAPIENTRYP VertexAttrib3dNV)(GLuint index, GLdouble x, GLdouble y, GLdouble z); /* 693 */
+   void (GLAPIENTRYP VertexAttrib3dvNV)(GLuint index, const GLdouble * v); /* 694 */
+   void (GLAPIENTRYP VertexAttrib3fNV)(GLuint index, GLfloat x, GLfloat y, GLfloat z); /* 695 */
+   void (GLAPIENTRYP VertexAttrib3fvNV)(GLuint index, const GLfloat * v); /* 696 */
+   void (GLAPIENTRYP VertexAttrib3sNV)(GLuint index, GLshort x, GLshort y, GLshort z); /* 697 */
+   void (GLAPIENTRYP VertexAttrib3svNV)(GLuint index, const GLshort * v); /* 698 */
+   void (GLAPIENTRYP VertexAttrib4dNV)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); /* 699 */
+   void (GLAPIENTRYP VertexAttrib4dvNV)(GLuint index, const GLdouble * v); /* 700 */
+   void (GLAPIENTRYP VertexAttrib4fNV)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); /* 701 */
+   void (GLAPIENTRYP VertexAttrib4fvNV)(GLuint index, const GLfloat * v); /* 702 */
+   void (GLAPIENTRYP VertexAttrib4sNV)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); /* 703 */
+   void (GLAPIENTRYP VertexAttrib4svNV)(GLuint index, const GLshort * v); /* 704 */
+   void (GLAPIENTRYP VertexAttrib4ubNV)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); /* 705 */
+   void (GLAPIENTRYP VertexAttrib4ubvNV)(GLuint index, const GLubyte * v); /* 706 */
+   void (GLAPIENTRYP VertexAttribPointerNV)(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); /* 707 */
+   void (GLAPIENTRYP VertexAttribs1dvNV)(GLuint index, GLsizei n, const GLdouble * v); /* 708 */
+   void (GLAPIENTRYP VertexAttribs1fvNV)(GLuint index, GLsizei n, const GLfloat * v); /* 709 */
+   void (GLAPIENTRYP VertexAttribs1svNV)(GLuint index, GLsizei n, const GLshort * v); /* 710 */
+   void (GLAPIENTRYP VertexAttribs2dvNV)(GLuint index, GLsizei n, const GLdouble * v); /* 711 */
+   void (GLAPIENTRYP VertexAttribs2fvNV)(GLuint index, GLsizei n, const GLfloat * v); /* 712 */
+   void (GLAPIENTRYP VertexAttribs2svNV)(GLuint index, GLsizei n, const GLshort * v); /* 713 */
+   void (GLAPIENTRYP VertexAttribs3dvNV)(GLuint index, GLsizei n, const GLdouble * v); /* 714 */
+   void (GLAPIENTRYP VertexAttribs3fvNV)(GLuint index, GLsizei n, const GLfloat * v); /* 715 */
+   void (GLAPIENTRYP VertexAttribs3svNV)(GLuint index, GLsizei n, const GLshort * v); /* 716 */
+   void (GLAPIENTRYP VertexAttribs4dvNV)(GLuint index, GLsizei n, const GLdouble * v); /* 717 */
+   void (GLAPIENTRYP VertexAttribs4fvNV)(GLuint index, GLsizei n, const GLfloat * v); /* 718 */
+   void (GLAPIENTRYP VertexAttribs4svNV)(GLuint index, GLsizei n, const GLshort * v); /* 719 */
+   void (GLAPIENTRYP VertexAttribs4ubvNV)(GLuint index, GLsizei n, const GLubyte * v); /* 720 */
+   void (GLAPIENTRYP GetTexBumpParameterfvATI)(GLenum pname, GLfloat * param); /* 721 */
+   void (GLAPIENTRYP GetTexBumpParameterivATI)(GLenum pname, GLint * param); /* 722 */
+   void (GLAPIENTRYP TexBumpParameterfvATI)(GLenum pname, const GLfloat * param); /* 723 */
+   void (GLAPIENTRYP TexBumpParameterivATI)(GLenum pname, const GLint * param); /* 724 */
+   void (GLAPIENTRYP AlphaFragmentOp1ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); /* 725 */
+   void (GLAPIENTRYP AlphaFragmentOp2ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); /* 726 */
+   void (GLAPIENTRYP AlphaFragmentOp3ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); /* 727 */
+   void (GLAPIENTRYP BeginFragmentShaderATI)(void); /* 728 */
+   void (GLAPIENTRYP BindFragmentShaderATI)(GLuint id); /* 729 */
+   void (GLAPIENTRYP ColorFragmentOp1ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); /* 730 */
+   void (GLAPIENTRYP ColorFragmentOp2ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); /* 731 */
+   void (GLAPIENTRYP ColorFragmentOp3ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); /* 732 */
+   void (GLAPIENTRYP DeleteFragmentShaderATI)(GLuint id); /* 733 */
+   void (GLAPIENTRYP EndFragmentShaderATI)(void); /* 734 */
+   GLuint (GLAPIENTRYP GenFragmentShadersATI)(GLuint range); /* 735 */
+   void (GLAPIENTRYP PassTexCoordATI)(GLuint dst, GLuint coord, GLenum swizzle); /* 736 */
+   void (GLAPIENTRYP SampleMapATI)(GLuint dst, GLuint interp, GLenum swizzle); /* 737 */
+   void (GLAPIENTRYP SetFragmentShaderConstantATI)(GLuint dst, const GLfloat * value); /* 738 */
+   void (GLAPIENTRYP PointParameteriNV)(GLenum pname, GLint param); /* 739 */
+   void (GLAPIENTRYP PointParameterivNV)(GLenum pname, const GLint * params); /* 740 */
+   void (GLAPIENTRYP ActiveStencilFaceEXT)(GLenum face); /* 741 */
+   void (GLAPIENTRYP BindVertexArrayAPPLE)(GLuint array); /* 742 */
+   void (GLAPIENTRYP DeleteVertexArraysAPPLE)(GLsizei n, const GLuint * arrays); /* 743 */
+   void (GLAPIENTRYP GenVertexArraysAPPLE)(GLsizei n, GLuint * arrays); /* 744 */
+   GLboolean (GLAPIENTRYP IsVertexArrayAPPLE)(GLuint array); /* 745 */
+   void (GLAPIENTRYP GetProgramNamedParameterdvNV)(GLuint id, GLsizei len, const GLubyte * name, GLdouble * params); /* 746 */
+   void (GLAPIENTRYP GetProgramNamedParameterfvNV)(GLuint id, GLsizei len, const GLubyte * name, GLfloat * params); /* 747 */
+   void (GLAPIENTRYP ProgramNamedParameter4dNV)(GLuint id, GLsizei len, const GLubyte * name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); /* 748 */
+   void (GLAPIENTRYP ProgramNamedParameter4dvNV)(GLuint id, GLsizei len, const GLubyte * name, const GLdouble * v); /* 749 */
+   void (GLAPIENTRYP ProgramNamedParameter4fNV)(GLuint id, GLsizei len, const GLubyte * name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); /* 750 */
+   void (GLAPIENTRYP ProgramNamedParameter4fvNV)(GLuint id, GLsizei len, const GLubyte * name, const GLfloat * v); /* 751 */
+   void (GLAPIENTRYP DepthBoundsEXT)(GLclampd zmin, GLclampd zmax); /* 752 */
+   void (GLAPIENTRYP BlendEquationSeparateEXT)(GLenum modeRGB, GLenum modeA); /* 753 */
+   void (GLAPIENTRYP BindFramebufferEXT)(GLenum target, GLuint framebuffer); /* 754 */
+   void (GLAPIENTRYP BindRenderbufferEXT)(GLenum target, GLuint renderbuffer); /* 755 */
+   GLenum (GLAPIENTRYP CheckFramebufferStatusEXT)(GLenum target); /* 756 */
+   void (GLAPIENTRYP DeleteFramebuffersEXT)(GLsizei n, const GLuint * framebuffers); /* 757 */
+   void (GLAPIENTRYP DeleteRenderbuffersEXT)(GLsizei n, const GLuint * renderbuffers); /* 758 */
+   void (GLAPIENTRYP FramebufferRenderbufferEXT)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); /* 759 */
+   void (GLAPIENTRYP FramebufferTexture1DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); /* 760 */
+   void (GLAPIENTRYP FramebufferTexture2DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); /* 761 */
+   void (GLAPIENTRYP FramebufferTexture3DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); /* 762 */
+   void (GLAPIENTRYP GenFramebuffersEXT)(GLsizei n, GLuint * framebuffers); /* 763 */
+   void (GLAPIENTRYP GenRenderbuffersEXT)(GLsizei n, GLuint * renderbuffers); /* 764 */
+   void (GLAPIENTRYP GenerateMipmapEXT)(GLenum target); /* 765 */
+   void (GLAPIENTRYP GetFramebufferAttachmentParameterivEXT)(GLenum target, GLenum attachment, GLenum pname, GLint * params); /* 766 */
+   void (GLAPIENTRYP GetRenderbufferParameterivEXT)(GLenum target, GLenum pname, GLint * params); /* 767 */
+   GLboolean (GLAPIENTRYP IsFramebufferEXT)(GLuint framebuffer); /* 768 */
+   GLboolean (GLAPIENTRYP IsRenderbufferEXT)(GLuint renderbuffer); /* 769 */
+   void (GLAPIENTRYP RenderbufferStorageEXT)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); /* 770 */
+   void (GLAPIENTRYP BlitFramebufferEXT)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); /* 771 */
+   void (GLAPIENTRYP FramebufferTextureLayerEXT)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); /* 772 */
+   void (GLAPIENTRYP StencilFuncSeparateATI)(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); /* 773 */
+   void (GLAPIENTRYP ProgramEnvParameters4fvEXT)(GLenum target, GLuint index, GLsizei count, const GLfloat * params); /* 774 */
+   void (GLAPIENTRYP ProgramLocalParameters4fvEXT)(GLenum target, GLuint index, GLsizei count, const GLfloat * params); /* 775 */
+   void (GLAPIENTRYP GetQueryObjecti64vEXT)(GLuint id, GLenum pname, GLint64EXT * params); /* 776 */
+   void (GLAPIENTRYP GetQueryObjectui64vEXT)(GLuint id, GLenum pname, GLuint64EXT * params); /* 777 */
 };
 
 #endif /* !defined( _GLAPI_TABLE_H_ ) */
index 7ccd9707c3694c46aa46b73263a230c10ae0ac54..b1ac9ff8412a31a161fae58aad1e6ecd01deb311 100644 (file)
@@ -4011,63 +4011,78 @@ KEYWORD1 void KEYWORD2 NAME(RenderbufferStorageMultisample)(GLenum target, GLsiz
    DISPATCH(RenderbufferStorageMultisample, (target, samples, internalformat, width, height), (F, "glRenderbufferStorageMultisample(0x%x, %d, 0x%x, %d, %d);\n", target, samples, internalformat, width, height));
 }
 
+KEYWORD1 void KEYWORD2 NAME(FlushMappedBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length)
+{
+   DISPATCH(FlushMappedBufferRange, (target, offset, length), (F, "glFlushMappedBufferRange(0x%x, %d, %d);\n", target, offset, length));
+}
+
+KEYWORD1 GLvoid * KEYWORD2 NAME(MapBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
+{
+   RETURN_DISPATCH(MapBufferRange, (target, offset, length, access), (F, "glMapBufferRange(0x%x, %d, %d, %d);\n", target, offset, length, access));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CopyBufferSubData)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
+{
+   DISPATCH(CopyBufferSubData, (readTarget, writeTarget, readOffset, writeOffset, size), (F, "glCopyBufferSubData(0x%x, 0x%x, %d, %d, %d);\n", readTarget, writeTarget, readOffset, writeOffset, size));
+}
+
 KEYWORD1 void KEYWORD2 NAME(PolygonOffsetEXT)(GLfloat factor, GLfloat bias)
 {
    DISPATCH(PolygonOffsetEXT, (factor, bias), (F, "glPolygonOffsetEXT(%f, %f);\n", factor, bias));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_563)(GLenum pname, GLfloat * params);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_566)(GLenum pname, GLfloat * params);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_563)(GLenum pname, GLfloat * params)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_566)(GLenum pname, GLfloat * params)
 {
    DISPATCH(GetPixelTexGenParameterfvSGIS, (pname, params), (F, "glGetPixelTexGenParameterfvSGIS(0x%x, %p);\n", pname, (const void *) params));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_564)(GLenum pname, GLint * params);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_567)(GLenum pname, GLint * params);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_564)(GLenum pname, GLint * params)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_567)(GLenum pname, GLint * params)
 {
    DISPATCH(GetPixelTexGenParameterivSGIS, (pname, params), (F, "glGetPixelTexGenParameterivSGIS(0x%x, %p);\n", pname, (const void *) params));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_565)(GLenum pname, GLfloat param);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_568)(GLenum pname, GLfloat param);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_565)(GLenum pname, GLfloat param)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_568)(GLenum pname, GLfloat param)
 {
    DISPATCH(PixelTexGenParameterfSGIS, (pname, param), (F, "glPixelTexGenParameterfSGIS(0x%x, %f);\n", pname, param));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_566)(GLenum pname, const GLfloat * params);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_569)(GLenum pname, const GLfloat * params);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_566)(GLenum pname, const GLfloat * params)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_569)(GLenum pname, const GLfloat * params)
 {
    DISPATCH(PixelTexGenParameterfvSGIS, (pname, params), (F, "glPixelTexGenParameterfvSGIS(0x%x, %p);\n", pname, (const void *) params));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_567)(GLenum pname, GLint param);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_570)(GLenum pname, GLint param);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_567)(GLenum pname, GLint param)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_570)(GLenum pname, GLint param)
 {
    DISPATCH(PixelTexGenParameteriSGIS, (pname, param), (F, "glPixelTexGenParameteriSGIS(0x%x, %d);\n", pname, param));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_568)(GLenum pname, const GLint * params);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_571)(GLenum pname, const GLint * params);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_568)(GLenum pname, const GLint * params)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_571)(GLenum pname, const GLint * params)
 {
    DISPATCH(PixelTexGenParameterivSGIS, (pname, params), (F, "glPixelTexGenParameterivSGIS(0x%x, %p);\n", pname, (const void *) params));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_569)(GLclampf value, GLboolean invert);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_572)(GLclampf value, GLboolean invert);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_569)(GLclampf value, GLboolean invert)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_572)(GLclampf value, GLboolean invert)
 {
    DISPATCH(SampleMaskSGIS, (value, invert), (F, "glSampleMaskSGIS(%f, %d);\n", value, invert));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_570)(GLenum pattern);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_573)(GLenum pattern);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_570)(GLenum pattern)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_573)(GLenum pattern)
 {
    DISPATCH(SamplePatternSGIS, (pattern), (F, "glSamplePatternSGIS(0x%x);\n", pattern));
 }
@@ -4117,9 +4132,9 @@ KEYWORD1 void KEYWORD2 NAME(PointParameterfEXT)(GLenum pname, GLfloat param)
    DISPATCH(PointParameterfEXT, (pname, param), (F, "glPointParameterfEXT(0x%x, %f);\n", pname, param));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_577)(GLenum pname, GLfloat param);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_580)(GLenum pname, GLfloat param);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_577)(GLenum pname, GLfloat param)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_580)(GLenum pname, GLfloat param)
 {
    DISPATCH(PointParameterfEXT, (pname, param), (F, "glPointParameterfSGIS(0x%x, %f);\n", pname, param));
 }
@@ -4139,9 +4154,9 @@ KEYWORD1 void KEYWORD2 NAME(PointParameterfvEXT)(GLenum pname, const GLfloat * p
    DISPATCH(PointParameterfvEXT, (pname, params), (F, "glPointParameterfvEXT(0x%x, %p);\n", pname, (const void *) params));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_578)(GLenum pname, const GLfloat * params);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_581)(GLenum pname, const GLfloat * params);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_578)(GLenum pname, const GLfloat * params)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_581)(GLenum pname, const GLfloat * params)
 {
    DISPATCH(PointParameterfvEXT, (pname, params), (F, "glPointParameterfvSGIS(0x%x, %p);\n", pname, (const void *) params));
 }
@@ -4156,16 +4171,16 @@ KEYWORD1 void KEYWORD2 NAME(UnlockArraysEXT)(void)
    DISPATCH(UnlockArraysEXT, (), (F, "glUnlockArraysEXT();\n"));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_581)(GLenum pname, GLdouble * params);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_584)(GLenum pname, GLdouble * params);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_581)(GLenum pname, GLdouble * params)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_584)(GLenum pname, GLdouble * params)
 {
    DISPATCH(CullParameterdvEXT, (pname, params), (F, "glCullParameterdvEXT(0x%x, %p);\n", pname, (const void *) params));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_582)(GLenum pname, GLfloat * params);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_585)(GLenum pname, GLfloat * params);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_582)(GLenum pname, GLfloat * params)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_585)(GLenum pname, GLfloat * params)
 {
    DISPATCH(CullParameterfvEXT, (pname, params), (F, "glCullParameterfvEXT(0x%x, %p);\n", pname, (const void *) params));
 }
@@ -4410,9 +4425,9 @@ KEYWORD1 void KEYWORD2 NAME(FogCoordfvEXT)(const GLfloat * coord)
    DISPATCH(FogCoordfvEXT, (coord), (F, "glFogCoordfvEXT(%p);\n", (const void *) coord));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_607)(GLenum mode);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_610)(GLenum mode);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_607)(GLenum mode)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_610)(GLenum mode)
 {
    DISPATCH(PixelTexGenSGIX, (mode), (F, "glPixelTexGenSGIX(0x%x);\n", mode));
 }
@@ -4427,9 +4442,9 @@ KEYWORD1 void KEYWORD2 NAME(BlendFuncSeparateEXT)(GLenum sfactorRGB, GLenum dfac
    DISPATCH(BlendFuncSeparateEXT, (sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha), (F, "glBlendFuncSeparateEXT(0x%x, 0x%x, 0x%x, 0x%x);\n", sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_608)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_611)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_608)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_611)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha)
 {
    DISPATCH(BlendFuncSeparateEXT, (sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha), (F, "glBlendFuncSeparateINGR(0x%x, 0x%x, 0x%x, 0x%x);\n", sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha));
 }
@@ -4794,65 +4809,65 @@ KEYWORD1 void KEYWORD2 NAME(WindowPos4svMESA)(const GLshort * v)
    DISPATCH(WindowPos4svMESA, (v), (F, "glWindowPos4svMESA(%p);\n", (const void *) v));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_649)(const GLenum * mode, const GLint * first, const GLsizei * count, GLsizei primcount, GLint modestride);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_652)(const GLenum * mode, const GLint * first, const GLsizei * count, GLsizei primcount, GLint modestride);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_649)(const GLenum * mode, const GLint * first, const GLsizei * count, GLsizei primcount, GLint modestride)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_652)(const GLenum * mode, const GLint * first, const GLsizei * count, GLsizei primcount, GLint modestride)
 {
    DISPATCH(MultiModeDrawArraysIBM, (mode, first, count, primcount, modestride), (F, "glMultiModeDrawArraysIBM(%p, %p, %p, %d, %d);\n", (const void *) mode, (const void *) first, (const void *) count, primcount, modestride));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_650)(const GLenum * mode, const GLsizei * count, GLenum type, const GLvoid * const * indices, GLsizei primcount, GLint modestride);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_653)(const GLenum * mode, const GLsizei * count, GLenum type, const GLvoid * const * indices, GLsizei primcount, GLint modestride);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_650)(const GLenum * mode, const GLsizei * count, GLenum type, const GLvoid * const * indices, GLsizei primcount, GLint modestride)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_653)(const GLenum * mode, const GLsizei * count, GLenum type, const GLvoid * const * indices, GLsizei primcount, GLint modestride)
 {
    DISPATCH(MultiModeDrawElementsIBM, (mode, count, type, indices, primcount, modestride), (F, "glMultiModeDrawElementsIBM(%p, %p, 0x%x, %p, %d, %d);\n", (const void *) mode, (const void *) count, type, (const void *) indices, primcount, modestride));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_651)(GLsizei n, const GLuint * fences);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_654)(GLsizei n, const GLuint * fences);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_651)(GLsizei n, const GLuint * fences)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_654)(GLsizei n, const GLuint * fences)
 {
    DISPATCH(DeleteFencesNV, (n, fences), (F, "glDeleteFencesNV(%d, %p);\n", n, (const void *) fences));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_652)(GLuint fence);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_655)(GLuint fence);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_652)(GLuint fence)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_655)(GLuint fence)
 {
    DISPATCH(FinishFenceNV, (fence), (F, "glFinishFenceNV(%d);\n", fence));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_653)(GLsizei n, GLuint * fences);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_656)(GLsizei n, GLuint * fences);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_653)(GLsizei n, GLuint * fences)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_656)(GLsizei n, GLuint * fences)
 {
    DISPATCH(GenFencesNV, (n, fences), (F, "glGenFencesNV(%d, %p);\n", n, (const void *) fences));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_654)(GLuint fence, GLenum pname, GLint * params);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_657)(GLuint fence, GLenum pname, GLint * params);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_654)(GLuint fence, GLenum pname, GLint * params)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_657)(GLuint fence, GLenum pname, GLint * params)
 {
    DISPATCH(GetFenceivNV, (fence, pname, params), (F, "glGetFenceivNV(%d, 0x%x, %p);\n", fence, pname, (const void *) params));
 }
 
-KEYWORD1_ALT GLboolean KEYWORD2 NAME(_dispatch_stub_655)(GLuint fence);
+KEYWORD1_ALT GLboolean KEYWORD2 NAME(_dispatch_stub_658)(GLuint fence);
 
-KEYWORD1_ALT GLboolean KEYWORD2 NAME(_dispatch_stub_655)(GLuint fence)
+KEYWORD1_ALT GLboolean KEYWORD2 NAME(_dispatch_stub_658)(GLuint fence)
 {
    RETURN_DISPATCH(IsFenceNV, (fence), (F, "glIsFenceNV(%d);\n", fence));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_656)(GLuint fence, GLenum condition);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_659)(GLuint fence, GLenum condition);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_656)(GLuint fence, GLenum condition)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_659)(GLuint fence, GLenum condition)
 {
    DISPATCH(SetFenceNV, (fence, condition), (F, "glSetFenceNV(%d, 0x%x);\n", fence, condition));
 }
 
-KEYWORD1_ALT GLboolean KEYWORD2 NAME(_dispatch_stub_657)(GLuint fence);
+KEYWORD1_ALT GLboolean KEYWORD2 NAME(_dispatch_stub_660)(GLuint fence);
 
-KEYWORD1_ALT GLboolean KEYWORD2 NAME(_dispatch_stub_657)(GLuint fence)
+KEYWORD1_ALT GLboolean KEYWORD2 NAME(_dispatch_stub_660)(GLuint fence)
 {
    RETURN_DISPATCH(TestFenceNV, (fence), (F, "glTestFenceNV(%d);\n", fence));
 }
@@ -5297,37 +5312,37 @@ KEYWORD1 void KEYWORD2 NAME(PointParameterivNV)(GLenum pname, const GLint * para
    DISPATCH(PointParameterivNV, (pname, params), (F, "glPointParameterivNV(0x%x, %p);\n", pname, (const void *) params));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_738)(GLenum face);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_741)(GLenum face);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_738)(GLenum face)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_741)(GLenum face)
 {
    DISPATCH(ActiveStencilFaceEXT, (face), (F, "glActiveStencilFaceEXT(0x%x);\n", face));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_739)(GLuint array);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_742)(GLuint array);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_739)(GLuint array)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_742)(GLuint array)
 {
    DISPATCH(BindVertexArrayAPPLE, (array), (F, "glBindVertexArrayAPPLE(%d);\n", array));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_740)(GLsizei n, const GLuint * arrays);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_743)(GLsizei n, const GLuint * arrays);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_740)(GLsizei n, const GLuint * arrays)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_743)(GLsizei n, const GLuint * arrays)
 {
    DISPATCH(DeleteVertexArraysAPPLE, (n, arrays), (F, "glDeleteVertexArraysAPPLE(%d, %p);\n", n, (const void *) arrays));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_741)(GLsizei n, GLuint * arrays);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_744)(GLsizei n, GLuint * arrays);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_741)(GLsizei n, GLuint * arrays)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_744)(GLsizei n, GLuint * arrays)
 {
    DISPATCH(GenVertexArraysAPPLE, (n, arrays), (F, "glGenVertexArraysAPPLE(%d, %p);\n", n, (const void *) arrays));
 }
 
-KEYWORD1_ALT GLboolean KEYWORD2 NAME(_dispatch_stub_742)(GLuint array);
+KEYWORD1_ALT GLboolean KEYWORD2 NAME(_dispatch_stub_745)(GLuint array);
 
-KEYWORD1_ALT GLboolean KEYWORD2 NAME(_dispatch_stub_742)(GLuint array)
+KEYWORD1_ALT GLboolean KEYWORD2 NAME(_dispatch_stub_745)(GLuint array)
 {
    RETURN_DISPATCH(IsVertexArrayAPPLE, (array), (F, "glIsVertexArrayAPPLE(%d);\n", array));
 }
@@ -5362,9 +5377,9 @@ KEYWORD1 void KEYWORD2 NAME(ProgramNamedParameter4fvNV)(GLuint id, GLsizei len,
    DISPATCH(ProgramNamedParameter4fvNV, (id, len, name, v), (F, "glProgramNamedParameter4fvNV(%d, %d, %p, %p);\n", id, len, (const void *) name, (const void *) v));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_749)(GLclampd zmin, GLclampd zmax);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_752)(GLclampd zmin, GLclampd zmax);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_749)(GLclampd zmin, GLclampd zmax)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_752)(GLclampd zmin, GLclampd zmax)
 {
    DISPATCH(DepthBoundsEXT, (zmin, zmax), (F, "glDepthBoundsEXT(%f, %f);\n", zmin, zmax));
 }
@@ -5374,9 +5389,9 @@ KEYWORD1 void KEYWORD2 NAME(BlendEquationSeparate)(GLenum modeRGB, GLenum modeA)
    DISPATCH(BlendEquationSeparateEXT, (modeRGB, modeA), (F, "glBlendEquationSeparate(0x%x, 0x%x);\n", modeRGB, modeA));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_750)(GLenum modeRGB, GLenum modeA);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_753)(GLenum modeRGB, GLenum modeA);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_750)(GLenum modeRGB, GLenum modeA)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_753)(GLenum modeRGB, GLenum modeA)
 {
    DISPATCH(BlendEquationSeparateEXT, (modeRGB, modeA), (F, "glBlendEquationSeparateEXT(0x%x, 0x%x);\n", modeRGB, modeA));
 }
@@ -5556,9 +5571,9 @@ KEYWORD1 void KEYWORD2 NAME(BlitFramebuffer)(GLint srcX0, GLint srcY0, GLint src
    DISPATCH(BlitFramebufferEXT, (srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter), (F, "glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d, %d, 0x%x);\n", srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_768)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_771)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_768)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_771)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
 {
    DISPATCH(BlitFramebufferEXT, (srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter), (F, "glBlitFramebufferEXT(%d, %d, %d, %d, %d, %d, %d, %d, %d, 0x%x);\n", srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter));
 }
@@ -5573,37 +5588,37 @@ KEYWORD1 void KEYWORD2 NAME(FramebufferTextureLayerEXT)(GLenum target, GLenum at
    DISPATCH(FramebufferTextureLayerEXT, (target, attachment, texture, level, layer), (F, "glFramebufferTextureLayerEXT(0x%x, 0x%x, %d, %d, %d);\n", target, attachment, texture, level, layer));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_770)(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_773)(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_770)(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_773)(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask)
 {
    DISPATCH(StencilFuncSeparateATI, (frontfunc, backfunc, ref, mask), (F, "glStencilFuncSeparateATI(0x%x, 0x%x, %d, %d);\n", frontfunc, backfunc, ref, mask));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_771)(GLenum target, GLuint index, GLsizei count, const GLfloat * params);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_774)(GLenum target, GLuint index, GLsizei count, const GLfloat * params);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_771)(GLenum target, GLuint index, GLsizei count, const GLfloat * params)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_774)(GLenum target, GLuint index, GLsizei count, const GLfloat * params)
 {
    DISPATCH(ProgramEnvParameters4fvEXT, (target, index, count, params), (F, "glProgramEnvParameters4fvEXT(0x%x, %d, %d, %p);\n", target, index, count, (const void *) params));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_772)(GLenum target, GLuint index, GLsizei count, const GLfloat * params);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_775)(GLenum target, GLuint index, GLsizei count, const GLfloat * params);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_772)(GLenum target, GLuint index, GLsizei count, const GLfloat * params)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_775)(GLenum target, GLuint index, GLsizei count, const GLfloat * params)
 {
    DISPATCH(ProgramLocalParameters4fvEXT, (target, index, count, params), (F, "glProgramLocalParameters4fvEXT(0x%x, %d, %d, %p);\n", target, index, count, (const void *) params));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_773)(GLuint id, GLenum pname, GLint64EXT * params);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_776)(GLuint id, GLenum pname, GLint64EXT * params);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_773)(GLuint id, GLenum pname, GLint64EXT * params)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_776)(GLuint id, GLenum pname, GLint64EXT * params)
 {
    DISPATCH(GetQueryObjecti64vEXT, (id, pname, params), (F, "glGetQueryObjecti64vEXT(%d, 0x%x, %p);\n", id, pname, (const void *) params));
 }
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_774)(GLuint id, GLenum pname, GLuint64EXT * params);
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_777)(GLuint id, GLenum pname, GLuint64EXT * params);
 
-KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_774)(GLuint id, GLenum pname, GLuint64EXT * params)
+KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_777)(GLuint id, GLenum pname, GLuint64EXT * params)
 {
    DISPATCH(GetQueryObjectui64vEXT, (id, pname, params), (F, "glGetQueryObjectui64vEXT(%d, 0x%x, %p);\n", id, pname, (const void *) params));
 }
@@ -6184,15 +6199,18 @@ static _glapi_proc DISPATCH_TABLE_NAME[] = {
    TABLE_ENTRY(GetAttribLocationARB),
    TABLE_ENTRY(DrawBuffersARB),
    TABLE_ENTRY(RenderbufferStorageMultisample),
+   TABLE_ENTRY(FlushMappedBufferRange),
+   TABLE_ENTRY(MapBufferRange),
+   TABLE_ENTRY(CopyBufferSubData),
    TABLE_ENTRY(PolygonOffsetEXT),
-   TABLE_ENTRY(_dispatch_stub_563),
-   TABLE_ENTRY(_dispatch_stub_564),
-   TABLE_ENTRY(_dispatch_stub_565),
    TABLE_ENTRY(_dispatch_stub_566),
    TABLE_ENTRY(_dispatch_stub_567),
    TABLE_ENTRY(_dispatch_stub_568),
    TABLE_ENTRY(_dispatch_stub_569),
    TABLE_ENTRY(_dispatch_stub_570),
+   TABLE_ENTRY(_dispatch_stub_571),
+   TABLE_ENTRY(_dispatch_stub_572),
+   TABLE_ENTRY(_dispatch_stub_573),
    TABLE_ENTRY(ColorPointerEXT),
    TABLE_ENTRY(EdgeFlagPointerEXT),
    TABLE_ENTRY(IndexPointerEXT),
@@ -6203,8 +6221,8 @@ static _glapi_proc DISPATCH_TABLE_NAME[] = {
    TABLE_ENTRY(PointParameterfvEXT),
    TABLE_ENTRY(LockArraysEXT),
    TABLE_ENTRY(UnlockArraysEXT),
-   TABLE_ENTRY(_dispatch_stub_581),
-   TABLE_ENTRY(_dispatch_stub_582),
+   TABLE_ENTRY(_dispatch_stub_584),
+   TABLE_ENTRY(_dispatch_stub_585),
    TABLE_ENTRY(SecondaryColor3bEXT),
    TABLE_ENTRY(SecondaryColor3bvEXT),
    TABLE_ENTRY(SecondaryColor3dEXT),
@@ -6229,7 +6247,7 @@ static _glapi_proc DISPATCH_TABLE_NAME[] = {
    TABLE_ENTRY(FogCoorddvEXT),
    TABLE_ENTRY(FogCoordfEXT),
    TABLE_ENTRY(FogCoordfvEXT),
-   TABLE_ENTRY(_dispatch_stub_607),
+   TABLE_ENTRY(_dispatch_stub_610),
    TABLE_ENTRY(BlendFuncSeparateEXT),
    TABLE_ENTRY(FlushVertexArrayRangeNV),
    TABLE_ENTRY(VertexArrayRangeNV),
@@ -6271,15 +6289,15 @@ static _glapi_proc DISPATCH_TABLE_NAME[] = {
    TABLE_ENTRY(WindowPos4ivMESA),
    TABLE_ENTRY(WindowPos4sMESA),
    TABLE_ENTRY(WindowPos4svMESA),
-   TABLE_ENTRY(_dispatch_stub_649),
-   TABLE_ENTRY(_dispatch_stub_650),
-   TABLE_ENTRY(_dispatch_stub_651),
    TABLE_ENTRY(_dispatch_stub_652),
    TABLE_ENTRY(_dispatch_stub_653),
    TABLE_ENTRY(_dispatch_stub_654),
    TABLE_ENTRY(_dispatch_stub_655),
    TABLE_ENTRY(_dispatch_stub_656),
    TABLE_ENTRY(_dispatch_stub_657),
+   TABLE_ENTRY(_dispatch_stub_658),
+   TABLE_ENTRY(_dispatch_stub_659),
+   TABLE_ENTRY(_dispatch_stub_660),
    TABLE_ENTRY(AreProgramsResidentNV),
    TABLE_ENTRY(BindProgramNV),
    TABLE_ENTRY(DeleteProgramsNV),
@@ -6360,19 +6378,19 @@ static _glapi_proc DISPATCH_TABLE_NAME[] = {
    TABLE_ENTRY(SetFragmentShaderConstantATI),
    TABLE_ENTRY(PointParameteriNV),
    TABLE_ENTRY(PointParameterivNV),
-   TABLE_ENTRY(_dispatch_stub_738),
-   TABLE_ENTRY(_dispatch_stub_739),
-   TABLE_ENTRY(_dispatch_stub_740),
    TABLE_ENTRY(_dispatch_stub_741),
    TABLE_ENTRY(_dispatch_stub_742),
+   TABLE_ENTRY(_dispatch_stub_743),
+   TABLE_ENTRY(_dispatch_stub_744),
+   TABLE_ENTRY(_dispatch_stub_745),
    TABLE_ENTRY(GetProgramNamedParameterdvNV),
    TABLE_ENTRY(GetProgramNamedParameterfvNV),
    TABLE_ENTRY(ProgramNamedParameter4dNV),
    TABLE_ENTRY(ProgramNamedParameter4dvNV),
    TABLE_ENTRY(ProgramNamedParameter4fNV),
    TABLE_ENTRY(ProgramNamedParameter4fvNV),
-   TABLE_ENTRY(_dispatch_stub_749),
-   TABLE_ENTRY(_dispatch_stub_750),
+   TABLE_ENTRY(_dispatch_stub_752),
+   TABLE_ENTRY(_dispatch_stub_753),
    TABLE_ENTRY(BindFramebufferEXT),
    TABLE_ENTRY(BindRenderbufferEXT),
    TABLE_ENTRY(CheckFramebufferStatusEXT),
@@ -6390,13 +6408,13 @@ static _glapi_proc DISPATCH_TABLE_NAME[] = {
    TABLE_ENTRY(IsFramebufferEXT),
    TABLE_ENTRY(IsRenderbufferEXT),
    TABLE_ENTRY(RenderbufferStorageEXT),
-   TABLE_ENTRY(_dispatch_stub_768),
-   TABLE_ENTRY(FramebufferTextureLayerEXT),
-   TABLE_ENTRY(_dispatch_stub_770),
    TABLE_ENTRY(_dispatch_stub_771),
-   TABLE_ENTRY(_dispatch_stub_772),
+   TABLE_ENTRY(FramebufferTextureLayerEXT),
    TABLE_ENTRY(_dispatch_stub_773),
    TABLE_ENTRY(_dispatch_stub_774),
+   TABLE_ENTRY(_dispatch_stub_775),
+   TABLE_ENTRY(_dispatch_stub_776),
+   TABLE_ENTRY(_dispatch_stub_777),
    /* A whole bunch of no-op functions.  These might be called
     * when someone tries to call a dynamically-registered
     * extension function without a current rendering context.
index 680893cfc4eb287d11984bdf6d813287c5ac7369..2a7cca5b2b9db844a0ad4ea22945ec4bffc41e5b 100644 (file)
@@ -614,6 +614,9 @@ static const char gl_string_table[] =
     "glGetAttribLocationARB\0"
     "glDrawBuffersARB\0"
     "glRenderbufferStorageMultisample\0"
+    "glFlushMappedBufferRange\0"
+    "glMapBufferRange\0"
+    "glCopyBufferSubData\0"
     "glPolygonOffsetEXT\0"
     "glGetPixelTexGenParameterfvSGIS\0"
     "glGetPixelTexGenParameterivSGIS\0"
@@ -1142,39 +1145,39 @@ static const char gl_string_table[] =
 #define gl_dispatch_stub_364 mgl_dispatch_stub_364
 #define gl_dispatch_stub_365 mgl_dispatch_stub_365
 #define gl_dispatch_stub_366 mgl_dispatch_stub_366
-#define gl_dispatch_stub_563 mgl_dispatch_stub_563
-#define gl_dispatch_stub_564 mgl_dispatch_stub_564
-#define gl_dispatch_stub_565 mgl_dispatch_stub_565
 #define gl_dispatch_stub_566 mgl_dispatch_stub_566
 #define gl_dispatch_stub_567 mgl_dispatch_stub_567
 #define gl_dispatch_stub_568 mgl_dispatch_stub_568
 #define gl_dispatch_stub_569 mgl_dispatch_stub_569
 #define gl_dispatch_stub_570 mgl_dispatch_stub_570
-#define gl_dispatch_stub_581 mgl_dispatch_stub_581
-#define gl_dispatch_stub_582 mgl_dispatch_stub_582
-#define gl_dispatch_stub_607 mgl_dispatch_stub_607
-#define gl_dispatch_stub_649 mgl_dispatch_stub_649
-#define gl_dispatch_stub_650 mgl_dispatch_stub_650
-#define gl_dispatch_stub_651 mgl_dispatch_stub_651
+#define gl_dispatch_stub_571 mgl_dispatch_stub_571
+#define gl_dispatch_stub_572 mgl_dispatch_stub_572
+#define gl_dispatch_stub_573 mgl_dispatch_stub_573
+#define gl_dispatch_stub_584 mgl_dispatch_stub_584
+#define gl_dispatch_stub_585 mgl_dispatch_stub_585
+#define gl_dispatch_stub_610 mgl_dispatch_stub_610
 #define gl_dispatch_stub_652 mgl_dispatch_stub_652
 #define gl_dispatch_stub_653 mgl_dispatch_stub_653
 #define gl_dispatch_stub_654 mgl_dispatch_stub_654
 #define gl_dispatch_stub_655 mgl_dispatch_stub_655
 #define gl_dispatch_stub_656 mgl_dispatch_stub_656
 #define gl_dispatch_stub_657 mgl_dispatch_stub_657
-#define gl_dispatch_stub_738 mgl_dispatch_stub_738
-#define gl_dispatch_stub_739 mgl_dispatch_stub_739
-#define gl_dispatch_stub_740 mgl_dispatch_stub_740
+#define gl_dispatch_stub_658 mgl_dispatch_stub_658
+#define gl_dispatch_stub_659 mgl_dispatch_stub_659
+#define gl_dispatch_stub_660 mgl_dispatch_stub_660
 #define gl_dispatch_stub_741 mgl_dispatch_stub_741
 #define gl_dispatch_stub_742 mgl_dispatch_stub_742
-#define gl_dispatch_stub_749 mgl_dispatch_stub_749
-#define gl_dispatch_stub_750 mgl_dispatch_stub_750
-#define gl_dispatch_stub_768 mgl_dispatch_stub_768
-#define gl_dispatch_stub_770 mgl_dispatch_stub_770
+#define gl_dispatch_stub_743 mgl_dispatch_stub_743
+#define gl_dispatch_stub_744 mgl_dispatch_stub_744
+#define gl_dispatch_stub_745 mgl_dispatch_stub_745
+#define gl_dispatch_stub_752 mgl_dispatch_stub_752
+#define gl_dispatch_stub_753 mgl_dispatch_stub_753
 #define gl_dispatch_stub_771 mgl_dispatch_stub_771
-#define gl_dispatch_stub_772 mgl_dispatch_stub_772
 #define gl_dispatch_stub_773 mgl_dispatch_stub_773
 #define gl_dispatch_stub_774 mgl_dispatch_stub_774
+#define gl_dispatch_stub_775 mgl_dispatch_stub_775
+#define gl_dispatch_stub_776 mgl_dispatch_stub_776
+#define gl_dispatch_stub_777 mgl_dispatch_stub_777
 #endif /* USE_MGL_NAMESPACE */
 
 
@@ -1192,39 +1195,39 @@ void GLAPIENTRY gl_dispatch_stub_363(GLenum target, GLenum pname, GLint * params
 void GLAPIENTRY gl_dispatch_stub_364(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values);
 void GLAPIENTRY gl_dispatch_stub_365(GLenum target, GLenum pname, GLfloat * params);
 void GLAPIENTRY gl_dispatch_stub_366(GLenum target, GLenum pname, GLint * params);
-void GLAPIENTRY gl_dispatch_stub_563(GLenum pname, GLfloat * params);
-void GLAPIENTRY gl_dispatch_stub_564(GLenum pname, GLint * params);
-void GLAPIENTRY gl_dispatch_stub_565(GLenum pname, GLfloat param);
-void GLAPIENTRY gl_dispatch_stub_566(GLenum pname, const GLfloat * params);
-void GLAPIENTRY gl_dispatch_stub_567(GLenum pname, GLint param);
-void GLAPIENTRY gl_dispatch_stub_568(GLenum pname, const GLint * params);
-void GLAPIENTRY gl_dispatch_stub_569(GLclampf value, GLboolean invert);
-void GLAPIENTRY gl_dispatch_stub_570(GLenum pattern);
-void GLAPIENTRY gl_dispatch_stub_581(GLenum pname, GLdouble * params);
-void GLAPIENTRY gl_dispatch_stub_582(GLenum pname, GLfloat * params);
-void GLAPIENTRY gl_dispatch_stub_607(GLenum mode);
-void GLAPIENTRY gl_dispatch_stub_649(const GLenum * mode, const GLint * first, const GLsizei * count, GLsizei primcount, GLint modestride);
-void GLAPIENTRY gl_dispatch_stub_650(const GLenum * mode, const GLsizei * count, GLenum type, const GLvoid * const * indices, GLsizei primcount, GLint modestride);
-void GLAPIENTRY gl_dispatch_stub_651(GLsizei n, const GLuint * fences);
-void GLAPIENTRY gl_dispatch_stub_652(GLuint fence);
-void GLAPIENTRY gl_dispatch_stub_653(GLsizei n, GLuint * fences);
-void GLAPIENTRY gl_dispatch_stub_654(GLuint fence, GLenum pname, GLint * params);
-GLboolean GLAPIENTRY gl_dispatch_stub_655(GLuint fence);
-void GLAPIENTRY gl_dispatch_stub_656(GLuint fence, GLenum condition);
-GLboolean GLAPIENTRY gl_dispatch_stub_657(GLuint fence);
-void GLAPIENTRY gl_dispatch_stub_738(GLenum face);
-void GLAPIENTRY gl_dispatch_stub_739(GLuint array);
-void GLAPIENTRY gl_dispatch_stub_740(GLsizei n, const GLuint * arrays);
-void GLAPIENTRY gl_dispatch_stub_741(GLsizei n, GLuint * arrays);
-GLboolean GLAPIENTRY gl_dispatch_stub_742(GLuint array);
-void GLAPIENTRY gl_dispatch_stub_749(GLclampd zmin, GLclampd zmax);
-void GLAPIENTRY gl_dispatch_stub_750(GLenum modeRGB, GLenum modeA);
-void GLAPIENTRY gl_dispatch_stub_768(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
-void GLAPIENTRY gl_dispatch_stub_770(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
-void GLAPIENTRY gl_dispatch_stub_771(GLenum target, GLuint index, GLsizei count, const GLfloat * params);
-void GLAPIENTRY gl_dispatch_stub_772(GLenum target, GLuint index, GLsizei count, const GLfloat * params);
-void GLAPIENTRY gl_dispatch_stub_773(GLuint id, GLenum pname, GLint64EXT * params);
-void GLAPIENTRY gl_dispatch_stub_774(GLuint id, GLenum pname, GLuint64EXT * params);
+void GLAPIENTRY gl_dispatch_stub_566(GLenum pname, GLfloat * params);
+void GLAPIENTRY gl_dispatch_stub_567(GLenum pname, GLint * params);
+void GLAPIENTRY gl_dispatch_stub_568(GLenum pname, GLfloat param);
+void GLAPIENTRY gl_dispatch_stub_569(GLenum pname, const GLfloat * params);
+void GLAPIENTRY gl_dispatch_stub_570(GLenum pname, GLint param);
+void GLAPIENTRY gl_dispatch_stub_571(GLenum pname, const GLint * params);
+void GLAPIENTRY gl_dispatch_stub_572(GLclampf value, GLboolean invert);
+void GLAPIENTRY gl_dispatch_stub_573(GLenum pattern);
+void GLAPIENTRY gl_dispatch_stub_584(GLenum pname, GLdouble * params);
+void GLAPIENTRY gl_dispatch_stub_585(GLenum pname, GLfloat * params);
+void GLAPIENTRY gl_dispatch_stub_610(GLenum mode);
+void GLAPIENTRY gl_dispatch_stub_652(const GLenum * mode, const GLint * first, const GLsizei * count, GLsizei primcount, GLint modestride);
+void GLAPIENTRY gl_dispatch_stub_653(const GLenum * mode, const GLsizei * count, GLenum type, const GLvoid * const * indices, GLsizei primcount, GLint modestride);
+void GLAPIENTRY gl_dispatch_stub_654(GLsizei n, const GLuint * fences);
+void GLAPIENTRY gl_dispatch_stub_655(GLuint fence);
+void GLAPIENTRY gl_dispatch_stub_656(GLsizei n, GLuint * fences);
+void GLAPIENTRY gl_dispatch_stub_657(GLuint fence, GLenum pname, GLint * params);
+GLboolean GLAPIENTRY gl_dispatch_stub_658(GLuint fence);
+void GLAPIENTRY gl_dispatch_stub_659(GLuint fence, GLenum condition);
+GLboolean GLAPIENTRY gl_dispatch_stub_660(GLuint fence);
+void GLAPIENTRY gl_dispatch_stub_741(GLenum face);
+void GLAPIENTRY gl_dispatch_stub_742(GLuint array);
+void GLAPIENTRY gl_dispatch_stub_743(GLsizei n, const GLuint * arrays);
+void GLAPIENTRY gl_dispatch_stub_744(GLsizei n, GLuint * arrays);
+GLboolean GLAPIENTRY gl_dispatch_stub_745(GLuint array);
+void GLAPIENTRY gl_dispatch_stub_752(GLclampd zmin, GLclampd zmax);
+void GLAPIENTRY gl_dispatch_stub_753(GLenum modeRGB, GLenum modeA);
+void GLAPIENTRY gl_dispatch_stub_771(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+void GLAPIENTRY gl_dispatch_stub_773(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
+void GLAPIENTRY gl_dispatch_stub_774(GLenum target, GLuint index, GLsizei count, const GLfloat * params);
+void GLAPIENTRY gl_dispatch_stub_775(GLenum target, GLuint index, GLsizei count, const GLfloat * params);
+void GLAPIENTRY gl_dispatch_stub_776(GLuint id, GLenum pname, GLint64EXT * params);
+void GLAPIENTRY gl_dispatch_stub_777(GLuint id, GLenum pname, GLuint64EXT * params);
 #endif /* defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING) */
 
 static const glprocs_table_t static_functions[] = {
@@ -1790,517 +1793,520 @@ static const glprocs_table_t static_functions[] = {
     NAME_FUNC_OFFSET( 8911, glGetAttribLocationARB, glGetAttribLocationARB, NULL, _gloffset_GetAttribLocationARB),
     NAME_FUNC_OFFSET( 8934, glDrawBuffersARB, glDrawBuffersARB, NULL, _gloffset_DrawBuffersARB),
     NAME_FUNC_OFFSET( 8951, glRenderbufferStorageMultisample, glRenderbufferStorageMultisample, NULL, _gloffset_RenderbufferStorageMultisample),
-    NAME_FUNC_OFFSET( 8984, glPolygonOffsetEXT, glPolygonOffsetEXT, NULL, _gloffset_PolygonOffsetEXT),
-    NAME_FUNC_OFFSET( 9003, gl_dispatch_stub_563, gl_dispatch_stub_563, NULL, _gloffset_GetPixelTexGenParameterfvSGIS),
-    NAME_FUNC_OFFSET( 9035, gl_dispatch_stub_564, gl_dispatch_stub_564, NULL, _gloffset_GetPixelTexGenParameterivSGIS),
-    NAME_FUNC_OFFSET( 9067, gl_dispatch_stub_565, gl_dispatch_stub_565, NULL, _gloffset_PixelTexGenParameterfSGIS),
-    NAME_FUNC_OFFSET( 9095, gl_dispatch_stub_566, gl_dispatch_stub_566, NULL, _gloffset_PixelTexGenParameterfvSGIS),
-    NAME_FUNC_OFFSET( 9124, gl_dispatch_stub_567, gl_dispatch_stub_567, NULL, _gloffset_PixelTexGenParameteriSGIS),
-    NAME_FUNC_OFFSET( 9152, gl_dispatch_stub_568, gl_dispatch_stub_568, NULL, _gloffset_PixelTexGenParameterivSGIS),
-    NAME_FUNC_OFFSET( 9181, gl_dispatch_stub_569, gl_dispatch_stub_569, NULL, _gloffset_SampleMaskSGIS),
-    NAME_FUNC_OFFSET( 9198, gl_dispatch_stub_570, gl_dispatch_stub_570, NULL, _gloffset_SamplePatternSGIS),
-    NAME_FUNC_OFFSET( 9218, glColorPointerEXT, glColorPointerEXT, NULL, _gloffset_ColorPointerEXT),
-    NAME_FUNC_OFFSET( 9236, glEdgeFlagPointerEXT, glEdgeFlagPointerEXT, NULL, _gloffset_EdgeFlagPointerEXT),
-    NAME_FUNC_OFFSET( 9257, glIndexPointerEXT, glIndexPointerEXT, NULL, _gloffset_IndexPointerEXT),
-    NAME_FUNC_OFFSET( 9275, glNormalPointerEXT, glNormalPointerEXT, NULL, _gloffset_NormalPointerEXT),
-    NAME_FUNC_OFFSET( 9294, glTexCoordPointerEXT, glTexCoordPointerEXT, NULL, _gloffset_TexCoordPointerEXT),
-    NAME_FUNC_OFFSET( 9315, glVertexPointerEXT, glVertexPointerEXT, NULL, _gloffset_VertexPointerEXT),
-    NAME_FUNC_OFFSET( 9334, glPointParameterfEXT, glPointParameterfEXT, NULL, _gloffset_PointParameterfEXT),
-    NAME_FUNC_OFFSET( 9355, glPointParameterfvEXT, glPointParameterfvEXT, NULL, _gloffset_PointParameterfvEXT),
-    NAME_FUNC_OFFSET( 9377, glLockArraysEXT, glLockArraysEXT, NULL, _gloffset_LockArraysEXT),
-    NAME_FUNC_OFFSET( 9393, glUnlockArraysEXT, glUnlockArraysEXT, NULL, _gloffset_UnlockArraysEXT),
-    NAME_FUNC_OFFSET( 9411, gl_dispatch_stub_581, gl_dispatch_stub_581, NULL, _gloffset_CullParameterdvEXT),
-    NAME_FUNC_OFFSET( 9432, gl_dispatch_stub_582, gl_dispatch_stub_582, NULL, _gloffset_CullParameterfvEXT),
-    NAME_FUNC_OFFSET( 9453, glSecondaryColor3bEXT, glSecondaryColor3bEXT, NULL, _gloffset_SecondaryColor3bEXT),
-    NAME_FUNC_OFFSET( 9475, glSecondaryColor3bvEXT, glSecondaryColor3bvEXT, NULL, _gloffset_SecondaryColor3bvEXT),
-    NAME_FUNC_OFFSET( 9498, glSecondaryColor3dEXT, glSecondaryColor3dEXT, NULL, _gloffset_SecondaryColor3dEXT),
-    NAME_FUNC_OFFSET( 9520, glSecondaryColor3dvEXT, glSecondaryColor3dvEXT, NULL, _gloffset_SecondaryColor3dvEXT),
-    NAME_FUNC_OFFSET( 9543, glSecondaryColor3fEXT, glSecondaryColor3fEXT, NULL, _gloffset_SecondaryColor3fEXT),
-    NAME_FUNC_OFFSET( 9565, glSecondaryColor3fvEXT, glSecondaryColor3fvEXT, NULL, _gloffset_SecondaryColor3fvEXT),
-    NAME_FUNC_OFFSET( 9588, glSecondaryColor3iEXT, glSecondaryColor3iEXT, NULL, _gloffset_SecondaryColor3iEXT),
-    NAME_FUNC_OFFSET( 9610, glSecondaryColor3ivEXT, glSecondaryColor3ivEXT, NULL, _gloffset_SecondaryColor3ivEXT),
-    NAME_FUNC_OFFSET( 9633, glSecondaryColor3sEXT, glSecondaryColor3sEXT, NULL, _gloffset_SecondaryColor3sEXT),
-    NAME_FUNC_OFFSET( 9655, glSecondaryColor3svEXT, glSecondaryColor3svEXT, NULL, _gloffset_SecondaryColor3svEXT),
-    NAME_FUNC_OFFSET( 9678, glSecondaryColor3ubEXT, glSecondaryColor3ubEXT, NULL, _gloffset_SecondaryColor3ubEXT),
-    NAME_FUNC_OFFSET( 9701, glSecondaryColor3ubvEXT, glSecondaryColor3ubvEXT, NULL, _gloffset_SecondaryColor3ubvEXT),
-    NAME_FUNC_OFFSET( 9725, glSecondaryColor3uiEXT, glSecondaryColor3uiEXT, NULL, _gloffset_SecondaryColor3uiEXT),
-    NAME_FUNC_OFFSET( 9748, glSecondaryColor3uivEXT, glSecondaryColor3uivEXT, NULL, _gloffset_SecondaryColor3uivEXT),
-    NAME_FUNC_OFFSET( 9772, glSecondaryColor3usEXT, glSecondaryColor3usEXT, NULL, _gloffset_SecondaryColor3usEXT),
-    NAME_FUNC_OFFSET( 9795, glSecondaryColor3usvEXT, glSecondaryColor3usvEXT, NULL, _gloffset_SecondaryColor3usvEXT),
-    NAME_FUNC_OFFSET( 9819, glSecondaryColorPointerEXT, glSecondaryColorPointerEXT, NULL, _gloffset_SecondaryColorPointerEXT),
-    NAME_FUNC_OFFSET( 9846, glMultiDrawArraysEXT, glMultiDrawArraysEXT, NULL, _gloffset_MultiDrawArraysEXT),
-    NAME_FUNC_OFFSET( 9867, glMultiDrawElementsEXT, glMultiDrawElementsEXT, NULL, _gloffset_MultiDrawElementsEXT),
-    NAME_FUNC_OFFSET( 9890, glFogCoordPointerEXT, glFogCoordPointerEXT, NULL, _gloffset_FogCoordPointerEXT),
-    NAME_FUNC_OFFSET( 9911, glFogCoorddEXT, glFogCoorddEXT, NULL, _gloffset_FogCoorddEXT),
-    NAME_FUNC_OFFSET( 9926, glFogCoorddvEXT, glFogCoorddvEXT, NULL, _gloffset_FogCoorddvEXT),
-    NAME_FUNC_OFFSET( 9942, glFogCoordfEXT, glFogCoordfEXT, NULL, _gloffset_FogCoordfEXT),
-    NAME_FUNC_OFFSET( 9957, glFogCoordfvEXT, glFogCoordfvEXT, NULL, _gloffset_FogCoordfvEXT),
-    NAME_FUNC_OFFSET( 9973, gl_dispatch_stub_607, gl_dispatch_stub_607, NULL, _gloffset_PixelTexGenSGIX),
-    NAME_FUNC_OFFSET( 9991, glBlendFuncSeparateEXT, glBlendFuncSeparateEXT, NULL, _gloffset_BlendFuncSeparateEXT),
-    NAME_FUNC_OFFSET(10014, glFlushVertexArrayRangeNV, glFlushVertexArrayRangeNV, NULL, _gloffset_FlushVertexArrayRangeNV),
-    NAME_FUNC_OFFSET(10040, glVertexArrayRangeNV, glVertexArrayRangeNV, NULL, _gloffset_VertexArrayRangeNV),
-    NAME_FUNC_OFFSET(10061, glCombinerInputNV, glCombinerInputNV, NULL, _gloffset_CombinerInputNV),
-    NAME_FUNC_OFFSET(10079, glCombinerOutputNV, glCombinerOutputNV, NULL, _gloffset_CombinerOutputNV),
-    NAME_FUNC_OFFSET(10098, glCombinerParameterfNV, glCombinerParameterfNV, NULL, _gloffset_CombinerParameterfNV),
-    NAME_FUNC_OFFSET(10121, glCombinerParameterfvNV, glCombinerParameterfvNV, NULL, _gloffset_CombinerParameterfvNV),
-    NAME_FUNC_OFFSET(10145, glCombinerParameteriNV, glCombinerParameteriNV, NULL, _gloffset_CombinerParameteriNV),
-    NAME_FUNC_OFFSET(10168, glCombinerParameterivNV, glCombinerParameterivNV, NULL, _gloffset_CombinerParameterivNV),
-    NAME_FUNC_OFFSET(10192, glFinalCombinerInputNV, glFinalCombinerInputNV, NULL, _gloffset_FinalCombinerInputNV),
-    NAME_FUNC_OFFSET(10215, glGetCombinerInputParameterfvNV, glGetCombinerInputParameterfvNV, NULL, _gloffset_GetCombinerInputParameterfvNV),
-    NAME_FUNC_OFFSET(10247, glGetCombinerInputParameterivNV, glGetCombinerInputParameterivNV, NULL, _gloffset_GetCombinerInputParameterivNV),
-    NAME_FUNC_OFFSET(10279, glGetCombinerOutputParameterfvNV, glGetCombinerOutputParameterfvNV, NULL, _gloffset_GetCombinerOutputParameterfvNV),
-    NAME_FUNC_OFFSET(10312, glGetCombinerOutputParameterivNV, glGetCombinerOutputParameterivNV, NULL, _gloffset_GetCombinerOutputParameterivNV),
-    NAME_FUNC_OFFSET(10345, glGetFinalCombinerInputParameterfvNV, glGetFinalCombinerInputParameterfvNV, NULL, _gloffset_GetFinalCombinerInputParameterfvNV),
-    NAME_FUNC_OFFSET(10382, glGetFinalCombinerInputParameterivNV, glGetFinalCombinerInputParameterivNV, NULL, _gloffset_GetFinalCombinerInputParameterivNV),
-    NAME_FUNC_OFFSET(10419, glResizeBuffersMESA, glResizeBuffersMESA, NULL, _gloffset_ResizeBuffersMESA),
-    NAME_FUNC_OFFSET(10439, glWindowPos2dMESA, glWindowPos2dMESA, NULL, _gloffset_WindowPos2dMESA),
-    NAME_FUNC_OFFSET(10457, glWindowPos2dvMESA, glWindowPos2dvMESA, NULL, _gloffset_WindowPos2dvMESA),
-    NAME_FUNC_OFFSET(10476, glWindowPos2fMESA, glWindowPos2fMESA, NULL, _gloffset_WindowPos2fMESA),
-    NAME_FUNC_OFFSET(10494, glWindowPos2fvMESA, glWindowPos2fvMESA, NULL, _gloffset_WindowPos2fvMESA),
-    NAME_FUNC_OFFSET(10513, glWindowPos2iMESA, glWindowPos2iMESA, NULL, _gloffset_WindowPos2iMESA),
-    NAME_FUNC_OFFSET(10531, glWindowPos2ivMESA, glWindowPos2ivMESA, NULL, _gloffset_WindowPos2ivMESA),
-    NAME_FUNC_OFFSET(10550, glWindowPos2sMESA, glWindowPos2sMESA, NULL, _gloffset_WindowPos2sMESA),
-    NAME_FUNC_OFFSET(10568, glWindowPos2svMESA, glWindowPos2svMESA, NULL, _gloffset_WindowPos2svMESA),
-    NAME_FUNC_OFFSET(10587, glWindowPos3dMESA, glWindowPos3dMESA, NULL, _gloffset_WindowPos3dMESA),
-    NAME_FUNC_OFFSET(10605, glWindowPos3dvMESA, glWindowPos3dvMESA, NULL, _gloffset_WindowPos3dvMESA),
-    NAME_FUNC_OFFSET(10624, glWindowPos3fMESA, glWindowPos3fMESA, NULL, _gloffset_WindowPos3fMESA),
-    NAME_FUNC_OFFSET(10642, glWindowPos3fvMESA, glWindowPos3fvMESA, NULL, _gloffset_WindowPos3fvMESA),
-    NAME_FUNC_OFFSET(10661, glWindowPos3iMESA, glWindowPos3iMESA, NULL, _gloffset_WindowPos3iMESA),
-    NAME_FUNC_OFFSET(10679, glWindowPos3ivMESA, glWindowPos3ivMESA, NULL, _gloffset_WindowPos3ivMESA),
-    NAME_FUNC_OFFSET(10698, glWindowPos3sMESA, glWindowPos3sMESA, NULL, _gloffset_WindowPos3sMESA),
-    NAME_FUNC_OFFSET(10716, glWindowPos3svMESA, glWindowPos3svMESA, NULL, _gloffset_WindowPos3svMESA),
-    NAME_FUNC_OFFSET(10735, glWindowPos4dMESA, glWindowPos4dMESA, NULL, _gloffset_WindowPos4dMESA),
-    NAME_FUNC_OFFSET(10753, glWindowPos4dvMESA, glWindowPos4dvMESA, NULL, _gloffset_WindowPos4dvMESA),
-    NAME_FUNC_OFFSET(10772, glWindowPos4fMESA, glWindowPos4fMESA, NULL, _gloffset_WindowPos4fMESA),
-    NAME_FUNC_OFFSET(10790, glWindowPos4fvMESA, glWindowPos4fvMESA, NULL, _gloffset_WindowPos4fvMESA),
-    NAME_FUNC_OFFSET(10809, glWindowPos4iMESA, glWindowPos4iMESA, NULL, _gloffset_WindowPos4iMESA),
-    NAME_FUNC_OFFSET(10827, glWindowPos4ivMESA, glWindowPos4ivMESA, NULL, _gloffset_WindowPos4ivMESA),
-    NAME_FUNC_OFFSET(10846, glWindowPos4sMESA, glWindowPos4sMESA, NULL, _gloffset_WindowPos4sMESA),
-    NAME_FUNC_OFFSET(10864, glWindowPos4svMESA, glWindowPos4svMESA, NULL, _gloffset_WindowPos4svMESA),
-    NAME_FUNC_OFFSET(10883, gl_dispatch_stub_649, gl_dispatch_stub_649, NULL, _gloffset_MultiModeDrawArraysIBM),
-    NAME_FUNC_OFFSET(10908, gl_dispatch_stub_650, gl_dispatch_stub_650, NULL, _gloffset_MultiModeDrawElementsIBM),
-    NAME_FUNC_OFFSET(10935, gl_dispatch_stub_651, gl_dispatch_stub_651, NULL, _gloffset_DeleteFencesNV),
-    NAME_FUNC_OFFSET(10952, gl_dispatch_stub_652, gl_dispatch_stub_652, NULL, _gloffset_FinishFenceNV),
-    NAME_FUNC_OFFSET(10968, gl_dispatch_stub_653, gl_dispatch_stub_653, NULL, _gloffset_GenFencesNV),
-    NAME_FUNC_OFFSET(10982, gl_dispatch_stub_654, gl_dispatch_stub_654, NULL, _gloffset_GetFenceivNV),
-    NAME_FUNC_OFFSET(10997, gl_dispatch_stub_655, gl_dispatch_stub_655, NULL, _gloffset_IsFenceNV),
-    NAME_FUNC_OFFSET(11009, gl_dispatch_stub_656, gl_dispatch_stub_656, NULL, _gloffset_SetFenceNV),
-    NAME_FUNC_OFFSET(11022, gl_dispatch_stub_657, gl_dispatch_stub_657, NULL, _gloffset_TestFenceNV),
-    NAME_FUNC_OFFSET(11036, glAreProgramsResidentNV, glAreProgramsResidentNV, NULL, _gloffset_AreProgramsResidentNV),
-    NAME_FUNC_OFFSET(11060, glBindProgramNV, glBindProgramNV, NULL, _gloffset_BindProgramNV),
-    NAME_FUNC_OFFSET(11076, glDeleteProgramsNV, glDeleteProgramsNV, NULL, _gloffset_DeleteProgramsNV),
-    NAME_FUNC_OFFSET(11095, glExecuteProgramNV, glExecuteProgramNV, NULL, _gloffset_ExecuteProgramNV),
-    NAME_FUNC_OFFSET(11114, glGenProgramsNV, glGenProgramsNV, NULL, _gloffset_GenProgramsNV),
-    NAME_FUNC_OFFSET(11130, glGetProgramParameterdvNV, glGetProgramParameterdvNV, NULL, _gloffset_GetProgramParameterdvNV),
-    NAME_FUNC_OFFSET(11156, glGetProgramParameterfvNV, glGetProgramParameterfvNV, NULL, _gloffset_GetProgramParameterfvNV),
-    NAME_FUNC_OFFSET(11182, glGetProgramStringNV, glGetProgramStringNV, NULL, _gloffset_GetProgramStringNV),
-    NAME_FUNC_OFFSET(11203, glGetProgramivNV, glGetProgramivNV, NULL, _gloffset_GetProgramivNV),
-    NAME_FUNC_OFFSET(11220, glGetTrackMatrixivNV, glGetTrackMatrixivNV, NULL, _gloffset_GetTrackMatrixivNV),
-    NAME_FUNC_OFFSET(11241, glGetVertexAttribPointervNV, glGetVertexAttribPointervNV, NULL, _gloffset_GetVertexAttribPointervNV),
-    NAME_FUNC_OFFSET(11269, glGetVertexAttribdvNV, glGetVertexAttribdvNV, NULL, _gloffset_GetVertexAttribdvNV),
-    NAME_FUNC_OFFSET(11291, glGetVertexAttribfvNV, glGetVertexAttribfvNV, NULL, _gloffset_GetVertexAttribfvNV),
-    NAME_FUNC_OFFSET(11313, glGetVertexAttribivNV, glGetVertexAttribivNV, NULL, _gloffset_GetVertexAttribivNV),
-    NAME_FUNC_OFFSET(11335, glIsProgramNV, glIsProgramNV, NULL, _gloffset_IsProgramNV),
-    NAME_FUNC_OFFSET(11349, glLoadProgramNV, glLoadProgramNV, NULL, _gloffset_LoadProgramNV),
-    NAME_FUNC_OFFSET(11365, glProgramParameters4dvNV, glProgramParameters4dvNV, NULL, _gloffset_ProgramParameters4dvNV),
-    NAME_FUNC_OFFSET(11390, glProgramParameters4fvNV, glProgramParameters4fvNV, NULL, _gloffset_ProgramParameters4fvNV),
-    NAME_FUNC_OFFSET(11415, glRequestResidentProgramsNV, glRequestResidentProgramsNV, NULL, _gloffset_RequestResidentProgramsNV),
-    NAME_FUNC_OFFSET(11443, glTrackMatrixNV, glTrackMatrixNV, NULL, _gloffset_TrackMatrixNV),
-    NAME_FUNC_OFFSET(11459, glVertexAttrib1dNV, glVertexAttrib1dNV, NULL, _gloffset_VertexAttrib1dNV),
-    NAME_FUNC_OFFSET(11478, glVertexAttrib1dvNV, glVertexAttrib1dvNV, NULL, _gloffset_VertexAttrib1dvNV),
-    NAME_FUNC_OFFSET(11498, glVertexAttrib1fNV, glVertexAttrib1fNV, NULL, _gloffset_VertexAttrib1fNV),
-    NAME_FUNC_OFFSET(11517, glVertexAttrib1fvNV, glVertexAttrib1fvNV, NULL, _gloffset_VertexAttrib1fvNV),
-    NAME_FUNC_OFFSET(11537, glVertexAttrib1sNV, glVertexAttrib1sNV, NULL, _gloffset_VertexAttrib1sNV),
-    NAME_FUNC_OFFSET(11556, glVertexAttrib1svNV, glVertexAttrib1svNV, NULL, _gloffset_VertexAttrib1svNV),
-    NAME_FUNC_OFFSET(11576, glVertexAttrib2dNV, glVertexAttrib2dNV, NULL, _gloffset_VertexAttrib2dNV),
-    NAME_FUNC_OFFSET(11595, glVertexAttrib2dvNV, glVertexAttrib2dvNV, NULL, _gloffset_VertexAttrib2dvNV),
-    NAME_FUNC_OFFSET(11615, glVertexAttrib2fNV, glVertexAttrib2fNV, NULL, _gloffset_VertexAttrib2fNV),
-    NAME_FUNC_OFFSET(11634, glVertexAttrib2fvNV, glVertexAttrib2fvNV, NULL, _gloffset_VertexAttrib2fvNV),
-    NAME_FUNC_OFFSET(11654, glVertexAttrib2sNV, glVertexAttrib2sNV, NULL, _gloffset_VertexAttrib2sNV),
-    NAME_FUNC_OFFSET(11673, glVertexAttrib2svNV, glVertexAttrib2svNV, NULL, _gloffset_VertexAttrib2svNV),
-    NAME_FUNC_OFFSET(11693, glVertexAttrib3dNV, glVertexAttrib3dNV, NULL, _gloffset_VertexAttrib3dNV),
-    NAME_FUNC_OFFSET(11712, glVertexAttrib3dvNV, glVertexAttrib3dvNV, NULL, _gloffset_VertexAttrib3dvNV),
-    NAME_FUNC_OFFSET(11732, glVertexAttrib3fNV, glVertexAttrib3fNV, NULL, _gloffset_VertexAttrib3fNV),
-    NAME_FUNC_OFFSET(11751, glVertexAttrib3fvNV, glVertexAttrib3fvNV, NULL, _gloffset_VertexAttrib3fvNV),
-    NAME_FUNC_OFFSET(11771, glVertexAttrib3sNV, glVertexAttrib3sNV, NULL, _gloffset_VertexAttrib3sNV),
-    NAME_FUNC_OFFSET(11790, glVertexAttrib3svNV, glVertexAttrib3svNV, NULL, _gloffset_VertexAttrib3svNV),
-    NAME_FUNC_OFFSET(11810, glVertexAttrib4dNV, glVertexAttrib4dNV, NULL, _gloffset_VertexAttrib4dNV),
-    NAME_FUNC_OFFSET(11829, glVertexAttrib4dvNV, glVertexAttrib4dvNV, NULL, _gloffset_VertexAttrib4dvNV),
-    NAME_FUNC_OFFSET(11849, glVertexAttrib4fNV, glVertexAttrib4fNV, NULL, _gloffset_VertexAttrib4fNV),
-    NAME_FUNC_OFFSET(11868, glVertexAttrib4fvNV, glVertexAttrib4fvNV, NULL, _gloffset_VertexAttrib4fvNV),
-    NAME_FUNC_OFFSET(11888, glVertexAttrib4sNV, glVertexAttrib4sNV, NULL, _gloffset_VertexAttrib4sNV),
-    NAME_FUNC_OFFSET(11907, glVertexAttrib4svNV, glVertexAttrib4svNV, NULL, _gloffset_VertexAttrib4svNV),
-    NAME_FUNC_OFFSET(11927, glVertexAttrib4ubNV, glVertexAttrib4ubNV, NULL, _gloffset_VertexAttrib4ubNV),
-    NAME_FUNC_OFFSET(11947, glVertexAttrib4ubvNV, glVertexAttrib4ubvNV, NULL, _gloffset_VertexAttrib4ubvNV),
-    NAME_FUNC_OFFSET(11968, glVertexAttribPointerNV, glVertexAttribPointerNV, NULL, _gloffset_VertexAttribPointerNV),
-    NAME_FUNC_OFFSET(11992, glVertexAttribs1dvNV, glVertexAttribs1dvNV, NULL, _gloffset_VertexAttribs1dvNV),
-    NAME_FUNC_OFFSET(12013, glVertexAttribs1fvNV, glVertexAttribs1fvNV, NULL, _gloffset_VertexAttribs1fvNV),
-    NAME_FUNC_OFFSET(12034, glVertexAttribs1svNV, glVertexAttribs1svNV, NULL, _gloffset_VertexAttribs1svNV),
-    NAME_FUNC_OFFSET(12055, glVertexAttribs2dvNV, glVertexAttribs2dvNV, NULL, _gloffset_VertexAttribs2dvNV),
-    NAME_FUNC_OFFSET(12076, glVertexAttribs2fvNV, glVertexAttribs2fvNV, NULL, _gloffset_VertexAttribs2fvNV),
-    NAME_FUNC_OFFSET(12097, glVertexAttribs2svNV, glVertexAttribs2svNV, NULL, _gloffset_VertexAttribs2svNV),
-    NAME_FUNC_OFFSET(12118, glVertexAttribs3dvNV, glVertexAttribs3dvNV, NULL, _gloffset_VertexAttribs3dvNV),
-    NAME_FUNC_OFFSET(12139, glVertexAttribs3fvNV, glVertexAttribs3fvNV, NULL, _gloffset_VertexAttribs3fvNV),
-    NAME_FUNC_OFFSET(12160, glVertexAttribs3svNV, glVertexAttribs3svNV, NULL, _gloffset_VertexAttribs3svNV),
-    NAME_FUNC_OFFSET(12181, glVertexAttribs4dvNV, glVertexAttribs4dvNV, NULL, _gloffset_VertexAttribs4dvNV),
-    NAME_FUNC_OFFSET(12202, glVertexAttribs4fvNV, glVertexAttribs4fvNV, NULL, _gloffset_VertexAttribs4fvNV),
-    NAME_FUNC_OFFSET(12223, glVertexAttribs4svNV, glVertexAttribs4svNV, NULL, _gloffset_VertexAttribs4svNV),
-    NAME_FUNC_OFFSET(12244, glVertexAttribs4ubvNV, glVertexAttribs4ubvNV, NULL, _gloffset_VertexAttribs4ubvNV),
-    NAME_FUNC_OFFSET(12266, glGetTexBumpParameterfvATI, glGetTexBumpParameterfvATI, NULL, _gloffset_GetTexBumpParameterfvATI),
-    NAME_FUNC_OFFSET(12293, glGetTexBumpParameterivATI, glGetTexBumpParameterivATI, NULL, _gloffset_GetTexBumpParameterivATI),
-    NAME_FUNC_OFFSET(12320, glTexBumpParameterfvATI, glTexBumpParameterfvATI, NULL, _gloffset_TexBumpParameterfvATI),
-    NAME_FUNC_OFFSET(12344, glTexBumpParameterivATI, glTexBumpParameterivATI, NULL, _gloffset_TexBumpParameterivATI),
-    NAME_FUNC_OFFSET(12368, glAlphaFragmentOp1ATI, glAlphaFragmentOp1ATI, NULL, _gloffset_AlphaFragmentOp1ATI),
-    NAME_FUNC_OFFSET(12390, glAlphaFragmentOp2ATI, glAlphaFragmentOp2ATI, NULL, _gloffset_AlphaFragmentOp2ATI),
-    NAME_FUNC_OFFSET(12412, glAlphaFragmentOp3ATI, glAlphaFragmentOp3ATI, NULL, _gloffset_AlphaFragmentOp3ATI),
-    NAME_FUNC_OFFSET(12434, glBeginFragmentShaderATI, glBeginFragmentShaderATI, NULL, _gloffset_BeginFragmentShaderATI),
-    NAME_FUNC_OFFSET(12459, glBindFragmentShaderATI, glBindFragmentShaderATI, NULL, _gloffset_BindFragmentShaderATI),
-    NAME_FUNC_OFFSET(12483, glColorFragmentOp1ATI, glColorFragmentOp1ATI, NULL, _gloffset_ColorFragmentOp1ATI),
-    NAME_FUNC_OFFSET(12505, glColorFragmentOp2ATI, glColorFragmentOp2ATI, NULL, _gloffset_ColorFragmentOp2ATI),
-    NAME_FUNC_OFFSET(12527, glColorFragmentOp3ATI, glColorFragmentOp3ATI, NULL, _gloffset_ColorFragmentOp3ATI),
-    NAME_FUNC_OFFSET(12549, glDeleteFragmentShaderATI, glDeleteFragmentShaderATI, NULL, _gloffset_DeleteFragmentShaderATI),
-    NAME_FUNC_OFFSET(12575, glEndFragmentShaderATI, glEndFragmentShaderATI, NULL, _gloffset_EndFragmentShaderATI),
-    NAME_FUNC_OFFSET(12598, glGenFragmentShadersATI, glGenFragmentShadersATI, NULL, _gloffset_GenFragmentShadersATI),
-    NAME_FUNC_OFFSET(12622, glPassTexCoordATI, glPassTexCoordATI, NULL, _gloffset_PassTexCoordATI),
-    NAME_FUNC_OFFSET(12640, glSampleMapATI, glSampleMapATI, NULL, _gloffset_SampleMapATI),
-    NAME_FUNC_OFFSET(12655, glSetFragmentShaderConstantATI, glSetFragmentShaderConstantATI, NULL, _gloffset_SetFragmentShaderConstantATI),
-    NAME_FUNC_OFFSET(12686, glPointParameteriNV, glPointParameteriNV, NULL, _gloffset_PointParameteriNV),
-    NAME_FUNC_OFFSET(12706, glPointParameterivNV, glPointParameterivNV, NULL, _gloffset_PointParameterivNV),
-    NAME_FUNC_OFFSET(12727, gl_dispatch_stub_738, gl_dispatch_stub_738, NULL, _gloffset_ActiveStencilFaceEXT),
-    NAME_FUNC_OFFSET(12750, gl_dispatch_stub_739, gl_dispatch_stub_739, NULL, _gloffset_BindVertexArrayAPPLE),
-    NAME_FUNC_OFFSET(12773, gl_dispatch_stub_740, gl_dispatch_stub_740, NULL, _gloffset_DeleteVertexArraysAPPLE),
-    NAME_FUNC_OFFSET(12799, gl_dispatch_stub_741, gl_dispatch_stub_741, NULL, _gloffset_GenVertexArraysAPPLE),
-    NAME_FUNC_OFFSET(12822, gl_dispatch_stub_742, gl_dispatch_stub_742, NULL, _gloffset_IsVertexArrayAPPLE),
-    NAME_FUNC_OFFSET(12843, glGetProgramNamedParameterdvNV, glGetProgramNamedParameterdvNV, NULL, _gloffset_GetProgramNamedParameterdvNV),
-    NAME_FUNC_OFFSET(12874, glGetProgramNamedParameterfvNV, glGetProgramNamedParameterfvNV, NULL, _gloffset_GetProgramNamedParameterfvNV),
-    NAME_FUNC_OFFSET(12905, glProgramNamedParameter4dNV, glProgramNamedParameter4dNV, NULL, _gloffset_ProgramNamedParameter4dNV),
-    NAME_FUNC_OFFSET(12933, glProgramNamedParameter4dvNV, glProgramNamedParameter4dvNV, NULL, _gloffset_ProgramNamedParameter4dvNV),
-    NAME_FUNC_OFFSET(12962, glProgramNamedParameter4fNV, glProgramNamedParameter4fNV, NULL, _gloffset_ProgramNamedParameter4fNV),
-    NAME_FUNC_OFFSET(12990, glProgramNamedParameter4fvNV, glProgramNamedParameter4fvNV, NULL, _gloffset_ProgramNamedParameter4fvNV),
-    NAME_FUNC_OFFSET(13019, gl_dispatch_stub_749, gl_dispatch_stub_749, NULL, _gloffset_DepthBoundsEXT),
-    NAME_FUNC_OFFSET(13036, gl_dispatch_stub_750, gl_dispatch_stub_750, NULL, _gloffset_BlendEquationSeparateEXT),
-    NAME_FUNC_OFFSET(13063, glBindFramebufferEXT, glBindFramebufferEXT, NULL, _gloffset_BindFramebufferEXT),
-    NAME_FUNC_OFFSET(13084, glBindRenderbufferEXT, glBindRenderbufferEXT, NULL, _gloffset_BindRenderbufferEXT),
-    NAME_FUNC_OFFSET(13106, glCheckFramebufferStatusEXT, glCheckFramebufferStatusEXT, NULL, _gloffset_CheckFramebufferStatusEXT),
-    NAME_FUNC_OFFSET(13134, glDeleteFramebuffersEXT, glDeleteFramebuffersEXT, NULL, _gloffset_DeleteFramebuffersEXT),
-    NAME_FUNC_OFFSET(13158, glDeleteRenderbuffersEXT, glDeleteRenderbuffersEXT, NULL, _gloffset_DeleteRenderbuffersEXT),
-    NAME_FUNC_OFFSET(13183, glFramebufferRenderbufferEXT, glFramebufferRenderbufferEXT, NULL, _gloffset_FramebufferRenderbufferEXT),
-    NAME_FUNC_OFFSET(13212, glFramebufferTexture1DEXT, glFramebufferTexture1DEXT, NULL, _gloffset_FramebufferTexture1DEXT),
-    NAME_FUNC_OFFSET(13238, glFramebufferTexture2DEXT, glFramebufferTexture2DEXT, NULL, _gloffset_FramebufferTexture2DEXT),
-    NAME_FUNC_OFFSET(13264, glFramebufferTexture3DEXT, glFramebufferTexture3DEXT, NULL, _gloffset_FramebufferTexture3DEXT),
-    NAME_FUNC_OFFSET(13290, glGenFramebuffersEXT, glGenFramebuffersEXT, NULL, _gloffset_GenFramebuffersEXT),
-    NAME_FUNC_OFFSET(13311, glGenRenderbuffersEXT, glGenRenderbuffersEXT, NULL, _gloffset_GenRenderbuffersEXT),
-    NAME_FUNC_OFFSET(13333, glGenerateMipmapEXT, glGenerateMipmapEXT, NULL, _gloffset_GenerateMipmapEXT),
-    NAME_FUNC_OFFSET(13353, glGetFramebufferAttachmentParameterivEXT, glGetFramebufferAttachmentParameterivEXT, NULL, _gloffset_GetFramebufferAttachmentParameterivEXT),
-    NAME_FUNC_OFFSET(13394, glGetRenderbufferParameterivEXT, glGetRenderbufferParameterivEXT, NULL, _gloffset_GetRenderbufferParameterivEXT),
-    NAME_FUNC_OFFSET(13426, glIsFramebufferEXT, glIsFramebufferEXT, NULL, _gloffset_IsFramebufferEXT),
-    NAME_FUNC_OFFSET(13445, glIsRenderbufferEXT, glIsRenderbufferEXT, NULL, _gloffset_IsRenderbufferEXT),
-    NAME_FUNC_OFFSET(13465, glRenderbufferStorageEXT, glRenderbufferStorageEXT, NULL, _gloffset_RenderbufferStorageEXT),
-    NAME_FUNC_OFFSET(13490, gl_dispatch_stub_768, gl_dispatch_stub_768, NULL, _gloffset_BlitFramebufferEXT),
-    NAME_FUNC_OFFSET(13511, glFramebufferTextureLayerEXT, glFramebufferTextureLayerEXT, NULL, _gloffset_FramebufferTextureLayerEXT),
-    NAME_FUNC_OFFSET(13540, gl_dispatch_stub_770, gl_dispatch_stub_770, NULL, _gloffset_StencilFuncSeparateATI),
-    NAME_FUNC_OFFSET(13565, gl_dispatch_stub_771, gl_dispatch_stub_771, NULL, _gloffset_ProgramEnvParameters4fvEXT),
-    NAME_FUNC_OFFSET(13594, gl_dispatch_stub_772, gl_dispatch_stub_772, NULL, _gloffset_ProgramLocalParameters4fvEXT),
-    NAME_FUNC_OFFSET(13625, gl_dispatch_stub_773, gl_dispatch_stub_773, NULL, _gloffset_GetQueryObjecti64vEXT),
-    NAME_FUNC_OFFSET(13649, gl_dispatch_stub_774, gl_dispatch_stub_774, NULL, _gloffset_GetQueryObjectui64vEXT),
-    NAME_FUNC_OFFSET(13674, glArrayElement, glArrayElement, NULL, _gloffset_ArrayElement),
-    NAME_FUNC_OFFSET(13692, glBindTexture, glBindTexture, NULL, _gloffset_BindTexture),
-    NAME_FUNC_OFFSET(13709, glDrawArrays, glDrawArrays, NULL, _gloffset_DrawArrays),
-    NAME_FUNC_OFFSET(13725, glAreTexturesResident, glAreTexturesResidentEXT, glAreTexturesResidentEXT, _gloffset_AreTexturesResident),
-    NAME_FUNC_OFFSET(13750, glCopyTexImage1D, glCopyTexImage1D, NULL, _gloffset_CopyTexImage1D),
-    NAME_FUNC_OFFSET(13770, glCopyTexImage2D, glCopyTexImage2D, NULL, _gloffset_CopyTexImage2D),
-    NAME_FUNC_OFFSET(13790, glCopyTexSubImage1D, glCopyTexSubImage1D, NULL, _gloffset_CopyTexSubImage1D),
-    NAME_FUNC_OFFSET(13813, glCopyTexSubImage2D, glCopyTexSubImage2D, NULL, _gloffset_CopyTexSubImage2D),
-    NAME_FUNC_OFFSET(13836, glDeleteTextures, glDeleteTexturesEXT, glDeleteTexturesEXT, _gloffset_DeleteTextures),
-    NAME_FUNC_OFFSET(13856, glGenTextures, glGenTexturesEXT, glGenTexturesEXT, _gloffset_GenTextures),
-    NAME_FUNC_OFFSET(13873, glGetPointerv, glGetPointerv, NULL, _gloffset_GetPointerv),
-    NAME_FUNC_OFFSET(13890, glIsTexture, glIsTextureEXT, glIsTextureEXT, _gloffset_IsTexture),
-    NAME_FUNC_OFFSET(13905, glPrioritizeTextures, glPrioritizeTextures, NULL, _gloffset_PrioritizeTextures),
-    NAME_FUNC_OFFSET(13929, glTexSubImage1D, glTexSubImage1D, NULL, _gloffset_TexSubImage1D),
-    NAME_FUNC_OFFSET(13948, glTexSubImage2D, glTexSubImage2D, NULL, _gloffset_TexSubImage2D),
-    NAME_FUNC_OFFSET(13967, glBlendColor, glBlendColor, NULL, _gloffset_BlendColor),
-    NAME_FUNC_OFFSET(13983, glBlendEquation, glBlendEquation, NULL, _gloffset_BlendEquation),
-    NAME_FUNC_OFFSET(14002, glDrawRangeElements, glDrawRangeElements, NULL, _gloffset_DrawRangeElements),
-    NAME_FUNC_OFFSET(14025, glColorTable, glColorTable, NULL, _gloffset_ColorTable),
-    NAME_FUNC_OFFSET(14041, glColorTable, glColorTable, NULL, _gloffset_ColorTable),
-    NAME_FUNC_OFFSET(14057, glColorTableParameterfv, glColorTableParameterfv, NULL, _gloffset_ColorTableParameterfv),
-    NAME_FUNC_OFFSET(14084, glColorTableParameteriv, glColorTableParameteriv, NULL, _gloffset_ColorTableParameteriv),
-    NAME_FUNC_OFFSET(14111, glCopyColorTable, glCopyColorTable, NULL, _gloffset_CopyColorTable),
-    NAME_FUNC_OFFSET(14131, glGetColorTable, glGetColorTableEXT, glGetColorTableEXT, _gloffset_GetColorTable),
-    NAME_FUNC_OFFSET(14150, glGetColorTable, glGetColorTableEXT, glGetColorTableEXT, _gloffset_GetColorTable),
-    NAME_FUNC_OFFSET(14169, glGetColorTableParameterfv, glGetColorTableParameterfvEXT, glGetColorTableParameterfvEXT, _gloffset_GetColorTableParameterfv),
-    NAME_FUNC_OFFSET(14199, glGetColorTableParameterfv, glGetColorTableParameterfvEXT, glGetColorTableParameterfvEXT, _gloffset_GetColorTableParameterfv),
-    NAME_FUNC_OFFSET(14229, glGetColorTableParameteriv, glGetColorTableParameterivEXT, glGetColorTableParameterivEXT, _gloffset_GetColorTableParameteriv),
-    NAME_FUNC_OFFSET(14259, glGetColorTableParameteriv, glGetColorTableParameterivEXT, glGetColorTableParameterivEXT, _gloffset_GetColorTableParameteriv),
-    NAME_FUNC_OFFSET(14289, glColorSubTable, glColorSubTable, NULL, _gloffset_ColorSubTable),
-    NAME_FUNC_OFFSET(14308, glCopyColorSubTable, glCopyColorSubTable, NULL, _gloffset_CopyColorSubTable),
-    NAME_FUNC_OFFSET(14331, glConvolutionFilter1D, glConvolutionFilter1D, NULL, _gloffset_ConvolutionFilter1D),
-    NAME_FUNC_OFFSET(14356, glConvolutionFilter2D, glConvolutionFilter2D, NULL, _gloffset_ConvolutionFilter2D),
-    NAME_FUNC_OFFSET(14381, glConvolutionParameterf, glConvolutionParameterf, NULL, _gloffset_ConvolutionParameterf),
-    NAME_FUNC_OFFSET(14408, glConvolutionParameterfv, glConvolutionParameterfv, NULL, _gloffset_ConvolutionParameterfv),
-    NAME_FUNC_OFFSET(14436, glConvolutionParameteri, glConvolutionParameteri, NULL, _gloffset_ConvolutionParameteri),
-    NAME_FUNC_OFFSET(14463, glConvolutionParameteriv, glConvolutionParameteriv, NULL, _gloffset_ConvolutionParameteriv),
-    NAME_FUNC_OFFSET(14491, glCopyConvolutionFilter1D, glCopyConvolutionFilter1D, NULL, _gloffset_CopyConvolutionFilter1D),
-    NAME_FUNC_OFFSET(14520, glCopyConvolutionFilter2D, glCopyConvolutionFilter2D, NULL, _gloffset_CopyConvolutionFilter2D),
-    NAME_FUNC_OFFSET(14549, glGetConvolutionFilter, gl_dispatch_stub_356, gl_dispatch_stub_356, _gloffset_GetConvolutionFilter),
-    NAME_FUNC_OFFSET(14575, glGetConvolutionParameterfv, gl_dispatch_stub_357, gl_dispatch_stub_357, _gloffset_GetConvolutionParameterfv),
-    NAME_FUNC_OFFSET(14606, glGetConvolutionParameteriv, gl_dispatch_stub_358, gl_dispatch_stub_358, _gloffset_GetConvolutionParameteriv),
-    NAME_FUNC_OFFSET(14637, glGetSeparableFilter, gl_dispatch_stub_359, gl_dispatch_stub_359, _gloffset_GetSeparableFilter),
-    NAME_FUNC_OFFSET(14661, glSeparableFilter2D, glSeparableFilter2D, NULL, _gloffset_SeparableFilter2D),
-    NAME_FUNC_OFFSET(14684, glGetHistogram, gl_dispatch_stub_361, gl_dispatch_stub_361, _gloffset_GetHistogram),
-    NAME_FUNC_OFFSET(14702, glGetHistogramParameterfv, gl_dispatch_stub_362, gl_dispatch_stub_362, _gloffset_GetHistogramParameterfv),
-    NAME_FUNC_OFFSET(14731, glGetHistogramParameteriv, gl_dispatch_stub_363, gl_dispatch_stub_363, _gloffset_GetHistogramParameteriv),
-    NAME_FUNC_OFFSET(14760, glGetMinmax, gl_dispatch_stub_364, gl_dispatch_stub_364, _gloffset_GetMinmax),
-    NAME_FUNC_OFFSET(14775, glGetMinmaxParameterfv, gl_dispatch_stub_365, gl_dispatch_stub_365, _gloffset_GetMinmaxParameterfv),
-    NAME_FUNC_OFFSET(14801, glGetMinmaxParameteriv, gl_dispatch_stub_366, gl_dispatch_stub_366, _gloffset_GetMinmaxParameteriv),
-    NAME_FUNC_OFFSET(14827, glHistogram, glHistogram, NULL, _gloffset_Histogram),
-    NAME_FUNC_OFFSET(14842, glMinmax, glMinmax, NULL, _gloffset_Minmax),
-    NAME_FUNC_OFFSET(14854, glResetHistogram, glResetHistogram, NULL, _gloffset_ResetHistogram),
-    NAME_FUNC_OFFSET(14874, glResetMinmax, glResetMinmax, NULL, _gloffset_ResetMinmax),
-    NAME_FUNC_OFFSET(14891, glTexImage3D, glTexImage3D, NULL, _gloffset_TexImage3D),
-    NAME_FUNC_OFFSET(14907, glTexSubImage3D, glTexSubImage3D, NULL, _gloffset_TexSubImage3D),
-    NAME_FUNC_OFFSET(14926, glCopyTexSubImage3D, glCopyTexSubImage3D, NULL, _gloffset_CopyTexSubImage3D),
-    NAME_FUNC_OFFSET(14949, glActiveTextureARB, glActiveTextureARB, NULL, _gloffset_ActiveTextureARB),
-    NAME_FUNC_OFFSET(14965, glClientActiveTextureARB, glClientActiveTextureARB, NULL, _gloffset_ClientActiveTextureARB),
-    NAME_FUNC_OFFSET(14987, glMultiTexCoord1dARB, glMultiTexCoord1dARB, NULL, _gloffset_MultiTexCoord1dARB),
-    NAME_FUNC_OFFSET(15005, glMultiTexCoord1dvARB, glMultiTexCoord1dvARB, NULL, _gloffset_MultiTexCoord1dvARB),
-    NAME_FUNC_OFFSET(15024, glMultiTexCoord1fARB, glMultiTexCoord1fARB, NULL, _gloffset_MultiTexCoord1fARB),
-    NAME_FUNC_OFFSET(15042, glMultiTexCoord1fvARB, glMultiTexCoord1fvARB, NULL, _gloffset_MultiTexCoord1fvARB),
-    NAME_FUNC_OFFSET(15061, glMultiTexCoord1iARB, glMultiTexCoord1iARB, NULL, _gloffset_MultiTexCoord1iARB),
-    NAME_FUNC_OFFSET(15079, glMultiTexCoord1ivARB, glMultiTexCoord1ivARB, NULL, _gloffset_MultiTexCoord1ivARB),
-    NAME_FUNC_OFFSET(15098, glMultiTexCoord1sARB, glMultiTexCoord1sARB, NULL, _gloffset_MultiTexCoord1sARB),
-    NAME_FUNC_OFFSET(15116, glMultiTexCoord1svARB, glMultiTexCoord1svARB, NULL, _gloffset_MultiTexCoord1svARB),
-    NAME_FUNC_OFFSET(15135, glMultiTexCoord2dARB, glMultiTexCoord2dARB, NULL, _gloffset_MultiTexCoord2dARB),
-    NAME_FUNC_OFFSET(15153, glMultiTexCoord2dvARB, glMultiTexCoord2dvARB, NULL, _gloffset_MultiTexCoord2dvARB),
-    NAME_FUNC_OFFSET(15172, glMultiTexCoord2fARB, glMultiTexCoord2fARB, NULL, _gloffset_MultiTexCoord2fARB),
-    NAME_FUNC_OFFSET(15190, glMultiTexCoord2fvARB, glMultiTexCoord2fvARB, NULL, _gloffset_MultiTexCoord2fvARB),
-    NAME_FUNC_OFFSET(15209, glMultiTexCoord2iARB, glMultiTexCoord2iARB, NULL, _gloffset_MultiTexCoord2iARB),
-    NAME_FUNC_OFFSET(15227, glMultiTexCoord2ivARB, glMultiTexCoord2ivARB, NULL, _gloffset_MultiTexCoord2ivARB),
-    NAME_FUNC_OFFSET(15246, glMultiTexCoord2sARB, glMultiTexCoord2sARB, NULL, _gloffset_MultiTexCoord2sARB),
-    NAME_FUNC_OFFSET(15264, glMultiTexCoord2svARB, glMultiTexCoord2svARB, NULL, _gloffset_MultiTexCoord2svARB),
-    NAME_FUNC_OFFSET(15283, glMultiTexCoord3dARB, glMultiTexCoord3dARB, NULL, _gloffset_MultiTexCoord3dARB),
-    NAME_FUNC_OFFSET(15301, glMultiTexCoord3dvARB, glMultiTexCoord3dvARB, NULL, _gloffset_MultiTexCoord3dvARB),
-    NAME_FUNC_OFFSET(15320, glMultiTexCoord3fARB, glMultiTexCoord3fARB, NULL, _gloffset_MultiTexCoord3fARB),
-    NAME_FUNC_OFFSET(15338, glMultiTexCoord3fvARB, glMultiTexCoord3fvARB, NULL, _gloffset_MultiTexCoord3fvARB),
-    NAME_FUNC_OFFSET(15357, glMultiTexCoord3iARB, glMultiTexCoord3iARB, NULL, _gloffset_MultiTexCoord3iARB),
-    NAME_FUNC_OFFSET(15375, glMultiTexCoord3ivARB, glMultiTexCoord3ivARB, NULL, _gloffset_MultiTexCoord3ivARB),
-    NAME_FUNC_OFFSET(15394, glMultiTexCoord3sARB, glMultiTexCoord3sARB, NULL, _gloffset_MultiTexCoord3sARB),
-    NAME_FUNC_OFFSET(15412, glMultiTexCoord3svARB, glMultiTexCoord3svARB, NULL, _gloffset_MultiTexCoord3svARB),
-    NAME_FUNC_OFFSET(15431, glMultiTexCoord4dARB, glMultiTexCoord4dARB, NULL, _gloffset_MultiTexCoord4dARB),
-    NAME_FUNC_OFFSET(15449, glMultiTexCoord4dvARB, glMultiTexCoord4dvARB, NULL, _gloffset_MultiTexCoord4dvARB),
-    NAME_FUNC_OFFSET(15468, glMultiTexCoord4fARB, glMultiTexCoord4fARB, NULL, _gloffset_MultiTexCoord4fARB),
-    NAME_FUNC_OFFSET(15486, glMultiTexCoord4fvARB, glMultiTexCoord4fvARB, NULL, _gloffset_MultiTexCoord4fvARB),
-    NAME_FUNC_OFFSET(15505, glMultiTexCoord4iARB, glMultiTexCoord4iARB, NULL, _gloffset_MultiTexCoord4iARB),
-    NAME_FUNC_OFFSET(15523, glMultiTexCoord4ivARB, glMultiTexCoord4ivARB, NULL, _gloffset_MultiTexCoord4ivARB),
-    NAME_FUNC_OFFSET(15542, glMultiTexCoord4sARB, glMultiTexCoord4sARB, NULL, _gloffset_MultiTexCoord4sARB),
-    NAME_FUNC_OFFSET(15560, glMultiTexCoord4svARB, glMultiTexCoord4svARB, NULL, _gloffset_MultiTexCoord4svARB),
-    NAME_FUNC_OFFSET(15579, glStencilOpSeparate, glStencilOpSeparate, NULL, _gloffset_StencilOpSeparate),
-    NAME_FUNC_OFFSET(15602, glLoadTransposeMatrixdARB, glLoadTransposeMatrixdARB, NULL, _gloffset_LoadTransposeMatrixdARB),
-    NAME_FUNC_OFFSET(15625, glLoadTransposeMatrixfARB, glLoadTransposeMatrixfARB, NULL, _gloffset_LoadTransposeMatrixfARB),
-    NAME_FUNC_OFFSET(15648, glMultTransposeMatrixdARB, glMultTransposeMatrixdARB, NULL, _gloffset_MultTransposeMatrixdARB),
-    NAME_FUNC_OFFSET(15671, glMultTransposeMatrixfARB, glMultTransposeMatrixfARB, NULL, _gloffset_MultTransposeMatrixfARB),
-    NAME_FUNC_OFFSET(15694, glSampleCoverageARB, glSampleCoverageARB, NULL, _gloffset_SampleCoverageARB),
-    NAME_FUNC_OFFSET(15711, glCompressedTexImage1DARB, glCompressedTexImage1DARB, NULL, _gloffset_CompressedTexImage1DARB),
-    NAME_FUNC_OFFSET(15734, glCompressedTexImage2DARB, glCompressedTexImage2DARB, NULL, _gloffset_CompressedTexImage2DARB),
-    NAME_FUNC_OFFSET(15757, glCompressedTexImage3DARB, glCompressedTexImage3DARB, NULL, _gloffset_CompressedTexImage3DARB),
-    NAME_FUNC_OFFSET(15780, glCompressedTexSubImage1DARB, glCompressedTexSubImage1DARB, NULL, _gloffset_CompressedTexSubImage1DARB),
-    NAME_FUNC_OFFSET(15806, glCompressedTexSubImage2DARB, glCompressedTexSubImage2DARB, NULL, _gloffset_CompressedTexSubImage2DARB),
-    NAME_FUNC_OFFSET(15832, glCompressedTexSubImage3DARB, glCompressedTexSubImage3DARB, NULL, _gloffset_CompressedTexSubImage3DARB),
-    NAME_FUNC_OFFSET(15858, glGetCompressedTexImageARB, glGetCompressedTexImageARB, NULL, _gloffset_GetCompressedTexImageARB),
-    NAME_FUNC_OFFSET(15882, glDisableVertexAttribArrayARB, glDisableVertexAttribArrayARB, NULL, _gloffset_DisableVertexAttribArrayARB),
-    NAME_FUNC_OFFSET(15909, glEnableVertexAttribArrayARB, glEnableVertexAttribArrayARB, NULL, _gloffset_EnableVertexAttribArrayARB),
-    NAME_FUNC_OFFSET(15935, glGetVertexAttribdvARB, glGetVertexAttribdvARB, NULL, _gloffset_GetVertexAttribdvARB),
-    NAME_FUNC_OFFSET(15955, glGetVertexAttribfvARB, glGetVertexAttribfvARB, NULL, _gloffset_GetVertexAttribfvARB),
-    NAME_FUNC_OFFSET(15975, glGetVertexAttribivARB, glGetVertexAttribivARB, NULL, _gloffset_GetVertexAttribivARB),
-    NAME_FUNC_OFFSET(15995, glProgramEnvParameter4dARB, glProgramEnvParameter4dARB, NULL, _gloffset_ProgramEnvParameter4dARB),
-    NAME_FUNC_OFFSET(16018, glProgramEnvParameter4dvARB, glProgramEnvParameter4dvARB, NULL, _gloffset_ProgramEnvParameter4dvARB),
-    NAME_FUNC_OFFSET(16042, glProgramEnvParameter4fARB, glProgramEnvParameter4fARB, NULL, _gloffset_ProgramEnvParameter4fARB),
-    NAME_FUNC_OFFSET(16065, glProgramEnvParameter4fvARB, glProgramEnvParameter4fvARB, NULL, _gloffset_ProgramEnvParameter4fvARB),
-    NAME_FUNC_OFFSET(16089, glVertexAttrib1dARB, glVertexAttrib1dARB, NULL, _gloffset_VertexAttrib1dARB),
-    NAME_FUNC_OFFSET(16106, glVertexAttrib1dvARB, glVertexAttrib1dvARB, NULL, _gloffset_VertexAttrib1dvARB),
-    NAME_FUNC_OFFSET(16124, glVertexAttrib1fARB, glVertexAttrib1fARB, NULL, _gloffset_VertexAttrib1fARB),
-    NAME_FUNC_OFFSET(16141, glVertexAttrib1fvARB, glVertexAttrib1fvARB, NULL, _gloffset_VertexAttrib1fvARB),
-    NAME_FUNC_OFFSET(16159, glVertexAttrib1sARB, glVertexAttrib1sARB, NULL, _gloffset_VertexAttrib1sARB),
-    NAME_FUNC_OFFSET(16176, glVertexAttrib1svARB, glVertexAttrib1svARB, NULL, _gloffset_VertexAttrib1svARB),
-    NAME_FUNC_OFFSET(16194, glVertexAttrib2dARB, glVertexAttrib2dARB, NULL, _gloffset_VertexAttrib2dARB),
-    NAME_FUNC_OFFSET(16211, glVertexAttrib2dvARB, glVertexAttrib2dvARB, NULL, _gloffset_VertexAttrib2dvARB),
-    NAME_FUNC_OFFSET(16229, glVertexAttrib2fARB, glVertexAttrib2fARB, NULL, _gloffset_VertexAttrib2fARB),
-    NAME_FUNC_OFFSET(16246, glVertexAttrib2fvARB, glVertexAttrib2fvARB, NULL, _gloffset_VertexAttrib2fvARB),
-    NAME_FUNC_OFFSET(16264, glVertexAttrib2sARB, glVertexAttrib2sARB, NULL, _gloffset_VertexAttrib2sARB),
-    NAME_FUNC_OFFSET(16281, glVertexAttrib2svARB, glVertexAttrib2svARB, NULL, _gloffset_VertexAttrib2svARB),
-    NAME_FUNC_OFFSET(16299, glVertexAttrib3dARB, glVertexAttrib3dARB, NULL, _gloffset_VertexAttrib3dARB),
-    NAME_FUNC_OFFSET(16316, glVertexAttrib3dvARB, glVertexAttrib3dvARB, NULL, _gloffset_VertexAttrib3dvARB),
-    NAME_FUNC_OFFSET(16334, glVertexAttrib3fARB, glVertexAttrib3fARB, NULL, _gloffset_VertexAttrib3fARB),
-    NAME_FUNC_OFFSET(16351, glVertexAttrib3fvARB, glVertexAttrib3fvARB, NULL, _gloffset_VertexAttrib3fvARB),
-    NAME_FUNC_OFFSET(16369, glVertexAttrib3sARB, glVertexAttrib3sARB, NULL, _gloffset_VertexAttrib3sARB),
-    NAME_FUNC_OFFSET(16386, glVertexAttrib3svARB, glVertexAttrib3svARB, NULL, _gloffset_VertexAttrib3svARB),
-    NAME_FUNC_OFFSET(16404, glVertexAttrib4NbvARB, glVertexAttrib4NbvARB, NULL, _gloffset_VertexAttrib4NbvARB),
-    NAME_FUNC_OFFSET(16423, glVertexAttrib4NivARB, glVertexAttrib4NivARB, NULL, _gloffset_VertexAttrib4NivARB),
-    NAME_FUNC_OFFSET(16442, glVertexAttrib4NsvARB, glVertexAttrib4NsvARB, NULL, _gloffset_VertexAttrib4NsvARB),
-    NAME_FUNC_OFFSET(16461, glVertexAttrib4NubARB, glVertexAttrib4NubARB, NULL, _gloffset_VertexAttrib4NubARB),
-    NAME_FUNC_OFFSET(16480, glVertexAttrib4NubvARB, glVertexAttrib4NubvARB, NULL, _gloffset_VertexAttrib4NubvARB),
-    NAME_FUNC_OFFSET(16500, glVertexAttrib4NuivARB, glVertexAttrib4NuivARB, NULL, _gloffset_VertexAttrib4NuivARB),
-    NAME_FUNC_OFFSET(16520, glVertexAttrib4NusvARB, glVertexAttrib4NusvARB, NULL, _gloffset_VertexAttrib4NusvARB),
-    NAME_FUNC_OFFSET(16540, glVertexAttrib4bvARB, glVertexAttrib4bvARB, NULL, _gloffset_VertexAttrib4bvARB),
-    NAME_FUNC_OFFSET(16558, glVertexAttrib4dARB, glVertexAttrib4dARB, NULL, _gloffset_VertexAttrib4dARB),
-    NAME_FUNC_OFFSET(16575, glVertexAttrib4dvARB, glVertexAttrib4dvARB, NULL, _gloffset_VertexAttrib4dvARB),
-    NAME_FUNC_OFFSET(16593, glVertexAttrib4fARB, glVertexAttrib4fARB, NULL, _gloffset_VertexAttrib4fARB),
-    NAME_FUNC_OFFSET(16610, glVertexAttrib4fvARB, glVertexAttrib4fvARB, NULL, _gloffset_VertexAttrib4fvARB),
-    NAME_FUNC_OFFSET(16628, glVertexAttrib4ivARB, glVertexAttrib4ivARB, NULL, _gloffset_VertexAttrib4ivARB),
-    NAME_FUNC_OFFSET(16646, glVertexAttrib4sARB, glVertexAttrib4sARB, NULL, _gloffset_VertexAttrib4sARB),
-    NAME_FUNC_OFFSET(16663, glVertexAttrib4svARB, glVertexAttrib4svARB, NULL, _gloffset_VertexAttrib4svARB),
-    NAME_FUNC_OFFSET(16681, glVertexAttrib4ubvARB, glVertexAttrib4ubvARB, NULL, _gloffset_VertexAttrib4ubvARB),
-    NAME_FUNC_OFFSET(16700, glVertexAttrib4uivARB, glVertexAttrib4uivARB, NULL, _gloffset_VertexAttrib4uivARB),
-    NAME_FUNC_OFFSET(16719, glVertexAttrib4usvARB, glVertexAttrib4usvARB, NULL, _gloffset_VertexAttrib4usvARB),
-    NAME_FUNC_OFFSET(16738, glVertexAttribPointerARB, glVertexAttribPointerARB, NULL, _gloffset_VertexAttribPointerARB),
-    NAME_FUNC_OFFSET(16760, glBindBufferARB, glBindBufferARB, NULL, _gloffset_BindBufferARB),
-    NAME_FUNC_OFFSET(16773, glBufferDataARB, glBufferDataARB, NULL, _gloffset_BufferDataARB),
-    NAME_FUNC_OFFSET(16786, glBufferSubDataARB, glBufferSubDataARB, NULL, _gloffset_BufferSubDataARB),
-    NAME_FUNC_OFFSET(16802, glDeleteBuffersARB, glDeleteBuffersARB, NULL, _gloffset_DeleteBuffersARB),
-    NAME_FUNC_OFFSET(16818, glGenBuffersARB, glGenBuffersARB, NULL, _gloffset_GenBuffersARB),
-    NAME_FUNC_OFFSET(16831, glGetBufferParameterivARB, glGetBufferParameterivARB, NULL, _gloffset_GetBufferParameterivARB),
-    NAME_FUNC_OFFSET(16854, glGetBufferPointervARB, glGetBufferPointervARB, NULL, _gloffset_GetBufferPointervARB),
-    NAME_FUNC_OFFSET(16874, glGetBufferSubDataARB, glGetBufferSubDataARB, NULL, _gloffset_GetBufferSubDataARB),
-    NAME_FUNC_OFFSET(16893, glIsBufferARB, glIsBufferARB, NULL, _gloffset_IsBufferARB),
-    NAME_FUNC_OFFSET(16904, glMapBufferARB, glMapBufferARB, NULL, _gloffset_MapBufferARB),
-    NAME_FUNC_OFFSET(16916, glUnmapBufferARB, glUnmapBufferARB, NULL, _gloffset_UnmapBufferARB),
-    NAME_FUNC_OFFSET(16930, glBeginQueryARB, glBeginQueryARB, NULL, _gloffset_BeginQueryARB),
-    NAME_FUNC_OFFSET(16943, glDeleteQueriesARB, glDeleteQueriesARB, NULL, _gloffset_DeleteQueriesARB),
-    NAME_FUNC_OFFSET(16959, glEndQueryARB, glEndQueryARB, NULL, _gloffset_EndQueryARB),
-    NAME_FUNC_OFFSET(16970, glGenQueriesARB, glGenQueriesARB, NULL, _gloffset_GenQueriesARB),
-    NAME_FUNC_OFFSET(16983, glGetQueryObjectivARB, glGetQueryObjectivARB, NULL, _gloffset_GetQueryObjectivARB),
-    NAME_FUNC_OFFSET(17002, glGetQueryObjectuivARB, glGetQueryObjectuivARB, NULL, _gloffset_GetQueryObjectuivARB),
-    NAME_FUNC_OFFSET(17022, glGetQueryivARB, glGetQueryivARB, NULL, _gloffset_GetQueryivARB),
-    NAME_FUNC_OFFSET(17035, glIsQueryARB, glIsQueryARB, NULL, _gloffset_IsQueryARB),
-    NAME_FUNC_OFFSET(17045, glCompileShaderARB, glCompileShaderARB, NULL, _gloffset_CompileShaderARB),
-    NAME_FUNC_OFFSET(17061, glGetActiveUniformARB, glGetActiveUniformARB, NULL, _gloffset_GetActiveUniformARB),
-    NAME_FUNC_OFFSET(17080, glGetShaderSourceARB, glGetShaderSourceARB, NULL, _gloffset_GetShaderSourceARB),
-    NAME_FUNC_OFFSET(17098, glGetUniformLocationARB, glGetUniformLocationARB, NULL, _gloffset_GetUniformLocationARB),
-    NAME_FUNC_OFFSET(17119, glGetUniformfvARB, glGetUniformfvARB, NULL, _gloffset_GetUniformfvARB),
-    NAME_FUNC_OFFSET(17134, glGetUniformivARB, glGetUniformivARB, NULL, _gloffset_GetUniformivARB),
-    NAME_FUNC_OFFSET(17149, glLinkProgramARB, glLinkProgramARB, NULL, _gloffset_LinkProgramARB),
-    NAME_FUNC_OFFSET(17163, glShaderSourceARB, glShaderSourceARB, NULL, _gloffset_ShaderSourceARB),
-    NAME_FUNC_OFFSET(17178, glUniform1fARB, glUniform1fARB, NULL, _gloffset_Uniform1fARB),
-    NAME_FUNC_OFFSET(17190, glUniform1fvARB, glUniform1fvARB, NULL, _gloffset_Uniform1fvARB),
-    NAME_FUNC_OFFSET(17203, glUniform1iARB, glUniform1iARB, NULL, _gloffset_Uniform1iARB),
-    NAME_FUNC_OFFSET(17215, glUniform1ivARB, glUniform1ivARB, NULL, _gloffset_Uniform1ivARB),
-    NAME_FUNC_OFFSET(17228, glUniform2fARB, glUniform2fARB, NULL, _gloffset_Uniform2fARB),
-    NAME_FUNC_OFFSET(17240, glUniform2fvARB, glUniform2fvARB, NULL, _gloffset_Uniform2fvARB),
-    NAME_FUNC_OFFSET(17253, glUniform2iARB, glUniform2iARB, NULL, _gloffset_Uniform2iARB),
-    NAME_FUNC_OFFSET(17265, glUniform2ivARB, glUniform2ivARB, NULL, _gloffset_Uniform2ivARB),
-    NAME_FUNC_OFFSET(17278, glUniform3fARB, glUniform3fARB, NULL, _gloffset_Uniform3fARB),
-    NAME_FUNC_OFFSET(17290, glUniform3fvARB, glUniform3fvARB, NULL, _gloffset_Uniform3fvARB),
-    NAME_FUNC_OFFSET(17303, glUniform3iARB, glUniform3iARB, NULL, _gloffset_Uniform3iARB),
-    NAME_FUNC_OFFSET(17315, glUniform3ivARB, glUniform3ivARB, NULL, _gloffset_Uniform3ivARB),
-    NAME_FUNC_OFFSET(17328, glUniform4fARB, glUniform4fARB, NULL, _gloffset_Uniform4fARB),
-    NAME_FUNC_OFFSET(17340, glUniform4fvARB, glUniform4fvARB, NULL, _gloffset_Uniform4fvARB),
-    NAME_FUNC_OFFSET(17353, glUniform4iARB, glUniform4iARB, NULL, _gloffset_Uniform4iARB),
-    NAME_FUNC_OFFSET(17365, glUniform4ivARB, glUniform4ivARB, NULL, _gloffset_Uniform4ivARB),
-    NAME_FUNC_OFFSET(17378, glUniformMatrix2fvARB, glUniformMatrix2fvARB, NULL, _gloffset_UniformMatrix2fvARB),
-    NAME_FUNC_OFFSET(17397, glUniformMatrix3fvARB, glUniformMatrix3fvARB, NULL, _gloffset_UniformMatrix3fvARB),
-    NAME_FUNC_OFFSET(17416, glUniformMatrix4fvARB, glUniformMatrix4fvARB, NULL, _gloffset_UniformMatrix4fvARB),
-    NAME_FUNC_OFFSET(17435, glUseProgramObjectARB, glUseProgramObjectARB, NULL, _gloffset_UseProgramObjectARB),
-    NAME_FUNC_OFFSET(17448, glValidateProgramARB, glValidateProgramARB, NULL, _gloffset_ValidateProgramARB),
-    NAME_FUNC_OFFSET(17466, glBindAttribLocationARB, glBindAttribLocationARB, NULL, _gloffset_BindAttribLocationARB),
-    NAME_FUNC_OFFSET(17487, glGetActiveAttribARB, glGetActiveAttribARB, NULL, _gloffset_GetActiveAttribARB),
-    NAME_FUNC_OFFSET(17505, glGetAttribLocationARB, glGetAttribLocationARB, NULL, _gloffset_GetAttribLocationARB),
-    NAME_FUNC_OFFSET(17525, glDrawBuffersARB, glDrawBuffersARB, NULL, _gloffset_DrawBuffersARB),
-    NAME_FUNC_OFFSET(17539, glDrawBuffersARB, glDrawBuffersARB, NULL, _gloffset_DrawBuffersARB),
-    NAME_FUNC_OFFSET(17556, gl_dispatch_stub_569, gl_dispatch_stub_569, NULL, _gloffset_SampleMaskSGIS),
-    NAME_FUNC_OFFSET(17572, gl_dispatch_stub_570, gl_dispatch_stub_570, NULL, _gloffset_SamplePatternSGIS),
-    NAME_FUNC_OFFSET(17591, glPointParameterfEXT, glPointParameterfEXT, NULL, _gloffset_PointParameterfEXT),
-    NAME_FUNC_OFFSET(17609, glPointParameterfEXT, glPointParameterfEXT, NULL, _gloffset_PointParameterfEXT),
-    NAME_FUNC_OFFSET(17630, glPointParameterfEXT, glPointParameterfEXT, NULL, _gloffset_PointParameterfEXT),
-    NAME_FUNC_OFFSET(17652, glPointParameterfvEXT, glPointParameterfvEXT, NULL, _gloffset_PointParameterfvEXT),
-    NAME_FUNC_OFFSET(17671, glPointParameterfvEXT, glPointParameterfvEXT, NULL, _gloffset_PointParameterfvEXT),
-    NAME_FUNC_OFFSET(17693, glPointParameterfvEXT, glPointParameterfvEXT, NULL, _gloffset_PointParameterfvEXT),
-    NAME_FUNC_OFFSET(17716, glSecondaryColor3bEXT, glSecondaryColor3bEXT, NULL, _gloffset_SecondaryColor3bEXT),
-    NAME_FUNC_OFFSET(17735, glSecondaryColor3bvEXT, glSecondaryColor3bvEXT, NULL, _gloffset_SecondaryColor3bvEXT),
-    NAME_FUNC_OFFSET(17755, glSecondaryColor3dEXT, glSecondaryColor3dEXT, NULL, _gloffset_SecondaryColor3dEXT),
-    NAME_FUNC_OFFSET(17774, glSecondaryColor3dvEXT, glSecondaryColor3dvEXT, NULL, _gloffset_SecondaryColor3dvEXT),
-    NAME_FUNC_OFFSET(17794, glSecondaryColor3fEXT, glSecondaryColor3fEXT, NULL, _gloffset_SecondaryColor3fEXT),
-    NAME_FUNC_OFFSET(17813, glSecondaryColor3fvEXT, glSecondaryColor3fvEXT, NULL, _gloffset_SecondaryColor3fvEXT),
-    NAME_FUNC_OFFSET(17833, glSecondaryColor3iEXT, glSecondaryColor3iEXT, NULL, _gloffset_SecondaryColor3iEXT),
-    NAME_FUNC_OFFSET(17852, glSecondaryColor3ivEXT, glSecondaryColor3ivEXT, NULL, _gloffset_SecondaryColor3ivEXT),
-    NAME_FUNC_OFFSET(17872, glSecondaryColor3sEXT, glSecondaryColor3sEXT, NULL, _gloffset_SecondaryColor3sEXT),
-    NAME_FUNC_OFFSET(17891, glSecondaryColor3svEXT, glSecondaryColor3svEXT, NULL, _gloffset_SecondaryColor3svEXT),
-    NAME_FUNC_OFFSET(17911, glSecondaryColor3ubEXT, glSecondaryColor3ubEXT, NULL, _gloffset_SecondaryColor3ubEXT),
-    NAME_FUNC_OFFSET(17931, glSecondaryColor3ubvEXT, glSecondaryColor3ubvEXT, NULL, _gloffset_SecondaryColor3ubvEXT),
-    NAME_FUNC_OFFSET(17952, glSecondaryColor3uiEXT, glSecondaryColor3uiEXT, NULL, _gloffset_SecondaryColor3uiEXT),
-    NAME_FUNC_OFFSET(17972, glSecondaryColor3uivEXT, glSecondaryColor3uivEXT, NULL, _gloffset_SecondaryColor3uivEXT),
-    NAME_FUNC_OFFSET(17993, glSecondaryColor3usEXT, glSecondaryColor3usEXT, NULL, _gloffset_SecondaryColor3usEXT),
-    NAME_FUNC_OFFSET(18013, glSecondaryColor3usvEXT, glSecondaryColor3usvEXT, NULL, _gloffset_SecondaryColor3usvEXT),
-    NAME_FUNC_OFFSET(18034, glSecondaryColorPointerEXT, glSecondaryColorPointerEXT, NULL, _gloffset_SecondaryColorPointerEXT),
-    NAME_FUNC_OFFSET(18058, glMultiDrawArraysEXT, glMultiDrawArraysEXT, NULL, _gloffset_MultiDrawArraysEXT),
-    NAME_FUNC_OFFSET(18076, glMultiDrawElementsEXT, glMultiDrawElementsEXT, NULL, _gloffset_MultiDrawElementsEXT),
-    NAME_FUNC_OFFSET(18096, glFogCoordPointerEXT, glFogCoordPointerEXT, NULL, _gloffset_FogCoordPointerEXT),
-    NAME_FUNC_OFFSET(18114, glFogCoorddEXT, glFogCoorddEXT, NULL, _gloffset_FogCoorddEXT),
-    NAME_FUNC_OFFSET(18126, glFogCoorddvEXT, glFogCoorddvEXT, NULL, _gloffset_FogCoorddvEXT),
-    NAME_FUNC_OFFSET(18139, glFogCoordfEXT, glFogCoordfEXT, NULL, _gloffset_FogCoordfEXT),
-    NAME_FUNC_OFFSET(18151, glFogCoordfvEXT, glFogCoordfvEXT, NULL, _gloffset_FogCoordfvEXT),
-    NAME_FUNC_OFFSET(18164, glBlendFuncSeparateEXT, glBlendFuncSeparateEXT, NULL, _gloffset_BlendFuncSeparateEXT),
-    NAME_FUNC_OFFSET(18184, glBlendFuncSeparateEXT, glBlendFuncSeparateEXT, NULL, _gloffset_BlendFuncSeparateEXT),
-    NAME_FUNC_OFFSET(18208, glWindowPos2dMESA, glWindowPos2dMESA, NULL, _gloffset_WindowPos2dMESA),
-    NAME_FUNC_OFFSET(18222, glWindowPos2dMESA, glWindowPos2dMESA, NULL, _gloffset_WindowPos2dMESA),
-    NAME_FUNC_OFFSET(18239, glWindowPos2dvMESA, glWindowPos2dvMESA, NULL, _gloffset_WindowPos2dvMESA),
-    NAME_FUNC_OFFSET(18254, glWindowPos2dvMESA, glWindowPos2dvMESA, NULL, _gloffset_WindowPos2dvMESA),
-    NAME_FUNC_OFFSET(18272, glWindowPos2fMESA, glWindowPos2fMESA, NULL, _gloffset_WindowPos2fMESA),
-    NAME_FUNC_OFFSET(18286, glWindowPos2fMESA, glWindowPos2fMESA, NULL, _gloffset_WindowPos2fMESA),
-    NAME_FUNC_OFFSET(18303, glWindowPos2fvMESA, glWindowPos2fvMESA, NULL, _gloffset_WindowPos2fvMESA),
-    NAME_FUNC_OFFSET(18318, glWindowPos2fvMESA, glWindowPos2fvMESA, NULL, _gloffset_WindowPos2fvMESA),
-    NAME_FUNC_OFFSET(18336, glWindowPos2iMESA, glWindowPos2iMESA, NULL, _gloffset_WindowPos2iMESA),
-    NAME_FUNC_OFFSET(18350, glWindowPos2iMESA, glWindowPos2iMESA, NULL, _gloffset_WindowPos2iMESA),
-    NAME_FUNC_OFFSET(18367, glWindowPos2ivMESA, glWindowPos2ivMESA, NULL, _gloffset_WindowPos2ivMESA),
-    NAME_FUNC_OFFSET(18382, glWindowPos2ivMESA, glWindowPos2ivMESA, NULL, _gloffset_WindowPos2ivMESA),
-    NAME_FUNC_OFFSET(18400, glWindowPos2sMESA, glWindowPos2sMESA, NULL, _gloffset_WindowPos2sMESA),
-    NAME_FUNC_OFFSET(18414, glWindowPos2sMESA, glWindowPos2sMESA, NULL, _gloffset_WindowPos2sMESA),
-    NAME_FUNC_OFFSET(18431, glWindowPos2svMESA, glWindowPos2svMESA, NULL, _gloffset_WindowPos2svMESA),
-    NAME_FUNC_OFFSET(18446, glWindowPos2svMESA, glWindowPos2svMESA, NULL, _gloffset_WindowPos2svMESA),
-    NAME_FUNC_OFFSET(18464, glWindowPos3dMESA, glWindowPos3dMESA, NULL, _gloffset_WindowPos3dMESA),
-    NAME_FUNC_OFFSET(18478, glWindowPos3dMESA, glWindowPos3dMESA, NULL, _gloffset_WindowPos3dMESA),
-    NAME_FUNC_OFFSET(18495, glWindowPos3dvMESA, glWindowPos3dvMESA, NULL, _gloffset_WindowPos3dvMESA),
-    NAME_FUNC_OFFSET(18510, glWindowPos3dvMESA, glWindowPos3dvMESA, NULL, _gloffset_WindowPos3dvMESA),
-    NAME_FUNC_OFFSET(18528, glWindowPos3fMESA, glWindowPos3fMESA, NULL, _gloffset_WindowPos3fMESA),
-    NAME_FUNC_OFFSET(18542, glWindowPos3fMESA, glWindowPos3fMESA, NULL, _gloffset_WindowPos3fMESA),
-    NAME_FUNC_OFFSET(18559, glWindowPos3fvMESA, glWindowPos3fvMESA, NULL, _gloffset_WindowPos3fvMESA),
-    NAME_FUNC_OFFSET(18574, glWindowPos3fvMESA, glWindowPos3fvMESA, NULL, _gloffset_WindowPos3fvMESA),
-    NAME_FUNC_OFFSET(18592, glWindowPos3iMESA, glWindowPos3iMESA, NULL, _gloffset_WindowPos3iMESA),
-    NAME_FUNC_OFFSET(18606, glWindowPos3iMESA, glWindowPos3iMESA, NULL, _gloffset_WindowPos3iMESA),
-    NAME_FUNC_OFFSET(18623, glWindowPos3ivMESA, glWindowPos3ivMESA, NULL, _gloffset_WindowPos3ivMESA),
-    NAME_FUNC_OFFSET(18638, glWindowPos3ivMESA, glWindowPos3ivMESA, NULL, _gloffset_WindowPos3ivMESA),
-    NAME_FUNC_OFFSET(18656, glWindowPos3sMESA, glWindowPos3sMESA, NULL, _gloffset_WindowPos3sMESA),
-    NAME_FUNC_OFFSET(18670, glWindowPos3sMESA, glWindowPos3sMESA, NULL, _gloffset_WindowPos3sMESA),
-    NAME_FUNC_OFFSET(18687, glWindowPos3svMESA, glWindowPos3svMESA, NULL, _gloffset_WindowPos3svMESA),
-    NAME_FUNC_OFFSET(18702, glWindowPos3svMESA, glWindowPos3svMESA, NULL, _gloffset_WindowPos3svMESA),
-    NAME_FUNC_OFFSET(18720, glBindProgramNV, glBindProgramNV, NULL, _gloffset_BindProgramNV),
-    NAME_FUNC_OFFSET(18737, glDeleteProgramsNV, glDeleteProgramsNV, NULL, _gloffset_DeleteProgramsNV),
-    NAME_FUNC_OFFSET(18757, glGenProgramsNV, glGenProgramsNV, NULL, _gloffset_GenProgramsNV),
-    NAME_FUNC_OFFSET(18774, glGetVertexAttribPointervNV, glGetVertexAttribPointervNV, NULL, _gloffset_GetVertexAttribPointervNV),
-    NAME_FUNC_OFFSET(18800, glGetVertexAttribPointervNV, glGetVertexAttribPointervNV, NULL, _gloffset_GetVertexAttribPointervNV),
-    NAME_FUNC_OFFSET(18829, glIsProgramNV, glIsProgramNV, NULL, _gloffset_IsProgramNV),
-    NAME_FUNC_OFFSET(18844, glPointParameteriNV, glPointParameteriNV, NULL, _gloffset_PointParameteriNV),
-    NAME_FUNC_OFFSET(18862, glPointParameterivNV, glPointParameterivNV, NULL, _gloffset_PointParameterivNV),
-    NAME_FUNC_OFFSET(18881, gl_dispatch_stub_750, gl_dispatch_stub_750, NULL, _gloffset_BlendEquationSeparateEXT),
-    NAME_FUNC_OFFSET(18905, gl_dispatch_stub_750, gl_dispatch_stub_750, NULL, _gloffset_BlendEquationSeparateEXT),
-    NAME_FUNC_OFFSET(18932, glBindFramebufferEXT, glBindFramebufferEXT, NULL, _gloffset_BindFramebufferEXT),
-    NAME_FUNC_OFFSET(18950, glBindRenderbufferEXT, glBindRenderbufferEXT, NULL, _gloffset_BindRenderbufferEXT),
-    NAME_FUNC_OFFSET(18969, glCheckFramebufferStatusEXT, glCheckFramebufferStatusEXT, NULL, _gloffset_CheckFramebufferStatusEXT),
-    NAME_FUNC_OFFSET(18994, glDeleteFramebuffersEXT, glDeleteFramebuffersEXT, NULL, _gloffset_DeleteFramebuffersEXT),
-    NAME_FUNC_OFFSET(19015, glDeleteRenderbuffersEXT, glDeleteRenderbuffersEXT, NULL, _gloffset_DeleteRenderbuffersEXT),
-    NAME_FUNC_OFFSET(19037, glFramebufferRenderbufferEXT, glFramebufferRenderbufferEXT, NULL, _gloffset_FramebufferRenderbufferEXT),
-    NAME_FUNC_OFFSET(19063, glFramebufferTexture1DEXT, glFramebufferTexture1DEXT, NULL, _gloffset_FramebufferTexture1DEXT),
-    NAME_FUNC_OFFSET(19086, glFramebufferTexture2DEXT, glFramebufferTexture2DEXT, NULL, _gloffset_FramebufferTexture2DEXT),
-    NAME_FUNC_OFFSET(19109, glFramebufferTexture3DEXT, glFramebufferTexture3DEXT, NULL, _gloffset_FramebufferTexture3DEXT),
-    NAME_FUNC_OFFSET(19132, glGenFramebuffersEXT, glGenFramebuffersEXT, NULL, _gloffset_GenFramebuffersEXT),
-    NAME_FUNC_OFFSET(19150, glGenRenderbuffersEXT, glGenRenderbuffersEXT, NULL, _gloffset_GenRenderbuffersEXT),
-    NAME_FUNC_OFFSET(19169, glGenerateMipmapEXT, glGenerateMipmapEXT, NULL, _gloffset_GenerateMipmapEXT),
-    NAME_FUNC_OFFSET(19186, glGetFramebufferAttachmentParameterivEXT, glGetFramebufferAttachmentParameterivEXT, NULL, _gloffset_GetFramebufferAttachmentParameterivEXT),
-    NAME_FUNC_OFFSET(19224, glGetRenderbufferParameterivEXT, glGetRenderbufferParameterivEXT, NULL, _gloffset_GetRenderbufferParameterivEXT),
-    NAME_FUNC_OFFSET(19253, glIsFramebufferEXT, glIsFramebufferEXT, NULL, _gloffset_IsFramebufferEXT),
-    NAME_FUNC_OFFSET(19269, glIsRenderbufferEXT, glIsRenderbufferEXT, NULL, _gloffset_IsRenderbufferEXT),
-    NAME_FUNC_OFFSET(19286, glRenderbufferStorageEXT, glRenderbufferStorageEXT, NULL, _gloffset_RenderbufferStorageEXT),
-    NAME_FUNC_OFFSET(19308, gl_dispatch_stub_768, gl_dispatch_stub_768, NULL, _gloffset_BlitFramebufferEXT),
-    NAME_FUNC_OFFSET(19326, glFramebufferTextureLayerEXT, glFramebufferTextureLayerEXT, NULL, _gloffset_FramebufferTextureLayerEXT),
+    NAME_FUNC_OFFSET( 8984, glFlushMappedBufferRange, glFlushMappedBufferRange, NULL, _gloffset_FlushMappedBufferRange),
+    NAME_FUNC_OFFSET( 9009, glMapBufferRange, glMapBufferRange, NULL, _gloffset_MapBufferRange),
+    NAME_FUNC_OFFSET( 9026, glCopyBufferSubData, glCopyBufferSubData, NULL, _gloffset_CopyBufferSubData),
+    NAME_FUNC_OFFSET( 9046, glPolygonOffsetEXT, glPolygonOffsetEXT, NULL, _gloffset_PolygonOffsetEXT),
+    NAME_FUNC_OFFSET( 9065, gl_dispatch_stub_566, gl_dispatch_stub_566, NULL, _gloffset_GetPixelTexGenParameterfvSGIS),
+    NAME_FUNC_OFFSET( 9097, gl_dispatch_stub_567, gl_dispatch_stub_567, NULL, _gloffset_GetPixelTexGenParameterivSGIS),
+    NAME_FUNC_OFFSET( 9129, gl_dispatch_stub_568, gl_dispatch_stub_568, NULL, _gloffset_PixelTexGenParameterfSGIS),
+    NAME_FUNC_OFFSET( 9157, gl_dispatch_stub_569, gl_dispatch_stub_569, NULL, _gloffset_PixelTexGenParameterfvSGIS),
+    NAME_FUNC_OFFSET( 9186, gl_dispatch_stub_570, gl_dispatch_stub_570, NULL, _gloffset_PixelTexGenParameteriSGIS),
+    NAME_FUNC_OFFSET( 9214, gl_dispatch_stub_571, gl_dispatch_stub_571, NULL, _gloffset_PixelTexGenParameterivSGIS),
+    NAME_FUNC_OFFSET( 9243, gl_dispatch_stub_572, gl_dispatch_stub_572, NULL, _gloffset_SampleMaskSGIS),
+    NAME_FUNC_OFFSET( 9260, gl_dispatch_stub_573, gl_dispatch_stub_573, NULL, _gloffset_SamplePatternSGIS),
+    NAME_FUNC_OFFSET( 9280, glColorPointerEXT, glColorPointerEXT, NULL, _gloffset_ColorPointerEXT),
+    NAME_FUNC_OFFSET( 9298, glEdgeFlagPointerEXT, glEdgeFlagPointerEXT, NULL, _gloffset_EdgeFlagPointerEXT),
+    NAME_FUNC_OFFSET( 9319, glIndexPointerEXT, glIndexPointerEXT, NULL, _gloffset_IndexPointerEXT),
+    NAME_FUNC_OFFSET( 9337, glNormalPointerEXT, glNormalPointerEXT, NULL, _gloffset_NormalPointerEXT),
+    NAME_FUNC_OFFSET( 9356, glTexCoordPointerEXT, glTexCoordPointerEXT, NULL, _gloffset_TexCoordPointerEXT),
+    NAME_FUNC_OFFSET( 9377, glVertexPointerEXT, glVertexPointerEXT, NULL, _gloffset_VertexPointerEXT),
+    NAME_FUNC_OFFSET( 9396, glPointParameterfEXT, glPointParameterfEXT, NULL, _gloffset_PointParameterfEXT),
+    NAME_FUNC_OFFSET( 9417, glPointParameterfvEXT, glPointParameterfvEXT, NULL, _gloffset_PointParameterfvEXT),
+    NAME_FUNC_OFFSET( 9439, glLockArraysEXT, glLockArraysEXT, NULL, _gloffset_LockArraysEXT),
+    NAME_FUNC_OFFSET( 9455, glUnlockArraysEXT, glUnlockArraysEXT, NULL, _gloffset_UnlockArraysEXT),
+    NAME_FUNC_OFFSET( 9473, gl_dispatch_stub_584, gl_dispatch_stub_584, NULL, _gloffset_CullParameterdvEXT),
+    NAME_FUNC_OFFSET( 9494, gl_dispatch_stub_585, gl_dispatch_stub_585, NULL, _gloffset_CullParameterfvEXT),
+    NAME_FUNC_OFFSET( 9515, glSecondaryColor3bEXT, glSecondaryColor3bEXT, NULL, _gloffset_SecondaryColor3bEXT),
+    NAME_FUNC_OFFSET( 9537, glSecondaryColor3bvEXT, glSecondaryColor3bvEXT, NULL, _gloffset_SecondaryColor3bvEXT),
+    NAME_FUNC_OFFSET( 9560, glSecondaryColor3dEXT, glSecondaryColor3dEXT, NULL, _gloffset_SecondaryColor3dEXT),
+    NAME_FUNC_OFFSET( 9582, glSecondaryColor3dvEXT, glSecondaryColor3dvEXT, NULL, _gloffset_SecondaryColor3dvEXT),
+    NAME_FUNC_OFFSET( 9605, glSecondaryColor3fEXT, glSecondaryColor3fEXT, NULL, _gloffset_SecondaryColor3fEXT),
+    NAME_FUNC_OFFSET( 9627, glSecondaryColor3fvEXT, glSecondaryColor3fvEXT, NULL, _gloffset_SecondaryColor3fvEXT),
+    NAME_FUNC_OFFSET( 9650, glSecondaryColor3iEXT, glSecondaryColor3iEXT, NULL, _gloffset_SecondaryColor3iEXT),
+    NAME_FUNC_OFFSET( 9672, glSecondaryColor3ivEXT, glSecondaryColor3ivEXT, NULL, _gloffset_SecondaryColor3ivEXT),
+    NAME_FUNC_OFFSET( 9695, glSecondaryColor3sEXT, glSecondaryColor3sEXT, NULL, _gloffset_SecondaryColor3sEXT),
+    NAME_FUNC_OFFSET( 9717, glSecondaryColor3svEXT, glSecondaryColor3svEXT, NULL, _gloffset_SecondaryColor3svEXT),
+    NAME_FUNC_OFFSET( 9740, glSecondaryColor3ubEXT, glSecondaryColor3ubEXT, NULL, _gloffset_SecondaryColor3ubEXT),
+    NAME_FUNC_OFFSET( 9763, glSecondaryColor3ubvEXT, glSecondaryColor3ubvEXT, NULL, _gloffset_SecondaryColor3ubvEXT),
+    NAME_FUNC_OFFSET( 9787, glSecondaryColor3uiEXT, glSecondaryColor3uiEXT, NULL, _gloffset_SecondaryColor3uiEXT),
+    NAME_FUNC_OFFSET( 9810, glSecondaryColor3uivEXT, glSecondaryColor3uivEXT, NULL, _gloffset_SecondaryColor3uivEXT),
+    NAME_FUNC_OFFSET( 9834, glSecondaryColor3usEXT, glSecondaryColor3usEXT, NULL, _gloffset_SecondaryColor3usEXT),
+    NAME_FUNC_OFFSET( 9857, glSecondaryColor3usvEXT, glSecondaryColor3usvEXT, NULL, _gloffset_SecondaryColor3usvEXT),
+    NAME_FUNC_OFFSET( 9881, glSecondaryColorPointerEXT, glSecondaryColorPointerEXT, NULL, _gloffset_SecondaryColorPointerEXT),
+    NAME_FUNC_OFFSET( 9908, glMultiDrawArraysEXT, glMultiDrawArraysEXT, NULL, _gloffset_MultiDrawArraysEXT),
+    NAME_FUNC_OFFSET( 9929, glMultiDrawElementsEXT, glMultiDrawElementsEXT, NULL, _gloffset_MultiDrawElementsEXT),
+    NAME_FUNC_OFFSET( 9952, glFogCoordPointerEXT, glFogCoordPointerEXT, NULL, _gloffset_FogCoordPointerEXT),
+    NAME_FUNC_OFFSET( 9973, glFogCoorddEXT, glFogCoorddEXT, NULL, _gloffset_FogCoorddEXT),
+    NAME_FUNC_OFFSET( 9988, glFogCoorddvEXT, glFogCoorddvEXT, NULL, _gloffset_FogCoorddvEXT),
+    NAME_FUNC_OFFSET(10004, glFogCoordfEXT, glFogCoordfEXT, NULL, _gloffset_FogCoordfEXT),
+    NAME_FUNC_OFFSET(10019, glFogCoordfvEXT, glFogCoordfvEXT, NULL, _gloffset_FogCoordfvEXT),
+    NAME_FUNC_OFFSET(10035, gl_dispatch_stub_610, gl_dispatch_stub_610, NULL, _gloffset_PixelTexGenSGIX),
+    NAME_FUNC_OFFSET(10053, glBlendFuncSeparateEXT, glBlendFuncSeparateEXT, NULL, _gloffset_BlendFuncSeparateEXT),
+    NAME_FUNC_OFFSET(10076, glFlushVertexArrayRangeNV, glFlushVertexArrayRangeNV, NULL, _gloffset_FlushVertexArrayRangeNV),
+    NAME_FUNC_OFFSET(10102, glVertexArrayRangeNV, glVertexArrayRangeNV, NULL, _gloffset_VertexArrayRangeNV),
+    NAME_FUNC_OFFSET(10123, glCombinerInputNV, glCombinerInputNV, NULL, _gloffset_CombinerInputNV),
+    NAME_FUNC_OFFSET(10141, glCombinerOutputNV, glCombinerOutputNV, NULL, _gloffset_CombinerOutputNV),
+    NAME_FUNC_OFFSET(10160, glCombinerParameterfNV, glCombinerParameterfNV, NULL, _gloffset_CombinerParameterfNV),
+    NAME_FUNC_OFFSET(10183, glCombinerParameterfvNV, glCombinerParameterfvNV, NULL, _gloffset_CombinerParameterfvNV),
+    NAME_FUNC_OFFSET(10207, glCombinerParameteriNV, glCombinerParameteriNV, NULL, _gloffset_CombinerParameteriNV),
+    NAME_FUNC_OFFSET(10230, glCombinerParameterivNV, glCombinerParameterivNV, NULL, _gloffset_CombinerParameterivNV),
+    NAME_FUNC_OFFSET(10254, glFinalCombinerInputNV, glFinalCombinerInputNV, NULL, _gloffset_FinalCombinerInputNV),
+    NAME_FUNC_OFFSET(10277, glGetCombinerInputParameterfvNV, glGetCombinerInputParameterfvNV, NULL, _gloffset_GetCombinerInputParameterfvNV),
+    NAME_FUNC_OFFSET(10309, glGetCombinerInputParameterivNV, glGetCombinerInputParameterivNV, NULL, _gloffset_GetCombinerInputParameterivNV),
+    NAME_FUNC_OFFSET(10341, glGetCombinerOutputParameterfvNV, glGetCombinerOutputParameterfvNV, NULL, _gloffset_GetCombinerOutputParameterfvNV),
+    NAME_FUNC_OFFSET(10374, glGetCombinerOutputParameterivNV, glGetCombinerOutputParameterivNV, NULL, _gloffset_GetCombinerOutputParameterivNV),
+    NAME_FUNC_OFFSET(10407, glGetFinalCombinerInputParameterfvNV, glGetFinalCombinerInputParameterfvNV, NULL, _gloffset_GetFinalCombinerInputParameterfvNV),
+    NAME_FUNC_OFFSET(10444, glGetFinalCombinerInputParameterivNV, glGetFinalCombinerInputParameterivNV, NULL, _gloffset_GetFinalCombinerInputParameterivNV),
+    NAME_FUNC_OFFSET(10481, glResizeBuffersMESA, glResizeBuffersMESA, NULL, _gloffset_ResizeBuffersMESA),
+    NAME_FUNC_OFFSET(10501, glWindowPos2dMESA, glWindowPos2dMESA, NULL, _gloffset_WindowPos2dMESA),
+    NAME_FUNC_OFFSET(10519, glWindowPos2dvMESA, glWindowPos2dvMESA, NULL, _gloffset_WindowPos2dvMESA),
+    NAME_FUNC_OFFSET(10538, glWindowPos2fMESA, glWindowPos2fMESA, NULL, _gloffset_WindowPos2fMESA),
+    NAME_FUNC_OFFSET(10556, glWindowPos2fvMESA, glWindowPos2fvMESA, NULL, _gloffset_WindowPos2fvMESA),
+    NAME_FUNC_OFFSET(10575, glWindowPos2iMESA, glWindowPos2iMESA, NULL, _gloffset_WindowPos2iMESA),
+    NAME_FUNC_OFFSET(10593, glWindowPos2ivMESA, glWindowPos2ivMESA, NULL, _gloffset_WindowPos2ivMESA),
+    NAME_FUNC_OFFSET(10612, glWindowPos2sMESA, glWindowPos2sMESA, NULL, _gloffset_WindowPos2sMESA),
+    NAME_FUNC_OFFSET(10630, glWindowPos2svMESA, glWindowPos2svMESA, NULL, _gloffset_WindowPos2svMESA),
+    NAME_FUNC_OFFSET(10649, glWindowPos3dMESA, glWindowPos3dMESA, NULL, _gloffset_WindowPos3dMESA),
+    NAME_FUNC_OFFSET(10667, glWindowPos3dvMESA, glWindowPos3dvMESA, NULL, _gloffset_WindowPos3dvMESA),
+    NAME_FUNC_OFFSET(10686, glWindowPos3fMESA, glWindowPos3fMESA, NULL, _gloffset_WindowPos3fMESA),
+    NAME_FUNC_OFFSET(10704, glWindowPos3fvMESA, glWindowPos3fvMESA, NULL, _gloffset_WindowPos3fvMESA),
+    NAME_FUNC_OFFSET(10723, glWindowPos3iMESA, glWindowPos3iMESA, NULL, _gloffset_WindowPos3iMESA),
+    NAME_FUNC_OFFSET(10741, glWindowPos3ivMESA, glWindowPos3ivMESA, NULL, _gloffset_WindowPos3ivMESA),
+    NAME_FUNC_OFFSET(10760, glWindowPos3sMESA, glWindowPos3sMESA, NULL, _gloffset_WindowPos3sMESA),
+    NAME_FUNC_OFFSET(10778, glWindowPos3svMESA, glWindowPos3svMESA, NULL, _gloffset_WindowPos3svMESA),
+    NAME_FUNC_OFFSET(10797, glWindowPos4dMESA, glWindowPos4dMESA, NULL, _gloffset_WindowPos4dMESA),
+    NAME_FUNC_OFFSET(10815, glWindowPos4dvMESA, glWindowPos4dvMESA, NULL, _gloffset_WindowPos4dvMESA),
+    NAME_FUNC_OFFSET(10834, glWindowPos4fMESA, glWindowPos4fMESA, NULL, _gloffset_WindowPos4fMESA),
+    NAME_FUNC_OFFSET(10852, glWindowPos4fvMESA, glWindowPos4fvMESA, NULL, _gloffset_WindowPos4fvMESA),
+    NAME_FUNC_OFFSET(10871, glWindowPos4iMESA, glWindowPos4iMESA, NULL, _gloffset_WindowPos4iMESA),
+    NAME_FUNC_OFFSET(10889, glWindowPos4ivMESA, glWindowPos4ivMESA, NULL, _gloffset_WindowPos4ivMESA),
+    NAME_FUNC_OFFSET(10908, glWindowPos4sMESA, glWindowPos4sMESA, NULL, _gloffset_WindowPos4sMESA),
+    NAME_FUNC_OFFSET(10926, glWindowPos4svMESA, glWindowPos4svMESA, NULL, _gloffset_WindowPos4svMESA),
+    NAME_FUNC_OFFSET(10945, gl_dispatch_stub_652, gl_dispatch_stub_652, NULL, _gloffset_MultiModeDrawArraysIBM),
+    NAME_FUNC_OFFSET(10970, gl_dispatch_stub_653, gl_dispatch_stub_653, NULL, _gloffset_MultiModeDrawElementsIBM),
+    NAME_FUNC_OFFSET(10997, gl_dispatch_stub_654, gl_dispatch_stub_654, NULL, _gloffset_DeleteFencesNV),
+    NAME_FUNC_OFFSET(11014, gl_dispatch_stub_655, gl_dispatch_stub_655, NULL, _gloffset_FinishFenceNV),
+    NAME_FUNC_OFFSET(11030, gl_dispatch_stub_656, gl_dispatch_stub_656, NULL, _gloffset_GenFencesNV),
+    NAME_FUNC_OFFSET(11044, gl_dispatch_stub_657, gl_dispatch_stub_657, NULL, _gloffset_GetFenceivNV),
+    NAME_FUNC_OFFSET(11059, gl_dispatch_stub_658, gl_dispatch_stub_658, NULL, _gloffset_IsFenceNV),
+    NAME_FUNC_OFFSET(11071, gl_dispatch_stub_659, gl_dispatch_stub_659, NULL, _gloffset_SetFenceNV),
+    NAME_FUNC_OFFSET(11084, gl_dispatch_stub_660, gl_dispatch_stub_660, NULL, _gloffset_TestFenceNV),
+    NAME_FUNC_OFFSET(11098, glAreProgramsResidentNV, glAreProgramsResidentNV, NULL, _gloffset_AreProgramsResidentNV),
+    NAME_FUNC_OFFSET(11122, glBindProgramNV, glBindProgramNV, NULL, _gloffset_BindProgramNV),
+    NAME_FUNC_OFFSET(11138, glDeleteProgramsNV, glDeleteProgramsNV, NULL, _gloffset_DeleteProgramsNV),
+    NAME_FUNC_OFFSET(11157, glExecuteProgramNV, glExecuteProgramNV, NULL, _gloffset_ExecuteProgramNV),
+    NAME_FUNC_OFFSET(11176, glGenProgramsNV, glGenProgramsNV, NULL, _gloffset_GenProgramsNV),
+    NAME_FUNC_OFFSET(11192, glGetProgramParameterdvNV, glGetProgramParameterdvNV, NULL, _gloffset_GetProgramParameterdvNV),
+    NAME_FUNC_OFFSET(11218, glGetProgramParameterfvNV, glGetProgramParameterfvNV, NULL, _gloffset_GetProgramParameterfvNV),
+    NAME_FUNC_OFFSET(11244, glGetProgramStringNV, glGetProgramStringNV, NULL, _gloffset_GetProgramStringNV),
+    NAME_FUNC_OFFSET(11265, glGetProgramivNV, glGetProgramivNV, NULL, _gloffset_GetProgramivNV),
+    NAME_FUNC_OFFSET(11282, glGetTrackMatrixivNV, glGetTrackMatrixivNV, NULL, _gloffset_GetTrackMatrixivNV),
+    NAME_FUNC_OFFSET(11303, glGetVertexAttribPointervNV, glGetVertexAttribPointervNV, NULL, _gloffset_GetVertexAttribPointervNV),
+    NAME_FUNC_OFFSET(11331, glGetVertexAttribdvNV, glGetVertexAttribdvNV, NULL, _gloffset_GetVertexAttribdvNV),
+    NAME_FUNC_OFFSET(11353, glGetVertexAttribfvNV, glGetVertexAttribfvNV, NULL, _gloffset_GetVertexAttribfvNV),
+    NAME_FUNC_OFFSET(11375, glGetVertexAttribivNV, glGetVertexAttribivNV, NULL, _gloffset_GetVertexAttribivNV),
+    NAME_FUNC_OFFSET(11397, glIsProgramNV, glIsProgramNV, NULL, _gloffset_IsProgramNV),
+    NAME_FUNC_OFFSET(11411, glLoadProgramNV, glLoadProgramNV, NULL, _gloffset_LoadProgramNV),
+    NAME_FUNC_OFFSET(11427, glProgramParameters4dvNV, glProgramParameters4dvNV, NULL, _gloffset_ProgramParameters4dvNV),
+    NAME_FUNC_OFFSET(11452, glProgramParameters4fvNV, glProgramParameters4fvNV, NULL, _gloffset_ProgramParameters4fvNV),
+    NAME_FUNC_OFFSET(11477, glRequestResidentProgramsNV, glRequestResidentProgramsNV, NULL, _gloffset_RequestResidentProgramsNV),
+    NAME_FUNC_OFFSET(11505, glTrackMatrixNV, glTrackMatrixNV, NULL, _gloffset_TrackMatrixNV),
+    NAME_FUNC_OFFSET(11521, glVertexAttrib1dNV, glVertexAttrib1dNV, NULL, _gloffset_VertexAttrib1dNV),
+    NAME_FUNC_OFFSET(11540, glVertexAttrib1dvNV, glVertexAttrib1dvNV, NULL, _gloffset_VertexAttrib1dvNV),
+    NAME_FUNC_OFFSET(11560, glVertexAttrib1fNV, glVertexAttrib1fNV, NULL, _gloffset_VertexAttrib1fNV),
+    NAME_FUNC_OFFSET(11579, glVertexAttrib1fvNV, glVertexAttrib1fvNV, NULL, _gloffset_VertexAttrib1fvNV),
+    NAME_FUNC_OFFSET(11599, glVertexAttrib1sNV, glVertexAttrib1sNV, NULL, _gloffset_VertexAttrib1sNV),
+    NAME_FUNC_OFFSET(11618, glVertexAttrib1svNV, glVertexAttrib1svNV, NULL, _gloffset_VertexAttrib1svNV),
+    NAME_FUNC_OFFSET(11638, glVertexAttrib2dNV, glVertexAttrib2dNV, NULL, _gloffset_VertexAttrib2dNV),
+    NAME_FUNC_OFFSET(11657, glVertexAttrib2dvNV, glVertexAttrib2dvNV, NULL, _gloffset_VertexAttrib2dvNV),
+    NAME_FUNC_OFFSET(11677, glVertexAttrib2fNV, glVertexAttrib2fNV, NULL, _gloffset_VertexAttrib2fNV),
+    NAME_FUNC_OFFSET(11696, glVertexAttrib2fvNV, glVertexAttrib2fvNV, NULL, _gloffset_VertexAttrib2fvNV),
+    NAME_FUNC_OFFSET(11716, glVertexAttrib2sNV, glVertexAttrib2sNV, NULL, _gloffset_VertexAttrib2sNV),
+    NAME_FUNC_OFFSET(11735, glVertexAttrib2svNV, glVertexAttrib2svNV, NULL, _gloffset_VertexAttrib2svNV),
+    NAME_FUNC_OFFSET(11755, glVertexAttrib3dNV, glVertexAttrib3dNV, NULL, _gloffset_VertexAttrib3dNV),
+    NAME_FUNC_OFFSET(11774, glVertexAttrib3dvNV, glVertexAttrib3dvNV, NULL, _gloffset_VertexAttrib3dvNV),
+    NAME_FUNC_OFFSET(11794, glVertexAttrib3fNV, glVertexAttrib3fNV, NULL, _gloffset_VertexAttrib3fNV),
+    NAME_FUNC_OFFSET(11813, glVertexAttrib3fvNV, glVertexAttrib3fvNV, NULL, _gloffset_VertexAttrib3fvNV),
+    NAME_FUNC_OFFSET(11833, glVertexAttrib3sNV, glVertexAttrib3sNV, NULL, _gloffset_VertexAttrib3sNV),
+    NAME_FUNC_OFFSET(11852, glVertexAttrib3svNV, glVertexAttrib3svNV, NULL, _gloffset_VertexAttrib3svNV),
+    NAME_FUNC_OFFSET(11872, glVertexAttrib4dNV, glVertexAttrib4dNV, NULL, _gloffset_VertexAttrib4dNV),
+    NAME_FUNC_OFFSET(11891, glVertexAttrib4dvNV, glVertexAttrib4dvNV, NULL, _gloffset_VertexAttrib4dvNV),
+    NAME_FUNC_OFFSET(11911, glVertexAttrib4fNV, glVertexAttrib4fNV, NULL, _gloffset_VertexAttrib4fNV),
+    NAME_FUNC_OFFSET(11930, glVertexAttrib4fvNV, glVertexAttrib4fvNV, NULL, _gloffset_VertexAttrib4fvNV),
+    NAME_FUNC_OFFSET(11950, glVertexAttrib4sNV, glVertexAttrib4sNV, NULL, _gloffset_VertexAttrib4sNV),
+    NAME_FUNC_OFFSET(11969, glVertexAttrib4svNV, glVertexAttrib4svNV, NULL, _gloffset_VertexAttrib4svNV),
+    NAME_FUNC_OFFSET(11989, glVertexAttrib4ubNV, glVertexAttrib4ubNV, NULL, _gloffset_VertexAttrib4ubNV),
+    NAME_FUNC_OFFSET(12009, glVertexAttrib4ubvNV, glVertexAttrib4ubvNV, NULL, _gloffset_VertexAttrib4ubvNV),
+    NAME_FUNC_OFFSET(12030, glVertexAttribPointerNV, glVertexAttribPointerNV, NULL, _gloffset_VertexAttribPointerNV),
+    NAME_FUNC_OFFSET(12054, glVertexAttribs1dvNV, glVertexAttribs1dvNV, NULL, _gloffset_VertexAttribs1dvNV),
+    NAME_FUNC_OFFSET(12075, glVertexAttribs1fvNV, glVertexAttribs1fvNV, NULL, _gloffset_VertexAttribs1fvNV),
+    NAME_FUNC_OFFSET(12096, glVertexAttribs1svNV, glVertexAttribs1svNV, NULL, _gloffset_VertexAttribs1svNV),
+    NAME_FUNC_OFFSET(12117, glVertexAttribs2dvNV, glVertexAttribs2dvNV, NULL, _gloffset_VertexAttribs2dvNV),
+    NAME_FUNC_OFFSET(12138, glVertexAttribs2fvNV, glVertexAttribs2fvNV, NULL, _gloffset_VertexAttribs2fvNV),
+    NAME_FUNC_OFFSET(12159, glVertexAttribs2svNV, glVertexAttribs2svNV, NULL, _gloffset_VertexAttribs2svNV),
+    NAME_FUNC_OFFSET(12180, glVertexAttribs3dvNV, glVertexAttribs3dvNV, NULL, _gloffset_VertexAttribs3dvNV),
+    NAME_FUNC_OFFSET(12201, glVertexAttribs3fvNV, glVertexAttribs3fvNV, NULL, _gloffset_VertexAttribs3fvNV),
+    NAME_FUNC_OFFSET(12222, glVertexAttribs3svNV, glVertexAttribs3svNV, NULL, _gloffset_VertexAttribs3svNV),
+    NAME_FUNC_OFFSET(12243, glVertexAttribs4dvNV, glVertexAttribs4dvNV, NULL, _gloffset_VertexAttribs4dvNV),
+    NAME_FUNC_OFFSET(12264, glVertexAttribs4fvNV, glVertexAttribs4fvNV, NULL, _gloffset_VertexAttribs4fvNV),
+    NAME_FUNC_OFFSET(12285, glVertexAttribs4svNV, glVertexAttribs4svNV, NULL, _gloffset_VertexAttribs4svNV),
+    NAME_FUNC_OFFSET(12306, glVertexAttribs4ubvNV, glVertexAttribs4ubvNV, NULL, _gloffset_VertexAttribs4ubvNV),
+    NAME_FUNC_OFFSET(12328, glGetTexBumpParameterfvATI, glGetTexBumpParameterfvATI, NULL, _gloffset_GetTexBumpParameterfvATI),
+    NAME_FUNC_OFFSET(12355, glGetTexBumpParameterivATI, glGetTexBumpParameterivATI, NULL, _gloffset_GetTexBumpParameterivATI),
+    NAME_FUNC_OFFSET(12382, glTexBumpParameterfvATI, glTexBumpParameterfvATI, NULL, _gloffset_TexBumpParameterfvATI),
+    NAME_FUNC_OFFSET(12406, glTexBumpParameterivATI, glTexBumpParameterivATI, NULL, _gloffset_TexBumpParameterivATI),
+    NAME_FUNC_OFFSET(12430, glAlphaFragmentOp1ATI, glAlphaFragmentOp1ATI, NULL, _gloffset_AlphaFragmentOp1ATI),
+    NAME_FUNC_OFFSET(12452, glAlphaFragmentOp2ATI, glAlphaFragmentOp2ATI, NULL, _gloffset_AlphaFragmentOp2ATI),
+    NAME_FUNC_OFFSET(12474, glAlphaFragmentOp3ATI, glAlphaFragmentOp3ATI, NULL, _gloffset_AlphaFragmentOp3ATI),
+    NAME_FUNC_OFFSET(12496, glBeginFragmentShaderATI, glBeginFragmentShaderATI, NULL, _gloffset_BeginFragmentShaderATI),
+    NAME_FUNC_OFFSET(12521, glBindFragmentShaderATI, glBindFragmentShaderATI, NULL, _gloffset_BindFragmentShaderATI),
+    NAME_FUNC_OFFSET(12545, glColorFragmentOp1ATI, glColorFragmentOp1ATI, NULL, _gloffset_ColorFragmentOp1ATI),
+    NAME_FUNC_OFFSET(12567, glColorFragmentOp2ATI, glColorFragmentOp2ATI, NULL, _gloffset_ColorFragmentOp2ATI),
+    NAME_FUNC_OFFSET(12589, glColorFragmentOp3ATI, glColorFragmentOp3ATI, NULL, _gloffset_ColorFragmentOp3ATI),
+    NAME_FUNC_OFFSET(12611, glDeleteFragmentShaderATI, glDeleteFragmentShaderATI, NULL, _gloffset_DeleteFragmentShaderATI),
+    NAME_FUNC_OFFSET(12637, glEndFragmentShaderATI, glEndFragmentShaderATI, NULL, _gloffset_EndFragmentShaderATI),
+    NAME_FUNC_OFFSET(12660, glGenFragmentShadersATI, glGenFragmentShadersATI, NULL, _gloffset_GenFragmentShadersATI),
+    NAME_FUNC_OFFSET(12684, glPassTexCoordATI, glPassTexCoordATI, NULL, _gloffset_PassTexCoordATI),
+    NAME_FUNC_OFFSET(12702, glSampleMapATI, glSampleMapATI, NULL, _gloffset_SampleMapATI),
+    NAME_FUNC_OFFSET(12717, glSetFragmentShaderConstantATI, glSetFragmentShaderConstantATI, NULL, _gloffset_SetFragmentShaderConstantATI),
+    NAME_FUNC_OFFSET(12748, glPointParameteriNV, glPointParameteriNV, NULL, _gloffset_PointParameteriNV),
+    NAME_FUNC_OFFSET(12768, glPointParameterivNV, glPointParameterivNV, NULL, _gloffset_PointParameterivNV),
+    NAME_FUNC_OFFSET(12789, gl_dispatch_stub_741, gl_dispatch_stub_741, NULL, _gloffset_ActiveStencilFaceEXT),
+    NAME_FUNC_OFFSET(12812, gl_dispatch_stub_742, gl_dispatch_stub_742, NULL, _gloffset_BindVertexArrayAPPLE),
+    NAME_FUNC_OFFSET(12835, gl_dispatch_stub_743, gl_dispatch_stub_743, NULL, _gloffset_DeleteVertexArraysAPPLE),
+    NAME_FUNC_OFFSET(12861, gl_dispatch_stub_744, gl_dispatch_stub_744, NULL, _gloffset_GenVertexArraysAPPLE),
+    NAME_FUNC_OFFSET(12884, gl_dispatch_stub_745, gl_dispatch_stub_745, NULL, _gloffset_IsVertexArrayAPPLE),
+    NAME_FUNC_OFFSET(12905, glGetProgramNamedParameterdvNV, glGetProgramNamedParameterdvNV, NULL, _gloffset_GetProgramNamedParameterdvNV),
+    NAME_FUNC_OFFSET(12936, glGetProgramNamedParameterfvNV, glGetProgramNamedParameterfvNV, NULL, _gloffset_GetProgramNamedParameterfvNV),
+    NAME_FUNC_OFFSET(12967, glProgramNamedParameter4dNV, glProgramNamedParameter4dNV, NULL, _gloffset_ProgramNamedParameter4dNV),
+    NAME_FUNC_OFFSET(12995, glProgramNamedParameter4dvNV, glProgramNamedParameter4dvNV, NULL, _gloffset_ProgramNamedParameter4dvNV),
+    NAME_FUNC_OFFSET(13024, glProgramNamedParameter4fNV, glProgramNamedParameter4fNV, NULL, _gloffset_ProgramNamedParameter4fNV),
+    NAME_FUNC_OFFSET(13052, glProgramNamedParameter4fvNV, glProgramNamedParameter4fvNV, NULL, _gloffset_ProgramNamedParameter4fvNV),
+    NAME_FUNC_OFFSET(13081, gl_dispatch_stub_752, gl_dispatch_stub_752, NULL, _gloffset_DepthBoundsEXT),
+    NAME_FUNC_OFFSET(13098, gl_dispatch_stub_753, gl_dispatch_stub_753, NULL, _gloffset_BlendEquationSeparateEXT),
+    NAME_FUNC_OFFSET(13125, glBindFramebufferEXT, glBindFramebufferEXT, NULL, _gloffset_BindFramebufferEXT),
+    NAME_FUNC_OFFSET(13146, glBindRenderbufferEXT, glBindRenderbufferEXT, NULL, _gloffset_BindRenderbufferEXT),
+    NAME_FUNC_OFFSET(13168, glCheckFramebufferStatusEXT, glCheckFramebufferStatusEXT, NULL, _gloffset_CheckFramebufferStatusEXT),
+    NAME_FUNC_OFFSET(13196, glDeleteFramebuffersEXT, glDeleteFramebuffersEXT, NULL, _gloffset_DeleteFramebuffersEXT),
+    NAME_FUNC_OFFSET(13220, glDeleteRenderbuffersEXT, glDeleteRenderbuffersEXT, NULL, _gloffset_DeleteRenderbuffersEXT),
+    NAME_FUNC_OFFSET(13245, glFramebufferRenderbufferEXT, glFramebufferRenderbufferEXT, NULL, _gloffset_FramebufferRenderbufferEXT),
+    NAME_FUNC_OFFSET(13274, glFramebufferTexture1DEXT, glFramebufferTexture1DEXT, NULL, _gloffset_FramebufferTexture1DEXT),
+    NAME_FUNC_OFFSET(13300, glFramebufferTexture2DEXT, glFramebufferTexture2DEXT, NULL, _gloffset_FramebufferTexture2DEXT),
+    NAME_FUNC_OFFSET(13326, glFramebufferTexture3DEXT, glFramebufferTexture3DEXT, NULL, _gloffset_FramebufferTexture3DEXT),
+    NAME_FUNC_OFFSET(13352, glGenFramebuffersEXT, glGenFramebuffersEXT, NULL, _gloffset_GenFramebuffersEXT),
+    NAME_FUNC_OFFSET(13373, glGenRenderbuffersEXT, glGenRenderbuffersEXT, NULL, _gloffset_GenRenderbuffersEXT),
+    NAME_FUNC_OFFSET(13395, glGenerateMipmapEXT, glGenerateMipmapEXT, NULL, _gloffset_GenerateMipmapEXT),
+    NAME_FUNC_OFFSET(13415, glGetFramebufferAttachmentParameterivEXT, glGetFramebufferAttachmentParameterivEXT, NULL, _gloffset_GetFramebufferAttachmentParameterivEXT),
+    NAME_FUNC_OFFSET(13456, glGetRenderbufferParameterivEXT, glGetRenderbufferParameterivEXT, NULL, _gloffset_GetRenderbufferParameterivEXT),
+    NAME_FUNC_OFFSET(13488, glIsFramebufferEXT, glIsFramebufferEXT, NULL, _gloffset_IsFramebufferEXT),
+    NAME_FUNC_OFFSET(13507, glIsRenderbufferEXT, glIsRenderbufferEXT, NULL, _gloffset_IsRenderbufferEXT),
+    NAME_FUNC_OFFSET(13527, glRenderbufferStorageEXT, glRenderbufferStorageEXT, NULL, _gloffset_RenderbufferStorageEXT),
+    NAME_FUNC_OFFSET(13552, gl_dispatch_stub_771, gl_dispatch_stub_771, NULL, _gloffset_BlitFramebufferEXT),
+    NAME_FUNC_OFFSET(13573, glFramebufferTextureLayerEXT, glFramebufferTextureLayerEXT, NULL, _gloffset_FramebufferTextureLayerEXT),
+    NAME_FUNC_OFFSET(13602, gl_dispatch_stub_773, gl_dispatch_stub_773, NULL, _gloffset_StencilFuncSeparateATI),
+    NAME_FUNC_OFFSET(13627, gl_dispatch_stub_774, gl_dispatch_stub_774, NULL, _gloffset_ProgramEnvParameters4fvEXT),
+    NAME_FUNC_OFFSET(13656, gl_dispatch_stub_775, gl_dispatch_stub_775, NULL, _gloffset_ProgramLocalParameters4fvEXT),
+    NAME_FUNC_OFFSET(13687, gl_dispatch_stub_776, gl_dispatch_stub_776, NULL, _gloffset_GetQueryObjecti64vEXT),
+    NAME_FUNC_OFFSET(13711, gl_dispatch_stub_777, gl_dispatch_stub_777, NULL, _gloffset_GetQueryObjectui64vEXT),
+    NAME_FUNC_OFFSET(13736, glArrayElement, glArrayElement, NULL, _gloffset_ArrayElement),
+    NAME_FUNC_OFFSET(13754, glBindTexture, glBindTexture, NULL, _gloffset_BindTexture),
+    NAME_FUNC_OFFSET(13771, glDrawArrays, glDrawArrays, NULL, _gloffset_DrawArrays),
+    NAME_FUNC_OFFSET(13787, glAreTexturesResident, glAreTexturesResidentEXT, glAreTexturesResidentEXT, _gloffset_AreTexturesResident),
+    NAME_FUNC_OFFSET(13812, glCopyTexImage1D, glCopyTexImage1D, NULL, _gloffset_CopyTexImage1D),
+    NAME_FUNC_OFFSET(13832, glCopyTexImage2D, glCopyTexImage2D, NULL, _gloffset_CopyTexImage2D),
+    NAME_FUNC_OFFSET(13852, glCopyTexSubImage1D, glCopyTexSubImage1D, NULL, _gloffset_CopyTexSubImage1D),
+    NAME_FUNC_OFFSET(13875, glCopyTexSubImage2D, glCopyTexSubImage2D, NULL, _gloffset_CopyTexSubImage2D),
+    NAME_FUNC_OFFSET(13898, glDeleteTextures, glDeleteTexturesEXT, glDeleteTexturesEXT, _gloffset_DeleteTextures),
+    NAME_FUNC_OFFSET(13918, glGenTextures, glGenTexturesEXT, glGenTexturesEXT, _gloffset_GenTextures),
+    NAME_FUNC_OFFSET(13935, glGetPointerv, glGetPointerv, NULL, _gloffset_GetPointerv),
+    NAME_FUNC_OFFSET(13952, glIsTexture, glIsTextureEXT, glIsTextureEXT, _gloffset_IsTexture),
+    NAME_FUNC_OFFSET(13967, glPrioritizeTextures, glPrioritizeTextures, NULL, _gloffset_PrioritizeTextures),
+    NAME_FUNC_OFFSET(13991, glTexSubImage1D, glTexSubImage1D, NULL, _gloffset_TexSubImage1D),
+    NAME_FUNC_OFFSET(14010, glTexSubImage2D, glTexSubImage2D, NULL, _gloffset_TexSubImage2D),
+    NAME_FUNC_OFFSET(14029, glBlendColor, glBlendColor, NULL, _gloffset_BlendColor),
+    NAME_FUNC_OFFSET(14045, glBlendEquation, glBlendEquation, NULL, _gloffset_BlendEquation),
+    NAME_FUNC_OFFSET(14064, glDrawRangeElements, glDrawRangeElements, NULL, _gloffset_DrawRangeElements),
+    NAME_FUNC_OFFSET(14087, glColorTable, glColorTable, NULL, _gloffset_ColorTable),
+    NAME_FUNC_OFFSET(14103, glColorTable, glColorTable, NULL, _gloffset_ColorTable),
+    NAME_FUNC_OFFSET(14119, glColorTableParameterfv, glColorTableParameterfv, NULL, _gloffset_ColorTableParameterfv),
+    NAME_FUNC_OFFSET(14146, glColorTableParameteriv, glColorTableParameteriv, NULL, _gloffset_ColorTableParameteriv),
+    NAME_FUNC_OFFSET(14173, glCopyColorTable, glCopyColorTable, NULL, _gloffset_CopyColorTable),
+    NAME_FUNC_OFFSET(14193, glGetColorTable, glGetColorTableEXT, glGetColorTableEXT, _gloffset_GetColorTable),
+    NAME_FUNC_OFFSET(14212, glGetColorTable, glGetColorTableEXT, glGetColorTableEXT, _gloffset_GetColorTable),
+    NAME_FUNC_OFFSET(14231, glGetColorTableParameterfv, glGetColorTableParameterfvEXT, glGetColorTableParameterfvEXT, _gloffset_GetColorTableParameterfv),
+    NAME_FUNC_OFFSET(14261, glGetColorTableParameterfv, glGetColorTableParameterfvEXT, glGetColorTableParameterfvEXT, _gloffset_GetColorTableParameterfv),
+    NAME_FUNC_OFFSET(14291, glGetColorTableParameteriv, glGetColorTableParameterivEXT, glGetColorTableParameterivEXT, _gloffset_GetColorTableParameteriv),
+    NAME_FUNC_OFFSET(14321, glGetColorTableParameteriv, glGetColorTableParameterivEXT, glGetColorTableParameterivEXT, _gloffset_GetColorTableParameteriv),
+    NAME_FUNC_OFFSET(14351, glColorSubTable, glColorSubTable, NULL, _gloffset_ColorSubTable),
+    NAME_FUNC_OFFSET(14370, glCopyColorSubTable, glCopyColorSubTable, NULL, _gloffset_CopyColorSubTable),
+    NAME_FUNC_OFFSET(14393, glConvolutionFilter1D, glConvolutionFilter1D, NULL, _gloffset_ConvolutionFilter1D),
+    NAME_FUNC_OFFSET(14418, glConvolutionFilter2D, glConvolutionFilter2D, NULL, _gloffset_ConvolutionFilter2D),
+    NAME_FUNC_OFFSET(14443, glConvolutionParameterf, glConvolutionParameterf, NULL, _gloffset_ConvolutionParameterf),
+    NAME_FUNC_OFFSET(14470, glConvolutionParameterfv, glConvolutionParameterfv, NULL, _gloffset_ConvolutionParameterfv),
+    NAME_FUNC_OFFSET(14498, glConvolutionParameteri, glConvolutionParameteri, NULL, _gloffset_ConvolutionParameteri),
+    NAME_FUNC_OFFSET(14525, glConvolutionParameteriv, glConvolutionParameteriv, NULL, _gloffset_ConvolutionParameteriv),
+    NAME_FUNC_OFFSET(14553, glCopyConvolutionFilter1D, glCopyConvolutionFilter1D, NULL, _gloffset_CopyConvolutionFilter1D),
+    NAME_FUNC_OFFSET(14582, glCopyConvolutionFilter2D, glCopyConvolutionFilter2D, NULL, _gloffset_CopyConvolutionFilter2D),
+    NAME_FUNC_OFFSET(14611, glGetConvolutionFilter, gl_dispatch_stub_356, gl_dispatch_stub_356, _gloffset_GetConvolutionFilter),
+    NAME_FUNC_OFFSET(14637, glGetConvolutionParameterfv, gl_dispatch_stub_357, gl_dispatch_stub_357, _gloffset_GetConvolutionParameterfv),
+    NAME_FUNC_OFFSET(14668, glGetConvolutionParameteriv, gl_dispatch_stub_358, gl_dispatch_stub_358, _gloffset_GetConvolutionParameteriv),
+    NAME_FUNC_OFFSET(14699, glGetSeparableFilter, gl_dispatch_stub_359, gl_dispatch_stub_359, _gloffset_GetSeparableFilter),
+    NAME_FUNC_OFFSET(14723, glSeparableFilter2D, glSeparableFilter2D, NULL, _gloffset_SeparableFilter2D),
+    NAME_FUNC_OFFSET(14746, glGetHistogram, gl_dispatch_stub_361, gl_dispatch_stub_361, _gloffset_GetHistogram),
+    NAME_FUNC_OFFSET(14764, glGetHistogramParameterfv, gl_dispatch_stub_362, gl_dispatch_stub_362, _gloffset_GetHistogramParameterfv),
+    NAME_FUNC_OFFSET(14793, glGetHistogramParameteriv, gl_dispatch_stub_363, gl_dispatch_stub_363, _gloffset_GetHistogramParameteriv),
+    NAME_FUNC_OFFSET(14822, glGetMinmax, gl_dispatch_stub_364, gl_dispatch_stub_364, _gloffset_GetMinmax),
+    NAME_FUNC_OFFSET(14837, glGetMinmaxParameterfv, gl_dispatch_stub_365, gl_dispatch_stub_365, _gloffset_GetMinmaxParameterfv),
+    NAME_FUNC_OFFSET(14863, glGetMinmaxParameteriv, gl_dispatch_stub_366, gl_dispatch_stub_366, _gloffset_GetMinmaxParameteriv),
+    NAME_FUNC_OFFSET(14889, glHistogram, glHistogram, NULL, _gloffset_Histogram),
+    NAME_FUNC_OFFSET(14904, glMinmax, glMinmax, NULL, _gloffset_Minmax),
+    NAME_FUNC_OFFSET(14916, glResetHistogram, glResetHistogram, NULL, _gloffset_ResetHistogram),
+    NAME_FUNC_OFFSET(14936, glResetMinmax, glResetMinmax, NULL, _gloffset_ResetMinmax),
+    NAME_FUNC_OFFSET(14953, glTexImage3D, glTexImage3D, NULL, _gloffset_TexImage3D),
+    NAME_FUNC_OFFSET(14969, glTexSubImage3D, glTexSubImage3D, NULL, _gloffset_TexSubImage3D),
+    NAME_FUNC_OFFSET(14988, glCopyTexSubImage3D, glCopyTexSubImage3D, NULL, _gloffset_CopyTexSubImage3D),
+    NAME_FUNC_OFFSET(15011, glActiveTextureARB, glActiveTextureARB, NULL, _gloffset_ActiveTextureARB),
+    NAME_FUNC_OFFSET(15027, glClientActiveTextureARB, glClientActiveTextureARB, NULL, _gloffset_ClientActiveTextureARB),
+    NAME_FUNC_OFFSET(15049, glMultiTexCoord1dARB, glMultiTexCoord1dARB, NULL, _gloffset_MultiTexCoord1dARB),
+    NAME_FUNC_OFFSET(15067, glMultiTexCoord1dvARB, glMultiTexCoord1dvARB, NULL, _gloffset_MultiTexCoord1dvARB),
+    NAME_FUNC_OFFSET(15086, glMultiTexCoord1fARB, glMultiTexCoord1fARB, NULL, _gloffset_MultiTexCoord1fARB),
+    NAME_FUNC_OFFSET(15104, glMultiTexCoord1fvARB, glMultiTexCoord1fvARB, NULL, _gloffset_MultiTexCoord1fvARB),
+    NAME_FUNC_OFFSET(15123, glMultiTexCoord1iARB, glMultiTexCoord1iARB, NULL, _gloffset_MultiTexCoord1iARB),
+    NAME_FUNC_OFFSET(15141, glMultiTexCoord1ivARB, glMultiTexCoord1ivARB, NULL, _gloffset_MultiTexCoord1ivARB),
+    NAME_FUNC_OFFSET(15160, glMultiTexCoord1sARB, glMultiTexCoord1sARB, NULL, _gloffset_MultiTexCoord1sARB),
+    NAME_FUNC_OFFSET(15178, glMultiTexCoord1svARB, glMultiTexCoord1svARB, NULL, _gloffset_MultiTexCoord1svARB),
+    NAME_FUNC_OFFSET(15197, glMultiTexCoord2dARB, glMultiTexCoord2dARB, NULL, _gloffset_MultiTexCoord2dARB),
+    NAME_FUNC_OFFSET(15215, glMultiTexCoord2dvARB, glMultiTexCoord2dvARB, NULL, _gloffset_MultiTexCoord2dvARB),
+    NAME_FUNC_OFFSET(15234, glMultiTexCoord2fARB, glMultiTexCoord2fARB, NULL, _gloffset_MultiTexCoord2fARB),
+    NAME_FUNC_OFFSET(15252, glMultiTexCoord2fvARB, glMultiTexCoord2fvARB, NULL, _gloffset_MultiTexCoord2fvARB),
+    NAME_FUNC_OFFSET(15271, glMultiTexCoord2iARB, glMultiTexCoord2iARB, NULL, _gloffset_MultiTexCoord2iARB),
+    NAME_FUNC_OFFSET(15289, glMultiTexCoord2ivARB, glMultiTexCoord2ivARB, NULL, _gloffset_MultiTexCoord2ivARB),
+    NAME_FUNC_OFFSET(15308, glMultiTexCoord2sARB, glMultiTexCoord2sARB, NULL, _gloffset_MultiTexCoord2sARB),
+    NAME_FUNC_OFFSET(15326, glMultiTexCoord2svARB, glMultiTexCoord2svARB, NULL, _gloffset_MultiTexCoord2svARB),
+    NAME_FUNC_OFFSET(15345, glMultiTexCoord3dARB, glMultiTexCoord3dARB, NULL, _gloffset_MultiTexCoord3dARB),
+    NAME_FUNC_OFFSET(15363, glMultiTexCoord3dvARB, glMultiTexCoord3dvARB, NULL, _gloffset_MultiTexCoord3dvARB),
+    NAME_FUNC_OFFSET(15382, glMultiTexCoord3fARB, glMultiTexCoord3fARB, NULL, _gloffset_MultiTexCoord3fARB),
+    NAME_FUNC_OFFSET(15400, glMultiTexCoord3fvARB, glMultiTexCoord3fvARB, NULL, _gloffset_MultiTexCoord3fvARB),
+    NAME_FUNC_OFFSET(15419, glMultiTexCoord3iARB, glMultiTexCoord3iARB, NULL, _gloffset_MultiTexCoord3iARB),
+    NAME_FUNC_OFFSET(15437, glMultiTexCoord3ivARB, glMultiTexCoord3ivARB, NULL, _gloffset_MultiTexCoord3ivARB),
+    NAME_FUNC_OFFSET(15456, glMultiTexCoord3sARB, glMultiTexCoord3sARB, NULL, _gloffset_MultiTexCoord3sARB),
+    NAME_FUNC_OFFSET(15474, glMultiTexCoord3svARB, glMultiTexCoord3svARB, NULL, _gloffset_MultiTexCoord3svARB),
+    NAME_FUNC_OFFSET(15493, glMultiTexCoord4dARB, glMultiTexCoord4dARB, NULL, _gloffset_MultiTexCoord4dARB),
+    NAME_FUNC_OFFSET(15511, glMultiTexCoord4dvARB, glMultiTexCoord4dvARB, NULL, _gloffset_MultiTexCoord4dvARB),
+    NAME_FUNC_OFFSET(15530, glMultiTexCoord4fARB, glMultiTexCoord4fARB, NULL, _gloffset_MultiTexCoord4fARB),
+    NAME_FUNC_OFFSET(15548, glMultiTexCoord4fvARB, glMultiTexCoord4fvARB, NULL, _gloffset_MultiTexCoord4fvARB),
+    NAME_FUNC_OFFSET(15567, glMultiTexCoord4iARB, glMultiTexCoord4iARB, NULL, _gloffset_MultiTexCoord4iARB),
+    NAME_FUNC_OFFSET(15585, glMultiTexCoord4ivARB, glMultiTexCoord4ivARB, NULL, _gloffset_MultiTexCoord4ivARB),
+    NAME_FUNC_OFFSET(15604, glMultiTexCoord4sARB, glMultiTexCoord4sARB, NULL, _gloffset_MultiTexCoord4sARB),
+    NAME_FUNC_OFFSET(15622, glMultiTexCoord4svARB, glMultiTexCoord4svARB, NULL, _gloffset_MultiTexCoord4svARB),
+    NAME_FUNC_OFFSET(15641, glStencilOpSeparate, glStencilOpSeparate, NULL, _gloffset_StencilOpSeparate),
+    NAME_FUNC_OFFSET(15664, glLoadTransposeMatrixdARB, glLoadTransposeMatrixdARB, NULL, _gloffset_LoadTransposeMatrixdARB),
+    NAME_FUNC_OFFSET(15687, glLoadTransposeMatrixfARB, glLoadTransposeMatrixfARB, NULL, _gloffset_LoadTransposeMatrixfARB),
+    NAME_FUNC_OFFSET(15710, glMultTransposeMatrixdARB, glMultTransposeMatrixdARB, NULL, _gloffset_MultTransposeMatrixdARB),
+    NAME_FUNC_OFFSET(15733, glMultTransposeMatrixfARB, glMultTransposeMatrixfARB, NULL, _gloffset_MultTransposeMatrixfARB),
+    NAME_FUNC_OFFSET(15756, glSampleCoverageARB, glSampleCoverageARB, NULL, _gloffset_SampleCoverageARB),
+    NAME_FUNC_OFFSET(15773, glCompressedTexImage1DARB, glCompressedTexImage1DARB, NULL, _gloffset_CompressedTexImage1DARB),
+    NAME_FUNC_OFFSET(15796, glCompressedTexImage2DARB, glCompressedTexImage2DARB, NULL, _gloffset_CompressedTexImage2DARB),
+    NAME_FUNC_OFFSET(15819, glCompressedTexImage3DARB, glCompressedTexImage3DARB, NULL, _gloffset_CompressedTexImage3DARB),
+    NAME_FUNC_OFFSET(15842, glCompressedTexSubImage1DARB, glCompressedTexSubImage1DARB, NULL, _gloffset_CompressedTexSubImage1DARB),
+    NAME_FUNC_OFFSET(15868, glCompressedTexSubImage2DARB, glCompressedTexSubImage2DARB, NULL, _gloffset_CompressedTexSubImage2DARB),
+    NAME_FUNC_OFFSET(15894, glCompressedTexSubImage3DARB, glCompressedTexSubImage3DARB, NULL, _gloffset_CompressedTexSubImage3DARB),
+    NAME_FUNC_OFFSET(15920, glGetCompressedTexImageARB, glGetCompressedTexImageARB, NULL, _gloffset_GetCompressedTexImageARB),
+    NAME_FUNC_OFFSET(15944, glDisableVertexAttribArrayARB, glDisableVertexAttribArrayARB, NULL, _gloffset_DisableVertexAttribArrayARB),
+    NAME_FUNC_OFFSET(15971, glEnableVertexAttribArrayARB, glEnableVertexAttribArrayARB, NULL, _gloffset_EnableVertexAttribArrayARB),
+    NAME_FUNC_OFFSET(15997, glGetVertexAttribdvARB, glGetVertexAttribdvARB, NULL, _gloffset_GetVertexAttribdvARB),
+    NAME_FUNC_OFFSET(16017, glGetVertexAttribfvARB, glGetVertexAttribfvARB, NULL, _gloffset_GetVertexAttribfvARB),
+    NAME_FUNC_OFFSET(16037, glGetVertexAttribivARB, glGetVertexAttribivARB, NULL, _gloffset_GetVertexAttribivARB),
+    NAME_FUNC_OFFSET(16057, glProgramEnvParameter4dARB, glProgramEnvParameter4dARB, NULL, _gloffset_ProgramEnvParameter4dARB),
+    NAME_FUNC_OFFSET(16080, glProgramEnvParameter4dvARB, glProgramEnvParameter4dvARB, NULL, _gloffset_ProgramEnvParameter4dvARB),
+    NAME_FUNC_OFFSET(16104, glProgramEnvParameter4fARB, glProgramEnvParameter4fARB, NULL, _gloffset_ProgramEnvParameter4fARB),
+    NAME_FUNC_OFFSET(16127, glProgramEnvParameter4fvARB, glProgramEnvParameter4fvARB, NULL, _gloffset_ProgramEnvParameter4fvARB),
+    NAME_FUNC_OFFSET(16151, glVertexAttrib1dARB, glVertexAttrib1dARB, NULL, _gloffset_VertexAttrib1dARB),
+    NAME_FUNC_OFFSET(16168, glVertexAttrib1dvARB, glVertexAttrib1dvARB, NULL, _gloffset_VertexAttrib1dvARB),
+    NAME_FUNC_OFFSET(16186, glVertexAttrib1fARB, glVertexAttrib1fARB, NULL, _gloffset_VertexAttrib1fARB),
+    NAME_FUNC_OFFSET(16203, glVertexAttrib1fvARB, glVertexAttrib1fvARB, NULL, _gloffset_VertexAttrib1fvARB),
+    NAME_FUNC_OFFSET(16221, glVertexAttrib1sARB, glVertexAttrib1sARB, NULL, _gloffset_VertexAttrib1sARB),
+    NAME_FUNC_OFFSET(16238, glVertexAttrib1svARB, glVertexAttrib1svARB, NULL, _gloffset_VertexAttrib1svARB),
+    NAME_FUNC_OFFSET(16256, glVertexAttrib2dARB, glVertexAttrib2dARB, NULL, _gloffset_VertexAttrib2dARB),
+    NAME_FUNC_OFFSET(16273, glVertexAttrib2dvARB, glVertexAttrib2dvARB, NULL, _gloffset_VertexAttrib2dvARB),
+    NAME_FUNC_OFFSET(16291, glVertexAttrib2fARB, glVertexAttrib2fARB, NULL, _gloffset_VertexAttrib2fARB),
+    NAME_FUNC_OFFSET(16308, glVertexAttrib2fvARB, glVertexAttrib2fvARB, NULL, _gloffset_VertexAttrib2fvARB),
+    NAME_FUNC_OFFSET(16326, glVertexAttrib2sARB, glVertexAttrib2sARB, NULL, _gloffset_VertexAttrib2sARB),
+    NAME_FUNC_OFFSET(16343, glVertexAttrib2svARB, glVertexAttrib2svARB, NULL, _gloffset_VertexAttrib2svARB),
+    NAME_FUNC_OFFSET(16361, glVertexAttrib3dARB, glVertexAttrib3dARB, NULL, _gloffset_VertexAttrib3dARB),
+    NAME_FUNC_OFFSET(16378, glVertexAttrib3dvARB, glVertexAttrib3dvARB, NULL, _gloffset_VertexAttrib3dvARB),
+    NAME_FUNC_OFFSET(16396, glVertexAttrib3fARB, glVertexAttrib3fARB, NULL, _gloffset_VertexAttrib3fARB),
+    NAME_FUNC_OFFSET(16413, glVertexAttrib3fvARB, glVertexAttrib3fvARB, NULL, _gloffset_VertexAttrib3fvARB),
+    NAME_FUNC_OFFSET(16431, glVertexAttrib3sARB, glVertexAttrib3sARB, NULL, _gloffset_VertexAttrib3sARB),
+    NAME_FUNC_OFFSET(16448, glVertexAttrib3svARB, glVertexAttrib3svARB, NULL, _gloffset_VertexAttrib3svARB),
+    NAME_FUNC_OFFSET(16466, glVertexAttrib4NbvARB, glVertexAttrib4NbvARB, NULL, _gloffset_VertexAttrib4NbvARB),
+    NAME_FUNC_OFFSET(16485, glVertexAttrib4NivARB, glVertexAttrib4NivARB, NULL, _gloffset_VertexAttrib4NivARB),
+    NAME_FUNC_OFFSET(16504, glVertexAttrib4NsvARB, glVertexAttrib4NsvARB, NULL, _gloffset_VertexAttrib4NsvARB),
+    NAME_FUNC_OFFSET(16523, glVertexAttrib4NubARB, glVertexAttrib4NubARB, NULL, _gloffset_VertexAttrib4NubARB),
+    NAME_FUNC_OFFSET(16542, glVertexAttrib4NubvARB, glVertexAttrib4NubvARB, NULL, _gloffset_VertexAttrib4NubvARB),
+    NAME_FUNC_OFFSET(16562, glVertexAttrib4NuivARB, glVertexAttrib4NuivARB, NULL, _gloffset_VertexAttrib4NuivARB),
+    NAME_FUNC_OFFSET(16582, glVertexAttrib4NusvARB, glVertexAttrib4NusvARB, NULL, _gloffset_VertexAttrib4NusvARB),
+    NAME_FUNC_OFFSET(16602, glVertexAttrib4bvARB, glVertexAttrib4bvARB, NULL, _gloffset_VertexAttrib4bvARB),
+    NAME_FUNC_OFFSET(16620, glVertexAttrib4dARB, glVertexAttrib4dARB, NULL, _gloffset_VertexAttrib4dARB),
+    NAME_FUNC_OFFSET(16637, glVertexAttrib4dvARB, glVertexAttrib4dvARB, NULL, _gloffset_VertexAttrib4dvARB),
+    NAME_FUNC_OFFSET(16655, glVertexAttrib4fARB, glVertexAttrib4fARB, NULL, _gloffset_VertexAttrib4fARB),
+    NAME_FUNC_OFFSET(16672, glVertexAttrib4fvARB, glVertexAttrib4fvARB, NULL, _gloffset_VertexAttrib4fvARB),
+    NAME_FUNC_OFFSET(16690, glVertexAttrib4ivARB, glVertexAttrib4ivARB, NULL, _gloffset_VertexAttrib4ivARB),
+    NAME_FUNC_OFFSET(16708, glVertexAttrib4sARB, glVertexAttrib4sARB, NULL, _gloffset_VertexAttrib4sARB),
+    NAME_FUNC_OFFSET(16725, glVertexAttrib4svARB, glVertexAttrib4svARB, NULL, _gloffset_VertexAttrib4svARB),
+    NAME_FUNC_OFFSET(16743, glVertexAttrib4ubvARB, glVertexAttrib4ubvARB, NULL, _gloffset_VertexAttrib4ubvARB),
+    NAME_FUNC_OFFSET(16762, glVertexAttrib4uivARB, glVertexAttrib4uivARB, NULL, _gloffset_VertexAttrib4uivARB),
+    NAME_FUNC_OFFSET(16781, glVertexAttrib4usvARB, glVertexAttrib4usvARB, NULL, _gloffset_VertexAttrib4usvARB),
+    NAME_FUNC_OFFSET(16800, glVertexAttribPointerARB, glVertexAttribPointerARB, NULL, _gloffset_VertexAttribPointerARB),
+    NAME_FUNC_OFFSET(16822, glBindBufferARB, glBindBufferARB, NULL, _gloffset_BindBufferARB),
+    NAME_FUNC_OFFSET(16835, glBufferDataARB, glBufferDataARB, NULL, _gloffset_BufferDataARB),
+    NAME_FUNC_OFFSET(16848, glBufferSubDataARB, glBufferSubDataARB, NULL, _gloffset_BufferSubDataARB),
+    NAME_FUNC_OFFSET(16864, glDeleteBuffersARB, glDeleteBuffersARB, NULL, _gloffset_DeleteBuffersARB),
+    NAME_FUNC_OFFSET(16880, glGenBuffersARB, glGenBuffersARB, NULL, _gloffset_GenBuffersARB),
+    NAME_FUNC_OFFSET(16893, glGetBufferParameterivARB, glGetBufferParameterivARB, NULL, _gloffset_GetBufferParameterivARB),
+    NAME_FUNC_OFFSET(16916, glGetBufferPointervARB, glGetBufferPointervARB, NULL, _gloffset_GetBufferPointervARB),
+    NAME_FUNC_OFFSET(16936, glGetBufferSubDataARB, glGetBufferSubDataARB, NULL, _gloffset_GetBufferSubDataARB),
+    NAME_FUNC_OFFSET(16955, glIsBufferARB, glIsBufferARB, NULL, _gloffset_IsBufferARB),
+    NAME_FUNC_OFFSET(16966, glMapBufferARB, glMapBufferARB, NULL, _gloffset_MapBufferARB),
+    NAME_FUNC_OFFSET(16978, glUnmapBufferARB, glUnmapBufferARB, NULL, _gloffset_UnmapBufferARB),
+    NAME_FUNC_OFFSET(16992, glBeginQueryARB, glBeginQueryARB, NULL, _gloffset_BeginQueryARB),
+    NAME_FUNC_OFFSET(17005, glDeleteQueriesARB, glDeleteQueriesARB, NULL, _gloffset_DeleteQueriesARB),
+    NAME_FUNC_OFFSET(17021, glEndQueryARB, glEndQueryARB, NULL, _gloffset_EndQueryARB),
+    NAME_FUNC_OFFSET(17032, glGenQueriesARB, glGenQueriesARB, NULL, _gloffset_GenQueriesARB),
+    NAME_FUNC_OFFSET(17045, glGetQueryObjectivARB, glGetQueryObjectivARB, NULL, _gloffset_GetQueryObjectivARB),
+    NAME_FUNC_OFFSET(17064, glGetQueryObjectuivARB, glGetQueryObjectuivARB, NULL, _gloffset_GetQueryObjectuivARB),
+    NAME_FUNC_OFFSET(17084, glGetQueryivARB, glGetQueryivARB, NULL, _gloffset_GetQueryivARB),
+    NAME_FUNC_OFFSET(17097, glIsQueryARB, glIsQueryARB, NULL, _gloffset_IsQueryARB),
+    NAME_FUNC_OFFSET(17107, glCompileShaderARB, glCompileShaderARB, NULL, _gloffset_CompileShaderARB),
+    NAME_FUNC_OFFSET(17123, glGetActiveUniformARB, glGetActiveUniformARB, NULL, _gloffset_GetActiveUniformARB),
+    NAME_FUNC_OFFSET(17142, glGetShaderSourceARB, glGetShaderSourceARB, NULL, _gloffset_GetShaderSourceARB),
+    NAME_FUNC_OFFSET(17160, glGetUniformLocationARB, glGetUniformLocationARB, NULL, _gloffset_GetUniformLocationARB),
+    NAME_FUNC_OFFSET(17181, glGetUniformfvARB, glGetUniformfvARB, NULL, _gloffset_GetUniformfvARB),
+    NAME_FUNC_OFFSET(17196, glGetUniformivARB, glGetUniformivARB, NULL, _gloffset_GetUniformivARB),
+    NAME_FUNC_OFFSET(17211, glLinkProgramARB, glLinkProgramARB, NULL, _gloffset_LinkProgramARB),
+    NAME_FUNC_OFFSET(17225, glShaderSourceARB, glShaderSourceARB, NULL, _gloffset_ShaderSourceARB),
+    NAME_FUNC_OFFSET(17240, glUniform1fARB, glUniform1fARB, NULL, _gloffset_Uniform1fARB),
+    NAME_FUNC_OFFSET(17252, glUniform1fvARB, glUniform1fvARB, NULL, _gloffset_Uniform1fvARB),
+    NAME_FUNC_OFFSET(17265, glUniform1iARB, glUniform1iARB, NULL, _gloffset_Uniform1iARB),
+    NAME_FUNC_OFFSET(17277, glUniform1ivARB, glUniform1ivARB, NULL, _gloffset_Uniform1ivARB),
+    NAME_FUNC_OFFSET(17290, glUniform2fARB, glUniform2fARB, NULL, _gloffset_Uniform2fARB),
+    NAME_FUNC_OFFSET(17302, glUniform2fvARB, glUniform2fvARB, NULL, _gloffset_Uniform2fvARB),
+    NAME_FUNC_OFFSET(17315, glUniform2iARB, glUniform2iARB, NULL, _gloffset_Uniform2iARB),
+    NAME_FUNC_OFFSET(17327, glUniform2ivARB, glUniform2ivARB, NULL, _gloffset_Uniform2ivARB),
+    NAME_FUNC_OFFSET(17340, glUniform3fARB, glUniform3fARB, NULL, _gloffset_Uniform3fARB),
+    NAME_FUNC_OFFSET(17352, glUniform3fvARB, glUniform3fvARB, NULL, _gloffset_Uniform3fvARB),
+    NAME_FUNC_OFFSET(17365, glUniform3iARB, glUniform3iARB, NULL, _gloffset_Uniform3iARB),
+    NAME_FUNC_OFFSET(17377, glUniform3ivARB, glUniform3ivARB, NULL, _gloffset_Uniform3ivARB),
+    NAME_FUNC_OFFSET(17390, glUniform4fARB, glUniform4fARB, NULL, _gloffset_Uniform4fARB),
+    NAME_FUNC_OFFSET(17402, glUniform4fvARB, glUniform4fvARB, NULL, _gloffset_Uniform4fvARB),
+    NAME_FUNC_OFFSET(17415, glUniform4iARB, glUniform4iARB, NULL, _gloffset_Uniform4iARB),
+    NAME_FUNC_OFFSET(17427, glUniform4ivARB, glUniform4ivARB, NULL, _gloffset_Uniform4ivARB),
+    NAME_FUNC_OFFSET(17440, glUniformMatrix2fvARB, glUniformMatrix2fvARB, NULL, _gloffset_UniformMatrix2fvARB),
+    NAME_FUNC_OFFSET(17459, glUniformMatrix3fvARB, glUniformMatrix3fvARB, NULL, _gloffset_UniformMatrix3fvARB),
+    NAME_FUNC_OFFSET(17478, glUniformMatrix4fvARB, glUniformMatrix4fvARB, NULL, _gloffset_UniformMatrix4fvARB),
+    NAME_FUNC_OFFSET(17497, glUseProgramObjectARB, glUseProgramObjectARB, NULL, _gloffset_UseProgramObjectARB),
+    NAME_FUNC_OFFSET(17510, glValidateProgramARB, glValidateProgramARB, NULL, _gloffset_ValidateProgramARB),
+    NAME_FUNC_OFFSET(17528, glBindAttribLocationARB, glBindAttribLocationARB, NULL, _gloffset_BindAttribLocationARB),
+    NAME_FUNC_OFFSET(17549, glGetActiveAttribARB, glGetActiveAttribARB, NULL, _gloffset_GetActiveAttribARB),
+    NAME_FUNC_OFFSET(17567, glGetAttribLocationARB, glGetAttribLocationARB, NULL, _gloffset_GetAttribLocationARB),
+    NAME_FUNC_OFFSET(17587, glDrawBuffersARB, glDrawBuffersARB, NULL, _gloffset_DrawBuffersARB),
+    NAME_FUNC_OFFSET(17601, glDrawBuffersARB, glDrawBuffersARB, NULL, _gloffset_DrawBuffersARB),
+    NAME_FUNC_OFFSET(17618, gl_dispatch_stub_572, gl_dispatch_stub_572, NULL, _gloffset_SampleMaskSGIS),
+    NAME_FUNC_OFFSET(17634, gl_dispatch_stub_573, gl_dispatch_stub_573, NULL, _gloffset_SamplePatternSGIS),
+    NAME_FUNC_OFFSET(17653, glPointParameterfEXT, glPointParameterfEXT, NULL, _gloffset_PointParameterfEXT),
+    NAME_FUNC_OFFSET(17671, glPointParameterfEXT, glPointParameterfEXT, NULL, _gloffset_PointParameterfEXT),
+    NAME_FUNC_OFFSET(17692, glPointParameterfEXT, glPointParameterfEXT, NULL, _gloffset_PointParameterfEXT),
+    NAME_FUNC_OFFSET(17714, glPointParameterfvEXT, glPointParameterfvEXT, NULL, _gloffset_PointParameterfvEXT),
+    NAME_FUNC_OFFSET(17733, glPointParameterfvEXT, glPointParameterfvEXT, NULL, _gloffset_PointParameterfvEXT),
+    NAME_FUNC_OFFSET(17755, glPointParameterfvEXT, glPointParameterfvEXT, NULL, _gloffset_PointParameterfvEXT),
+    NAME_FUNC_OFFSET(17778, glSecondaryColor3bEXT, glSecondaryColor3bEXT, NULL, _gloffset_SecondaryColor3bEXT),
+    NAME_FUNC_OFFSET(17797, glSecondaryColor3bvEXT, glSecondaryColor3bvEXT, NULL, _gloffset_SecondaryColor3bvEXT),
+    NAME_FUNC_OFFSET(17817, glSecondaryColor3dEXT, glSecondaryColor3dEXT, NULL, _gloffset_SecondaryColor3dEXT),
+    NAME_FUNC_OFFSET(17836, glSecondaryColor3dvEXT, glSecondaryColor3dvEXT, NULL, _gloffset_SecondaryColor3dvEXT),
+    NAME_FUNC_OFFSET(17856, glSecondaryColor3fEXT, glSecondaryColor3fEXT, NULL, _gloffset_SecondaryColor3fEXT),
+    NAME_FUNC_OFFSET(17875, glSecondaryColor3fvEXT, glSecondaryColor3fvEXT, NULL, _gloffset_SecondaryColor3fvEXT),
+    NAME_FUNC_OFFSET(17895, glSecondaryColor3iEXT, glSecondaryColor3iEXT, NULL, _gloffset_SecondaryColor3iEXT),
+    NAME_FUNC_OFFSET(17914, glSecondaryColor3ivEXT, glSecondaryColor3ivEXT, NULL, _gloffset_SecondaryColor3ivEXT),
+    NAME_FUNC_OFFSET(17934, glSecondaryColor3sEXT, glSecondaryColor3sEXT, NULL, _gloffset_SecondaryColor3sEXT),
+    NAME_FUNC_OFFSET(17953, glSecondaryColor3svEXT, glSecondaryColor3svEXT, NULL, _gloffset_SecondaryColor3svEXT),
+    NAME_FUNC_OFFSET(17973, glSecondaryColor3ubEXT, glSecondaryColor3ubEXT, NULL, _gloffset_SecondaryColor3ubEXT),
+    NAME_FUNC_OFFSET(17993, glSecondaryColor3ubvEXT, glSecondaryColor3ubvEXT, NULL, _gloffset_SecondaryColor3ubvEXT),
+    NAME_FUNC_OFFSET(18014, glSecondaryColor3uiEXT, glSecondaryColor3uiEXT, NULL, _gloffset_SecondaryColor3uiEXT),
+    NAME_FUNC_OFFSET(18034, glSecondaryColor3uivEXT, glSecondaryColor3uivEXT, NULL, _gloffset_SecondaryColor3uivEXT),
+    NAME_FUNC_OFFSET(18055, glSecondaryColor3usEXT, glSecondaryColor3usEXT, NULL, _gloffset_SecondaryColor3usEXT),
+    NAME_FUNC_OFFSET(18075, glSecondaryColor3usvEXT, glSecondaryColor3usvEXT, NULL, _gloffset_SecondaryColor3usvEXT),
+    NAME_FUNC_OFFSET(18096, glSecondaryColorPointerEXT, glSecondaryColorPointerEXT, NULL, _gloffset_SecondaryColorPointerEXT),
+    NAME_FUNC_OFFSET(18120, glMultiDrawArraysEXT, glMultiDrawArraysEXT, NULL, _gloffset_MultiDrawArraysEXT),
+    NAME_FUNC_OFFSET(18138, glMultiDrawElementsEXT, glMultiDrawElementsEXT, NULL, _gloffset_MultiDrawElementsEXT),
+    NAME_FUNC_OFFSET(18158, glFogCoordPointerEXT, glFogCoordPointerEXT, NULL, _gloffset_FogCoordPointerEXT),
+    NAME_FUNC_OFFSET(18176, glFogCoorddEXT, glFogCoorddEXT, NULL, _gloffset_FogCoorddEXT),
+    NAME_FUNC_OFFSET(18188, glFogCoorddvEXT, glFogCoorddvEXT, NULL, _gloffset_FogCoorddvEXT),
+    NAME_FUNC_OFFSET(18201, glFogCoordfEXT, glFogCoordfEXT, NULL, _gloffset_FogCoordfEXT),
+    NAME_FUNC_OFFSET(18213, glFogCoordfvEXT, glFogCoordfvEXT, NULL, _gloffset_FogCoordfvEXT),
+    NAME_FUNC_OFFSET(18226, glBlendFuncSeparateEXT, glBlendFuncSeparateEXT, NULL, _gloffset_BlendFuncSeparateEXT),
+    NAME_FUNC_OFFSET(18246, glBlendFuncSeparateEXT, glBlendFuncSeparateEXT, NULL, _gloffset_BlendFuncSeparateEXT),
+    NAME_FUNC_OFFSET(18270, glWindowPos2dMESA, glWindowPos2dMESA, NULL, _gloffset_WindowPos2dMESA),
+    NAME_FUNC_OFFSET(18284, glWindowPos2dMESA, glWindowPos2dMESA, NULL, _gloffset_WindowPos2dMESA),
+    NAME_FUNC_OFFSET(18301, glWindowPos2dvMESA, glWindowPos2dvMESA, NULL, _gloffset_WindowPos2dvMESA),
+    NAME_FUNC_OFFSET(18316, glWindowPos2dvMESA, glWindowPos2dvMESA, NULL, _gloffset_WindowPos2dvMESA),
+    NAME_FUNC_OFFSET(18334, glWindowPos2fMESA, glWindowPos2fMESA, NULL, _gloffset_WindowPos2fMESA),
+    NAME_FUNC_OFFSET(18348, glWindowPos2fMESA, glWindowPos2fMESA, NULL, _gloffset_WindowPos2fMESA),
+    NAME_FUNC_OFFSET(18365, glWindowPos2fvMESA, glWindowPos2fvMESA, NULL, _gloffset_WindowPos2fvMESA),
+    NAME_FUNC_OFFSET(18380, glWindowPos2fvMESA, glWindowPos2fvMESA, NULL, _gloffset_WindowPos2fvMESA),
+    NAME_FUNC_OFFSET(18398, glWindowPos2iMESA, glWindowPos2iMESA, NULL, _gloffset_WindowPos2iMESA),
+    NAME_FUNC_OFFSET(18412, glWindowPos2iMESA, glWindowPos2iMESA, NULL, _gloffset_WindowPos2iMESA),
+    NAME_FUNC_OFFSET(18429, glWindowPos2ivMESA, glWindowPos2ivMESA, NULL, _gloffset_WindowPos2ivMESA),
+    NAME_FUNC_OFFSET(18444, glWindowPos2ivMESA, glWindowPos2ivMESA, NULL, _gloffset_WindowPos2ivMESA),
+    NAME_FUNC_OFFSET(18462, glWindowPos2sMESA, glWindowPos2sMESA, NULL, _gloffset_WindowPos2sMESA),
+    NAME_FUNC_OFFSET(18476, glWindowPos2sMESA, glWindowPos2sMESA, NULL, _gloffset_WindowPos2sMESA),
+    NAME_FUNC_OFFSET(18493, glWindowPos2svMESA, glWindowPos2svMESA, NULL, _gloffset_WindowPos2svMESA),
+    NAME_FUNC_OFFSET(18508, glWindowPos2svMESA, glWindowPos2svMESA, NULL, _gloffset_WindowPos2svMESA),
+    NAME_FUNC_OFFSET(18526, glWindowPos3dMESA, glWindowPos3dMESA, NULL, _gloffset_WindowPos3dMESA),
+    NAME_FUNC_OFFSET(18540, glWindowPos3dMESA, glWindowPos3dMESA, NULL, _gloffset_WindowPos3dMESA),
+    NAME_FUNC_OFFSET(18557, glWindowPos3dvMESA, glWindowPos3dvMESA, NULL, _gloffset_WindowPos3dvMESA),
+    NAME_FUNC_OFFSET(18572, glWindowPos3dvMESA, glWindowPos3dvMESA, NULL, _gloffset_WindowPos3dvMESA),
+    NAME_FUNC_OFFSET(18590, glWindowPos3fMESA, glWindowPos3fMESA, NULL, _gloffset_WindowPos3fMESA),
+    NAME_FUNC_OFFSET(18604, glWindowPos3fMESA, glWindowPos3fMESA, NULL, _gloffset_WindowPos3fMESA),
+    NAME_FUNC_OFFSET(18621, glWindowPos3fvMESA, glWindowPos3fvMESA, NULL, _gloffset_WindowPos3fvMESA),
+    NAME_FUNC_OFFSET(18636, glWindowPos3fvMESA, glWindowPos3fvMESA, NULL, _gloffset_WindowPos3fvMESA),
+    NAME_FUNC_OFFSET(18654, glWindowPos3iMESA, glWindowPos3iMESA, NULL, _gloffset_WindowPos3iMESA),
+    NAME_FUNC_OFFSET(18668, glWindowPos3iMESA, glWindowPos3iMESA, NULL, _gloffset_WindowPos3iMESA),
+    NAME_FUNC_OFFSET(18685, glWindowPos3ivMESA, glWindowPos3ivMESA, NULL, _gloffset_WindowPos3ivMESA),
+    NAME_FUNC_OFFSET(18700, glWindowPos3ivMESA, glWindowPos3ivMESA, NULL, _gloffset_WindowPos3ivMESA),
+    NAME_FUNC_OFFSET(18718, glWindowPos3sMESA, glWindowPos3sMESA, NULL, _gloffset_WindowPos3sMESA),
+    NAME_FUNC_OFFSET(18732, glWindowPos3sMESA, glWindowPos3sMESA, NULL, _gloffset_WindowPos3sMESA),
+    NAME_FUNC_OFFSET(18749, glWindowPos3svMESA, glWindowPos3svMESA, NULL, _gloffset_WindowPos3svMESA),
+    NAME_FUNC_OFFSET(18764, glWindowPos3svMESA, glWindowPos3svMESA, NULL, _gloffset_WindowPos3svMESA),
+    NAME_FUNC_OFFSET(18782, glBindProgramNV, glBindProgramNV, NULL, _gloffset_BindProgramNV),
+    NAME_FUNC_OFFSET(18799, glDeleteProgramsNV, glDeleteProgramsNV, NULL, _gloffset_DeleteProgramsNV),
+    NAME_FUNC_OFFSET(18819, glGenProgramsNV, glGenProgramsNV, NULL, _gloffset_GenProgramsNV),
+    NAME_FUNC_OFFSET(18836, glGetVertexAttribPointervNV, glGetVertexAttribPointervNV, NULL, _gloffset_GetVertexAttribPointervNV),
+    NAME_FUNC_OFFSET(18862, glGetVertexAttribPointervNV, glGetVertexAttribPointervNV, NULL, _gloffset_GetVertexAttribPointervNV),
+    NAME_FUNC_OFFSET(18891, glIsProgramNV, glIsProgramNV, NULL, _gloffset_IsProgramNV),
+    NAME_FUNC_OFFSET(18906, glPointParameteriNV, glPointParameteriNV, NULL, _gloffset_PointParameteriNV),
+    NAME_FUNC_OFFSET(18924, glPointParameterivNV, glPointParameterivNV, NULL, _gloffset_PointParameterivNV),
+    NAME_FUNC_OFFSET(18943, gl_dispatch_stub_753, gl_dispatch_stub_753, NULL, _gloffset_BlendEquationSeparateEXT),
+    NAME_FUNC_OFFSET(18967, gl_dispatch_stub_753, gl_dispatch_stub_753, NULL, _gloffset_BlendEquationSeparateEXT),
+    NAME_FUNC_OFFSET(18994, glBindFramebufferEXT, glBindFramebufferEXT, NULL, _gloffset_BindFramebufferEXT),
+    NAME_FUNC_OFFSET(19012, glBindRenderbufferEXT, glBindRenderbufferEXT, NULL, _gloffset_BindRenderbufferEXT),
+    NAME_FUNC_OFFSET(19031, glCheckFramebufferStatusEXT, glCheckFramebufferStatusEXT, NULL, _gloffset_CheckFramebufferStatusEXT),
+    NAME_FUNC_OFFSET(19056, glDeleteFramebuffersEXT, glDeleteFramebuffersEXT, NULL, _gloffset_DeleteFramebuffersEXT),
+    NAME_FUNC_OFFSET(19077, glDeleteRenderbuffersEXT, glDeleteRenderbuffersEXT, NULL, _gloffset_DeleteRenderbuffersEXT),
+    NAME_FUNC_OFFSET(19099, glFramebufferRenderbufferEXT, glFramebufferRenderbufferEXT, NULL, _gloffset_FramebufferRenderbufferEXT),
+    NAME_FUNC_OFFSET(19125, glFramebufferTexture1DEXT, glFramebufferTexture1DEXT, NULL, _gloffset_FramebufferTexture1DEXT),
+    NAME_FUNC_OFFSET(19148, glFramebufferTexture2DEXT, glFramebufferTexture2DEXT, NULL, _gloffset_FramebufferTexture2DEXT),
+    NAME_FUNC_OFFSET(19171, glFramebufferTexture3DEXT, glFramebufferTexture3DEXT, NULL, _gloffset_FramebufferTexture3DEXT),
+    NAME_FUNC_OFFSET(19194, glGenFramebuffersEXT, glGenFramebuffersEXT, NULL, _gloffset_GenFramebuffersEXT),
+    NAME_FUNC_OFFSET(19212, glGenRenderbuffersEXT, glGenRenderbuffersEXT, NULL, _gloffset_GenRenderbuffersEXT),
+    NAME_FUNC_OFFSET(19231, glGenerateMipmapEXT, glGenerateMipmapEXT, NULL, _gloffset_GenerateMipmapEXT),
+    NAME_FUNC_OFFSET(19248, glGetFramebufferAttachmentParameterivEXT, glGetFramebufferAttachmentParameterivEXT, NULL, _gloffset_GetFramebufferAttachmentParameterivEXT),
+    NAME_FUNC_OFFSET(19286, glGetRenderbufferParameterivEXT, glGetRenderbufferParameterivEXT, NULL, _gloffset_GetRenderbufferParameterivEXT),
+    NAME_FUNC_OFFSET(19315, glIsFramebufferEXT, glIsFramebufferEXT, NULL, _gloffset_IsFramebufferEXT),
+    NAME_FUNC_OFFSET(19331, glIsRenderbufferEXT, glIsRenderbufferEXT, NULL, _gloffset_IsRenderbufferEXT),
+    NAME_FUNC_OFFSET(19348, glRenderbufferStorageEXT, glRenderbufferStorageEXT, NULL, _gloffset_RenderbufferStorageEXT),
+    NAME_FUNC_OFFSET(19370, gl_dispatch_stub_771, gl_dispatch_stub_771, NULL, _gloffset_BlitFramebufferEXT),
+    NAME_FUNC_OFFSET(19388, glFramebufferTextureLayerEXT, glFramebufferTextureLayerEXT, NULL, _gloffset_FramebufferTextureLayerEXT),
     NAME_FUNC_OFFSET(-1, NULL, NULL, NULL, 0)
 };
 
index d124c724c99473527e92c24df4a6024d5a2171ef..f5b7d1e1385051e76067b2bf8a00dc4850bfb412 100644 (file)
@@ -1094,48 +1094,49 @@ static void _ae_update_state( GLcontext *ctx )
    AEarray *aa = actx->arrays;
    AEattrib *at = actx->attribs;
    GLuint i;
+   struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
 
    actx->nr_vbos = 0;
 
    /* conventional vertex arrays */
-  if (ctx->Array.ArrayObj->Index.Enabled) {
-      aa->array = &ctx->Array.ArrayObj->Index;
+   if (arrayObj->Index.Enabled) {
+      aa->array = &arrayObj->Index;
       aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
-   if (ctx->Array.ArrayObj->EdgeFlag.Enabled) {
-      aa->array = &ctx->Array.ArrayObj->EdgeFlag;
+   if (arrayObj->EdgeFlag.Enabled) {
+      aa->array = &arrayObj->EdgeFlag;
       aa->offset = _gloffset_EdgeFlagv;
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
-   if (ctx->Array.ArrayObj->Normal.Enabled) {
-      aa->array = &ctx->Array.ArrayObj->Normal;
+   if (arrayObj->Normal.Enabled) {
+      aa->array = &arrayObj->Normal;
       aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
-   if (ctx->Array.ArrayObj->Color.Enabled) {
-      aa->array = &ctx->Array.ArrayObj->Color;
+   if (arrayObj->Color.Enabled) {
+      aa->array = &arrayObj->Color;
       aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
-   if (ctx->Array.ArrayObj->SecondaryColor.Enabled) {
-      aa->array = &ctx->Array.ArrayObj->SecondaryColor;
+   if (arrayObj->SecondaryColor.Enabled) {
+      aa->array = &arrayObj->SecondaryColor;
       aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
-   if (ctx->Array.ArrayObj->FogCoord.Enabled) {
-      aa->array = &ctx->Array.ArrayObj->FogCoord;
+   if (arrayObj->FogCoord.Enabled) {
+      aa->array = &arrayObj->FogCoord;
       aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
    for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
-      struct gl_client_array *attribArray = &ctx->Array.ArrayObj->TexCoord[i];
+      struct gl_client_array *attribArray = &arrayObj->TexCoord[i];
       if (attribArray->Enabled) {
          /* NOTE: we use generic glVertexAttribNV functions here.
           * If we ever remove GL_NV_vertex_program this will have to change.
@@ -1152,8 +1153,8 @@ static void _ae_update_state( GLcontext *ctx )
    }
 
    /* generic vertex attribute arrays */   
-   for (i = 1; i < VERT_ATTRIB_MAX; i++) {  /* skip zero! */
-      struct gl_client_array *attribArray = &ctx->Array.ArrayObj->VertexAttrib[i];
+   for (i = 1; i < Elements(arrayObj->VertexAttrib); i++) {  /* skip zero! */
+      struct gl_client_array *attribArray = &arrayObj->VertexAttrib[i];
       if (attribArray->Enabled) {
          at->array = attribArray;
          /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
@@ -1179,18 +1180,18 @@ static void _ae_update_state( GLcontext *ctx )
    }
 
    /* finally, vertex position */
-   if (ctx->Array.ArrayObj->VertexAttrib[0].Enabled) {
+   if (arrayObj->VertexAttrib[0].Enabled) {
       /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
        * issued as the last (provoking) attribute).
        */
-      aa->array = &ctx->Array.ArrayObj->VertexAttrib[0];
+      aa->array = &arrayObj->VertexAttrib[0];
       assert(aa->array->Size >= 2); /* XXX fix someday? */
       aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
-   else if (ctx->Array.ArrayObj->Vertex.Enabled) {
-      aa->array = &ctx->Array.ArrayObj->Vertex;
+   else if (arrayObj->Vertex.Enabled) {
+      aa->array = &arrayObj->Vertex;
       aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
index 6f66ff47a0822c627b27022ff533b510fa2f88fa..2cc9a4323b20639deceb58b5b2b7693472e66387 100644 (file)
@@ -894,5 +894,12 @@ _mesa_init_exec_table(struct _glapi_table *exec)
     */
    SET_RenderbufferStorageMultisample(exec, _mesa_RenderbufferStorageMultisample);
 #endif
-}
 
+#if FEATURE_ARB_map_buffer_range
+   SET_MapBufferRange(exec, _mesa_MapBufferRange);
+   SET_FlushMappedBufferRange(exec, _mesa_FlushMappedBufferRange);
+#endif
+
+   /* GL_ARB_copy_buffer */
+   SET_CopyBufferSubData(exec, _mesa_CopyBufferSubData);
+}
index a1cc3a2a4b8a5483ef439280b931e87dc0be0b94..66f9c4e6bdb0d65573fc8b98d69823dd411fd6dd 100644 (file)
@@ -477,7 +477,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib4fvNV( GLuint index, const GLfloat
 static void GLAPIENTRY _mesa_noop_VertexAttrib1fARB( GLuint index, GLfloat x )
 {
    GET_CURRENT_CONTEXT(ctx);
-   if (index < MAX_VERTEX_ATTRIBS) {
+   if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
       ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, 0, 0, 1);
    }
    else
@@ -487,7 +487,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib1fARB( GLuint index, GLfloat x )
 static void GLAPIENTRY _mesa_noop_VertexAttrib1fvARB( GLuint index, const GLfloat *v )
 {
    GET_CURRENT_CONTEXT(ctx);
-   if (index < MAX_VERTEX_ATTRIBS) {
+   if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
       ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], 0, 0, 1);
    }
    else
@@ -497,7 +497,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib1fvARB( GLuint index, const GLfloa
 static void GLAPIENTRY _mesa_noop_VertexAttrib2fARB( GLuint index, GLfloat x, GLfloat y )
 {
    GET_CURRENT_CONTEXT(ctx);
-   if (index < MAX_VERTEX_ATTRIBS) {
+   if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
       ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, 0, 1);
    }
    else
@@ -507,7 +507,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib2fARB( GLuint index, GLfloat x, GL
 static void GLAPIENTRY _mesa_noop_VertexAttrib2fvARB( GLuint index, const GLfloat *v )
 {
    GET_CURRENT_CONTEXT(ctx);
-   if (index < MAX_VERTEX_ATTRIBS) {
+   if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
       ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], 0, 1);
    }
    else
@@ -518,7 +518,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib3fARB( GLuint index, GLfloat x,
                                   GLfloat y, GLfloat z )
 {
    GET_CURRENT_CONTEXT(ctx);
-   if (index < MAX_VERTEX_ATTRIBS) {
+   if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
       ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, z, 1);
    }
    else
@@ -528,7 +528,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib3fARB( GLuint index, GLfloat x,
 static void GLAPIENTRY _mesa_noop_VertexAttrib3fvARB( GLuint index, const GLfloat *v )
 {
    GET_CURRENT_CONTEXT(ctx);
-   if (index < MAX_VERTEX_ATTRIBS) {
+   if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
       ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], v[2], 1);
    }
    else
@@ -539,7 +539,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib4fARB( GLuint index, GLfloat x,
                                   GLfloat y, GLfloat z, GLfloat w )
 {
    GET_CURRENT_CONTEXT(ctx);
-   if (index < MAX_VERTEX_ATTRIBS) {
+   if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
       ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, z, w);
    }
    else
@@ -549,7 +549,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib4fARB( GLuint index, GLfloat x,
 static void GLAPIENTRY _mesa_noop_VertexAttrib4fvARB( GLuint index, const GLfloat *v )
 {
    GET_CURRENT_CONTEXT(ctx);
-   if (index < MAX_VERTEX_ATTRIBS) {
+   if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
       ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], v[2], v[3]);
    }
    else
index 2c6f370df94641e82ebdd3e3a56d699903fa5225..b2f11ffbfe3effde7735555e414fd53b3a34852b 100644 (file)
 #include "state.h"
 
 
+
+/**
+ * \return  number of bytes in array [count] of type.
+ */
+static GLsizei
+index_bytes(GLenum type, GLsizei count)
+{
+   if (type == GL_UNSIGNED_INT) {
+      return count * sizeof(GLuint);
+   }
+   else if (type == GL_UNSIGNED_BYTE) {
+      return count * sizeof(GLubyte);
+   }
+   else {
+      ASSERT(type == GL_UNSIGNED_SHORT);
+      return count * sizeof(GLushort);
+   }
+}
+
+
 /**
  * Find the max index in the given element/index buffer
  */
@@ -44,10 +64,8 @@ max_buffer_index(GLcontext *ctx, GLuint count, GLenum type,
 
    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);
+      map = ctx->Driver.MapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER,
+                                  GL_READ_ONLY, elementBuf);
       /* Actual address is the sum of pointers */
       indices = (const GLvoid *) ADD_POINTERS(map, (const GLubyte *) indices);
    }
@@ -70,14 +88,16 @@ max_buffer_index(GLcontext *ctx, GLuint count, GLenum type,
    }
 
    if (map) {
-      ctx->Driver.UnmapBuffer(ctx,
-                              GL_ELEMENT_ARRAY_BUFFER_ARB,
-                              ctx->Array.ElementArrayBufferObj);
+      ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, elementBuf);
    }
 
    return max;
 }
 
+
+/**
+ * Check if OK to render by examining framebuffer status and vertex arrays.
+ */
 static GLboolean
 check_valid_to_render(GLcontext *ctx, char *function)
 {
@@ -105,6 +125,12 @@ check_valid_to_render(GLcontext *ctx, char *function)
    return GL_TRUE;
 }
 
+
+/**
+ * Error checking for glDrawElements().  Includes parameter checking
+ * and VBO bounds checking.
+ * \return GL_TRUE if OK to render, GL_FALSE if error found
+ */
 GLboolean
 _mesa_validate_DrawElements(GLcontext *ctx,
                            GLenum mode, GLsizei count, GLenum type,
@@ -140,27 +166,8 @@ _mesa_validate_DrawElements(GLcontext *ctx,
    /* Vertex buffer object tests */
    if (ctx->Array.ElementArrayBufferObj->Name) {
       /* use indices in the buffer object */
-      GLuint indexBytes;
-
-      if (!ctx->Array.ElementArrayBufferObj->Size) {
-         _mesa_warning(ctx,
-                       "glDrawElements called with empty array elements buffer");
-         return GL_FALSE;
-      }
-
-      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 > (GLuint) ctx->Array.ElementArrayBufferObj->Size) {
+      if (index_bytes(type, count) > ctx->Array.ElementArrayBufferObj->Size) {
          _mesa_warning(ctx, "glDrawElements index out of buffer bounds");
          return GL_FALSE;
       }
@@ -175,8 +182,10 @@ _mesa_validate_DrawElements(GLcontext *ctx,
       /* find max array index */
       GLuint max = max_buffer_index(ctx, count, type, indices,
                                     ctx->Array.ElementArrayBufferObj);
-      if (max >= ctx->Array._MaxElement) {
+      if (max >= ctx->Array.ArrayObj->_MaxElement) {
          /* the max element is out of bounds of one or more enabled arrays */
+         _mesa_warning(ctx, "glDrawElements() index=%u is "
+                       "out of bounds (max=%u)", max, ctx->Array.ArrayObj->_MaxElement);
          return GL_FALSE;
       }
    }
@@ -184,6 +193,12 @@ _mesa_validate_DrawElements(GLcontext *ctx,
    return GL_TRUE;
 }
 
+
+/**
+ * Error checking for glDrawRangeElements().  Includes parameter checking
+ * and VBO bounds checking.
+ * \return GL_TRUE if OK to render, GL_FALSE if error found
+ */
 GLboolean
 _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode,
                                 GLuint start, GLuint end,
@@ -224,21 +239,8 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode,
    /* Vertex buffer object tests */
    if (ctx->Array.ElementArrayBufferObj->Name) {
       /* use indices in the buffer object */
-      GLsizei 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) {
+      if (index_bytes(type, count) > ctx->Array.ElementArrayBufferObj->Size) {
          _mesa_warning(ctx, "glDrawRangeElements index out of buffer bounds");
          return GL_FALSE;
       }
@@ -252,7 +254,7 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode,
    if (ctx->Const.CheckArrayBounds) {
       GLuint max = max_buffer_index(ctx, count, type, indices,
                                     ctx->Array.ElementArrayBufferObj);
-      if (max >= ctx->Array._MaxElement) {
+      if (max >= ctx->Array.ArrayObj->_MaxElement) {
          /* the max element is out of bounds of one or more enabled arrays */
          return GL_FALSE;
       }
@@ -265,6 +267,7 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode,
 /**
  * Called from the tnl module to error check the function parameters and
  * verify that we really can draw something.
+ * \return GL_TRUE if OK to render, GL_FALSE if error found
  */
 GLboolean
 _mesa_validate_DrawArrays(GLcontext *ctx,
@@ -290,7 +293,7 @@ _mesa_validate_DrawArrays(GLcontext *ctx,
       return GL_FALSE;
 
    if (ctx->Const.CheckArrayBounds) {
-      if (start + count > (GLint) ctx->Array._MaxElement)
+      if (start + count > (GLint) ctx->Array.ArrayObj->_MaxElement)
          return GL_FALSE;
    }
 
index 0fa5f0de55188b5d98107a3d9b804352d56990a3..c03353b78f523db0e14987e4cb385f88c3f3ca52 100644 (file)
@@ -1,9 +1,10 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.2
+ * Version:  7.6
  *
  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  * (C) Copyright IBM Corporation 2006
+ * Copyright (C) 2009  VMware, 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"),
@@ -46,6 +47,7 @@
 #include "bufferobj.h"
 #endif
 #include "arrayobj.h"
+#include "macros.h"
 #include "glapi/dispatch.h"
 
 
@@ -79,6 +81,7 @@ unbind_array_object_vbos(GLcontext *ctx, struct gl_array_object *obj)
    GLuint i;
 
    _mesa_reference_buffer_object(ctx, &obj->Vertex.BufferObj, NULL);
+   _mesa_reference_buffer_object(ctx, &obj->Weight.BufferObj, NULL);
    _mesa_reference_buffer_object(ctx, &obj->Normal.BufferObj, NULL);
    _mesa_reference_buffer_object(ctx, &obj->Color.BufferObj, NULL);
    _mesa_reference_buffer_object(ctx, &obj->SecondaryColor.BufferObj, NULL);
@@ -86,10 +89,10 @@ unbind_array_object_vbos(GLcontext *ctx, struct gl_array_object *obj)
    _mesa_reference_buffer_object(ctx, &obj->Index.BufferObj, NULL);
    _mesa_reference_buffer_object(ctx, &obj->EdgeFlag.BufferObj, NULL);
 
-   for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++)
+   for (i = 0; i < Elements(obj->TexCoord); i++)
       _mesa_reference_buffer_object(ctx, &obj->TexCoord[i].BufferObj, NULL);
 
-   for (i = 0; i < VERT_ATTRIB_MAX; i++)
+   for (i = 0; i < Elements(obj->VertexAttrib); i++)
       _mesa_reference_buffer_object(ctx, &obj->VertexAttrib[i].BufferObj,NULL);
 }
 
@@ -198,7 +201,8 @@ init_array(GLcontext *ctx,
    array->Normalized = GL_FALSE;
 #if FEATURE_ARB_vertex_buffer_object
    /* Vertex array buffers */
-   array->BufferObj = ctx->Array.NullBufferObj;
+   _mesa_reference_buffer_object(ctx, &array->BufferObj,
+                                 ctx->Shared->NullBufferObj);
 #endif
 }
 
@@ -220,16 +224,17 @@ _mesa_initialize_array_object( GLcontext *ctx,
 
    /* Init the individual arrays */
    init_array(ctx, &obj->Vertex, 4, GL_FLOAT);
+   init_array(ctx, &obj->Weight, 1, GL_FLOAT);
    init_array(ctx, &obj->Normal, 3, GL_FLOAT);
    init_array(ctx, &obj->Color, 4, GL_FLOAT);
    init_array(ctx, &obj->SecondaryColor, 4, GL_FLOAT);
    init_array(ctx, &obj->FogCoord, 1, GL_FLOAT);
    init_array(ctx, &obj->Index, 1, GL_FLOAT);
-   for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
+   for (i = 0; i < Elements(obj->TexCoord); i++) {
       init_array(ctx, &obj->TexCoord[i], 4, GL_FLOAT);
    }
    init_array(ctx, &obj->EdgeFlag, 1, GL_BOOL);
-   for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+   for (i = 0; i < Elements(obj->VertexAttrib); i++) {
       init_array(ctx, &obj->VertexAttrib[i], 4, GL_FLOAT);
    }
 
@@ -242,8 +247,8 @@ _mesa_initialize_array_object( GLcontext *ctx,
 /**
  * Add the given array object to the array object pool.
  */
-void
-_mesa_save_array_object( GLcontext *ctx, struct gl_array_object *obj )
+static void
+save_array_object( GLcontext *ctx, struct gl_array_object *obj )
 {
    if (obj->Name > 0) {
       /* insert into hash table */
@@ -256,8 +261,8 @@ _mesa_save_array_object( GLcontext *ctx, struct gl_array_object *obj )
  * Remove the given array object from the array object pool.
  * Do not deallocate the array object though.
  */
-void
-_mesa_remove_array_object( GLcontext *ctx, struct gl_array_object *obj )
+static void
+remove_array_object( GLcontext *ctx, struct gl_array_object *obj )
 {
    if (obj->Name > 0) {
       /* remove from hash table */
@@ -266,6 +271,83 @@ _mesa_remove_array_object( GLcontext *ctx, struct gl_array_object *obj )
 }
 
 
+
+/**
+ * Compute the index of the last array element that can be safely accessed
+ * in a vertex array.  We can really only do this when the array lives in
+ * a VBO.
+ * The array->_MaxElement field will be updated.
+ * Later in glDrawArrays/Elements/etc we can do some bounds checking.
+ */
+static void
+compute_max_element(struct gl_client_array *array)
+{
+   if (array->BufferObj->Name) {
+      /* Compute the max element we can access in the VBO without going
+       * out of bounds.
+       */
+      array->_MaxElement = ((GLsizeiptrARB) array->BufferObj->Size
+                            - (GLsizeiptrARB) array->Ptr + array->StrideB
+                            - array->_ElementSize) / array->StrideB;
+      if (0)
+         _mesa_printf("%s Object %u  Size %u  MaxElement %u\n",
+                      __FUNCTION__,
+                      array->BufferObj->Name,
+                      (GLuint) array->BufferObj->Size,
+                      array->_MaxElement);
+   }
+   else {
+      /* user-space array, no idea how big it is */
+      array->_MaxElement = 2 * 1000 * 1000 * 1000; /* just a big number */
+   }
+}
+
+
+/**
+ * Helper for update_arrays().
+ * \return  min(current min, array->_MaxElement).
+ */
+static GLuint
+update_min(GLuint min, struct gl_client_array *array)
+{
+   compute_max_element(array);
+   if (array->Enabled)
+      return MIN2(min, array->_MaxElement);
+   else
+      return min;
+}
+
+
+/**
+ * Examine vertex arrays to update the gl_array_object::_MaxElement field.
+ */
+void
+_mesa_update_array_object_max_element(GLcontext *ctx,
+                                      struct gl_array_object *arrayObj)
+{
+   GLuint i, min = ~0;
+
+   min = update_min(min, &arrayObj->Vertex);
+   min = update_min(min, &arrayObj->Weight);
+   min = update_min(min, &arrayObj->Normal);
+   min = update_min(min, &arrayObj->Color);
+   min = update_min(min, &arrayObj->SecondaryColor);
+   min = update_min(min, &arrayObj->FogCoord);
+   min = update_min(min, &arrayObj->Index);
+   min = update_min(min, &arrayObj->EdgeFlag);
+#if FEATURE_point_size_array
+   min = update_min(min, &arrayObj->PointSize);
+#endif
+   for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++)
+      min = update_min(min, &arrayObj->TexCoord[i]);
+   for (i = 0; i < Elements(arrayObj->VertexAttrib); i++)
+      min = update_min(min, &arrayObj->VertexAttrib[i]);
+
+   /* _MaxElement is one past the last legal array element */
+   arrayObj->_MaxElement = min;
+}
+
+
 /**********************************************************************/
 /* API Functions                                                      */
 /**********************************************************************/
@@ -311,7 +393,7 @@ _mesa_BindVertexArrayAPPLE( GLuint id )
             _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindVertexArrayAPPLE");
             return;
          }
-         _mesa_save_array_object(ctx, newObj);
+         save_array_object(ctx, newObj);
       }
    }
 
@@ -360,7 +442,7 @@ _mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids)
         }
 
         /* The ID is immediately freed for re-use */
-        _mesa_remove_array_object(ctx, obj);
+        remove_array_object(ctx, obj);
 
          /* Unreference the array object. 
           * If refcount hits zero, the object will be deleted.
@@ -414,7 +496,7 @@ _mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *arrays)
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenVertexArraysAPPLE");
          return;
       }
-      _mesa_save_array_object(ctx, obj);
+      save_array_object(ctx, obj);
       arrays[i] = first + i;
    }
 
index 9c4036af5a7ca613fd778dabf96d6036aa528c52..abca5ab9b4c2a3fe57416a627c7ca46aa9f226be 100644 (file)
@@ -1,9 +1,10 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5
+ * Version:  7.6
  *
  * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
  * (C) Copyright IBM Corporation 2006
+ * Copyright (C) 2009  VMware, 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"),
@@ -56,12 +57,10 @@ extern void
 _mesa_initialize_array_object( GLcontext *ctx,
                                struct gl_array_object *obj, GLuint name );
 
-extern void
-_mesa_save_array_object( GLcontext *ctx, struct gl_array_object *obj );
 
 extern void
-_mesa_remove_array_object( GLcontext *ctx, struct gl_array_object *obj );
-
+_mesa_update_array_object_max_element(GLcontext *ctx,
+                                      struct gl_array_object *arrayObj);
 
 
 /*
index e43fa96dd31e2e8671602be7e3ff74d6270190e2..476a24434ccd5aa0f643d6526fb36198310d8b30 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.3
+ * Version:  7.6
  *
  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  * Copyright (C) 2009  VMware, Inc.   All Rights Reserved.
@@ -541,6 +541,7 @@ end:
 static void
 pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable)
 {
+   const GLuint curTexUnitSave = ctx->Texture.CurrentUnit;
    GLuint i;
 
 #define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM)         \
@@ -685,59 +686,51 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable)
 
    /* texture unit enables */
    for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
-      if (ctx->Texture.Unit[i].Enabled != enable->Texture[i]) {
-         ctx->Texture.Unit[i].Enabled = enable->Texture[i];
-         if (ctx->Driver.Enable) {
-            if (ctx->Driver.ActiveTexture) {
-               (*ctx->Driver.ActiveTexture)(ctx, i);
-            }
-            (*ctx->Driver.Enable)( ctx, GL_TEXTURE_1D,
-                             (GLboolean) (enable->Texture[i] & TEXTURE_1D_BIT) );
-            (*ctx->Driver.Enable)( ctx, GL_TEXTURE_2D,
-                             (GLboolean) (enable->Texture[i] & TEXTURE_2D_BIT) );
-            (*ctx->Driver.Enable)( ctx, GL_TEXTURE_3D,
-                             (GLboolean) (enable->Texture[i] & TEXTURE_3D_BIT) );
-            if (ctx->Extensions.ARB_texture_cube_map)
-               (*ctx->Driver.Enable)( ctx, GL_TEXTURE_CUBE_MAP_ARB,
-                          (GLboolean) (enable->Texture[i] & TEXTURE_CUBE_BIT) );
-            if (ctx->Extensions.NV_texture_rectangle)
-               (*ctx->Driver.Enable)( ctx, GL_TEXTURE_RECTANGLE_NV,
-                          (GLboolean) (enable->Texture[i] & TEXTURE_RECT_BIT) );
+      const GLbitfield enabled = enable->Texture[i];
+      const GLbitfield genEnabled = enable->TexGen[i];
+
+      if (ctx->Texture.Unit[i].Enabled != enabled) {
+         _mesa_ActiveTextureARB(GL_TEXTURE0 + i);
+
+         _mesa_set_enable(ctx, GL_TEXTURE_1D,
+                          (enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE);
+         _mesa_set_enable(ctx, GL_TEXTURE_2D,
+                          (enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE);
+         _mesa_set_enable(ctx, GL_TEXTURE_3D,
+                          (enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE);
+         if (ctx->Extensions.NV_texture_rectangle) {
+            _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_ARB,
+                             (enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE);
+         }
+         if (ctx->Extensions.ARB_texture_cube_map) {
+            _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP,
+                             (enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE);
+         }
+         if (ctx->Extensions.MESA_texture_array) {
+            _mesa_set_enable(ctx, GL_TEXTURE_1D_ARRAY_EXT,
+                           (enabled & TEXTURE_1D_ARRAY_BIT) ? GL_TRUE : GL_FALSE);
+            _mesa_set_enable(ctx, GL_TEXTURE_2D_ARRAY_EXT,
+                           (enabled & TEXTURE_2D_ARRAY_BIT) ? GL_TRUE : GL_FALSE);
          }
       }
 
-      if (ctx->Texture.Unit[i].TexGenEnabled != enable->TexGen[i]) {
-         ctx->Texture.Unit[i].TexGenEnabled = enable->TexGen[i];
-         if (ctx->Driver.Enable) {
-            if (ctx->Driver.ActiveTexture) {
-               (*ctx->Driver.ActiveTexture)(ctx, i);
-            }
-            if (enable->TexGen[i] & S_BIT)
-               (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_S, GL_TRUE);
-            else
-               (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_S, GL_FALSE);
-            if (enable->TexGen[i] & T_BIT)
-               (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_T, GL_TRUE);
-            else
-               (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_T, GL_FALSE);
-            if (enable->TexGen[i] & R_BIT)
-               (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_R, GL_TRUE);
-            else
-               (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_R, GL_FALSE);
-            if (enable->TexGen[i] & Q_BIT)
-               (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_Q, GL_TRUE);
-            else
-               (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_Q, GL_FALSE);
-         }
+      if (ctx->Texture.Unit[i].TexGenEnabled != genEnabled) {
+         _mesa_ActiveTextureARB(GL_TEXTURE0 + i);
+         _mesa_set_enable(ctx, GL_TEXTURE_GEN_S,
+                          (genEnabled & S_BIT) ? GL_TRUE : GL_FALSE);
+         _mesa_set_enable(ctx, GL_TEXTURE_GEN_T,
+                          (genEnabled & T_BIT) ? GL_TRUE : GL_FALSE);
+         _mesa_set_enable(ctx, GL_TEXTURE_GEN_R,
+                          (genEnabled & R_BIT) ? GL_TRUE : GL_FALSE);
+         _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q,
+                          (genEnabled & Q_BIT) ? GL_TRUE : GL_FALSE);
       }
 
       /* GL_SGI_texture_color_table */
       ctx->Texture.Unit[i].ColorTableEnabled = enable->TextureColorTable[i];
    }
 
-   if (ctx->Driver.ActiveTexture) {
-      (*ctx->Driver.ActiveTexture)(ctx, ctx->Texture.CurrentUnit);
-   }
+   _mesa_ActiveTextureARB(GL_TEXTURE0 + curTexUnitSave);
 }
 
 
@@ -770,6 +763,13 @@ pop_texture_group(GLcontext *ctx, struct texture_state *texstate)
          _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_NV,
                      (unit->Enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE);
       }
+      if (ctx->Extensions.MESA_texture_array) {
+         _mesa_set_enable(ctx, GL_TEXTURE_1D_ARRAY_EXT,
+                 (unit->Enabled & TEXTURE_1D_ARRAY_BIT) ? GL_TRUE : GL_FALSE);
+         _mesa_set_enable(ctx, GL_TEXTURE_2D_ARRAY_EXT,
+                 (unit->Enabled & TEXTURE_2D_ARRAY_BIT) ? GL_TRUE : GL_FALSE);
+      }
+
       if (ctx->Extensions.SGI_texture_color_table) {
          _mesa_set_enable(ctx, GL_TEXTURE_COLOR_TABLE_SGI,
                           unit->ColorTableEnabled);
@@ -1330,20 +1330,22 @@ _mesa_PopAttrib(void)
  * counts when pushing/popping the GL_CLIENT_VERTEX_ARRAY_BIT attribute group.
  */
 static void
-adjust_buffer_object_ref_counts(struct gl_array_attrib *array, GLint step)
+adjust_buffer_object_ref_counts(struct gl_array_object *arrayObj, GLint step)
 {
    GLuint i;
-   array->ArrayObj->Vertex.BufferObj->RefCount += step;
-   array->ArrayObj->Normal.BufferObj->RefCount += step;
-   array->ArrayObj->Color.BufferObj->RefCount += step;
-   array->ArrayObj->SecondaryColor.BufferObj->RefCount += step;
-   array->ArrayObj->FogCoord.BufferObj->RefCount += step;
-   array->ArrayObj->Index.BufferObj->RefCount += step;
-   array->ArrayObj->EdgeFlag.BufferObj->RefCount += step;
-   for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++)
-      array->ArrayObj->TexCoord[i].BufferObj->RefCount += step;
-   for (i = 0; i < VERT_ATTRIB_MAX; i++)
-      array->ArrayObj->VertexAttrib[i].BufferObj->RefCount += step;
+
+   arrayObj->Vertex.BufferObj->RefCount += step;
+   arrayObj->Weight.BufferObj->RefCount += step;
+   arrayObj->Normal.BufferObj->RefCount += step;
+   arrayObj->Color.BufferObj->RefCount += step;
+   arrayObj->SecondaryColor.BufferObj->RefCount += step;
+   arrayObj->FogCoord.BufferObj->RefCount += step;
+   arrayObj->Index.BufferObj->RefCount += step;
+   arrayObj->EdgeFlag.BufferObj->RefCount += step;
+   for (i = 0; i < Elements(arrayObj->TexCoord); i++)
+      arrayObj->TexCoord[i].BufferObj->RefCount += step;
+   for (i = 0; i < Elements(arrayObj->VertexAttrib); i++)
+      arrayObj->VertexAttrib[i].BufferObj->RefCount += step;
 }
 
 
@@ -1434,7 +1436,7 @@ _mesa_PushClientAttrib(GLbitfield mask)
       newnode->next = head;
       head = newnode;
       /* bump reference counts on buffer objects */
-      adjust_buffer_object_ref_counts(&ctx->Array, 1);
+      adjust_buffer_object_ref_counts(ctx->Array.ArrayObj, 1);
    }
 
    ctx->ClientAttribStack[ctx->ClientAttribStackDepth] = head;
@@ -1484,7 +1486,7 @@ _mesa_PopClientAttrib(void)
            struct gl_array_attrib * data =
              (struct gl_array_attrib *) node->data;
 
-            adjust_buffer_object_ref_counts(&ctx->Array, -1);
+            adjust_buffer_object_ref_counts(ctx->Array.ArrayObj, -1);
         
             ctx->Array.ActiveTexture = data->ActiveTexture;
            if (data->LockCount != 0)
index c8d160baa9a88c302bc1e094df5ac678df9bd272..ba19e58cdb7b06da95fd335c1c4c8dd14fe0a232 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.5
+ * Version:  7.6
  *
  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
- * Copyright (C) 1999-2009  VMware, Inc.  All Rights Reserved.
+ * Copyright (C) 2009  VMware, 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"),
 #include "bufferobj.h"
 
 
+/* Debug flags */
+/*#define VBO_DEBUG*/
+/*#define BOUNDS_CHECK*/
+
+
 #ifdef FEATURE_OES_mapbuffer
-#define DEFAULT_ACCESS GL_WRITE_ONLY;
+#define DEFAULT_ACCESS GL_MAP_WRITE_BIT
 #else
-#define DEFAULT_ACCESS GL_READ_WRITE;
+#define DEFAULT_ACCESS (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)
 #endif
 
 
@@ -73,6 +78,16 @@ get_buffer(GLcontext *ctx, GLenum target)
       case GL_PIXEL_UNPACK_BUFFER_EXT:
          bufObj = ctx->Unpack.BufferObj;
          break;
+      case GL_COPY_READ_BUFFER:
+         if (ctx->Extensions.ARB_copy_buffer) {
+            bufObj = ctx->CopyReadBuffer;
+         }
+         break;
+      case GL_COPY_WRITE_BUFFER:
+         if (ctx->Extensions.ARB_copy_buffer) {
+            bufObj = ctx->CopyWriteBuffer;
+         }
+         break;
       default:
          /* error must be recorded by caller */
          return NULL;
@@ -85,6 +100,24 @@ get_buffer(GLcontext *ctx, GLenum target)
 }
 
 
+/**
+ * Convert a GLbitfield describing the mapped buffer access flags
+ * into one of GL_READ_WRITE, GL_READ_ONLY, or GL_WRITE_ONLY.
+ */
+static GLenum
+simplified_access_mode(GLbitfield access)
+{
+   const GLbitfield rwFlags = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT;
+   if ((access & rwFlags) == rwFlags)
+      return GL_READ_WRITE;
+   if ((access & GL_MAP_READ_BIT) == GL_MAP_READ_BIT)
+      return GL_READ_ONLY;
+   if ((access & GL_MAP_WRITE_BIT) == GL_MAP_WRITE_BIT)
+      return GL_WRITE_ONLY;
+   return GL_READ_WRITE; /* this should never happen, but no big deal */
+}
+
+
 /**
  * Tests the subdata range parameters and sets the GL error code for
  * \c glBufferSubDataARB and \c glGetBufferSubDataARB.
@@ -194,7 +227,7 @@ _mesa_reference_buffer_object(GLcontext *ctx,
       return;
 
    if (*ptr) {
-      /* Unreference the old texture */
+      /* Unreference the old buffer */
       GLboolean deleteFlag = GL_FALSE;
       struct gl_buffer_object *oldObj = *ptr;
 
@@ -227,7 +260,7 @@ _mesa_reference_buffer_object(GLcontext *ctx,
    ASSERT(!*ptr);
 
    if (bufObj) {
-      /* reference new texture */
+      /* reference new buffer */
       /*_glthread_LOCK_MUTEX(tex->Mutex);*/
       if (bufObj->RefCount == 0) {
          /* this buffer's being deleted (look just above) */
@@ -261,7 +294,7 @@ _mesa_initialize_buffer_object( struct gl_buffer_object *obj,
    obj->RefCount = 1;
    obj->Name = name;
    obj->Usage = GL_STATIC_DRAW_ARB;
-   obj->Access = DEFAULT_ACCESS;
+   obj->AccessFlags = DEFAULT_ACCESS;
 }
 
 
@@ -389,7 +422,6 @@ _mesa_buffer_map( GLcontext *ctx, GLenum target, GLenum access,
    (void) ctx;
    (void) target;
    (void) access;
-   ASSERT(!bufObj->OnCard);
    /* Just return a direct pointer to the data */
    if (bufObj->Pointer) {
       /* already mapped! */
@@ -400,6 +432,43 @@ _mesa_buffer_map( GLcontext *ctx, GLenum target, GLenum access,
 }
 
 
+/**
+ * Default fallback for \c dd_function_table::MapBufferRange().
+ * Called via glMapBufferRange().
+ */
+void *
+_mesa_buffer_map_range( GLcontext *ctx, GLenum target, GLintptr offset,
+                        GLsizeiptr length, GLbitfield access,
+                        struct gl_buffer_object *bufObj )
+{
+   (void) ctx;
+   (void) target;
+   (void) access;
+   (void) length;
+   assert(!bufObj->Pointer);
+   /* Just return a direct pointer to the data */
+   return bufObj->Data + offset;
+}
+
+
+/**
+ * Default fallback for \c dd_function_table::FlushMappedBufferRange().
+ * Called via glFlushMappedBufferRange().
+ */
+void
+_mesa_buffer_flush_mapped_range( GLcontext *ctx, GLenum target, 
+                                 GLintptr offset, GLsizeiptr length,
+                                 struct gl_buffer_object *obj )
+{
+   (void) ctx;
+   (void) target;
+   (void) offset;
+   (void) length;
+   (void) obj;
+   /* no-op */
+}
+
+
 /**
  * Default callback for \c dd_function_table::MapBuffer().
  *
@@ -413,29 +482,58 @@ _mesa_buffer_unmap( GLcontext *ctx, GLenum target,
 {
    (void) ctx;
    (void) target;
-   ASSERT(!bufObj->OnCard);
    /* XXX we might assert here that bufObj->Pointer is non-null */
    bufObj->Pointer = NULL;
    return GL_TRUE;
 }
 
 
+/**
+ * Default fallback for \c dd_function_table::CopyBufferSubData().
+ * Called via glCopyBuffserSubData().
+ */
+void
+_mesa_copy_buffer_subdata(GLcontext *ctx,
+                          struct gl_buffer_object *src,
+                          struct gl_buffer_object *dst,
+                          GLintptr readOffset, GLintptr writeOffset,
+                          GLsizeiptr size)
+{
+   GLubyte *srcPtr, *dstPtr;
+
+   /* buffer should not already be mapped */
+   assert(!src->Pointer);
+   assert(!dst->Pointer);
+
+   srcPtr = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_COPY_READ_BUFFER,
+                                              GL_READ_ONLY, src);
+   dstPtr = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_COPY_WRITE_BUFFER,
+                                              GL_WRITE_ONLY, dst);
+
+   if (srcPtr && dstPtr)
+      _mesa_memcpy(dstPtr + writeOffset, srcPtr + readOffset, size);
+
+   ctx->Driver.UnmapBuffer(ctx, GL_COPY_READ_BUFFER, src);
+   ctx->Driver.UnmapBuffer(ctx, GL_COPY_WRITE_BUFFER, dst);
+}
+
+
+
 /**
  * Initialize the state associated with buffer objects
  */
 void
 _mesa_init_buffer_objects( GLcontext *ctx )
 {
-   /* Allocate the default buffer object and set refcount so high that
-    * it never gets deleted.
-    * XXX with recent/improved refcounting this may not longer be needed.
-    */
-   ctx->Array.NullBufferObj = _mesa_new_buffer_object(ctx, 0, 0);
-   if (ctx->Array.NullBufferObj)
-      ctx->Array.NullBufferObj->RefCount = 1000;
-
-   ctx->Array.ArrayBufferObj = ctx->Array.NullBufferObj;
-   ctx->Array.ElementArrayBufferObj = ctx->Array.NullBufferObj;
+   _mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj,
+                                 ctx->Shared->NullBufferObj);
+   _mesa_reference_buffer_object(ctx, &ctx->Array.ElementArrayBufferObj,
+                                 ctx->Shared->NullBufferObj);
+
+   _mesa_reference_buffer_object(ctx, &ctx->CopyReadBuffer,
+                                 ctx->Shared->NullBufferObj);
+   _mesa_reference_buffer_object(ctx, &ctx->CopyWriteBuffer,
+                                 ctx->Shared->NullBufferObj);
 }
 
 
@@ -462,8 +560,22 @@ bind_buffer_object(GLcontext *ctx, GLenum target, GLuint buffer)
    case GL_PIXEL_UNPACK_BUFFER_EXT:
       bindTarget = &ctx->Unpack.BufferObj;
       break;
+   case GL_COPY_READ_BUFFER:
+      if (ctx->Extensions.ARB_copy_buffer) {
+         bindTarget = &ctx->CopyReadBuffer;
+      }
+      break;
+   case GL_COPY_WRITE_BUFFER:
+      if (ctx->Extensions.ARB_copy_buffer) {
+         bindTarget = &ctx->CopyWriteBuffer;
+      }
+      break;
    default:
-      _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferARB(target)");
+      ; /* no-op / we'll hit the follow error test next */
+   }
+
+   if (!bindTarget) {
+      _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferARB(target 0x%x)");
       return;
    }
 
@@ -479,7 +591,7 @@ bind_buffer_object(GLcontext *ctx, GLenum target, GLuint buffer)
       /* The spec says there's not a buffer object named 0, but we use
        * one internally because it simplifies things.
        */
-      newBufObj = ctx->Array.NullBufferObj;
+      newBufObj = ctx->Shared->NullBufferObj;
    }
    else {
       /* non-default buffer object */
@@ -500,7 +612,7 @@ bind_buffer_object(GLcontext *ctx, GLenum target, GLuint buffer)
    _mesa_reference_buffer_object(ctx, bindTarget, newBufObj);
 
    /* Pass BindBuffer call to device driver */
-   if (ctx->Driver.BindBuffer && newBufObj)
+   if (ctx->Driver.BindBuffer)
       ctx->Driver.BindBuffer( ctx, target, newBufObj );
 }
 
@@ -746,7 +858,7 @@ unbind(GLcontext *ctx,
        struct gl_buffer_object *obj)
 {
    if (*ptr == obj) {
-      _mesa_reference_buffer_object(ctx, ptr, ctx->Array.NullBufferObj);
+      _mesa_reference_buffer_object(ctx, ptr, ctx->Shared->NullBufferObj);
    }
 }
 
@@ -789,6 +901,7 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
    for (i = 0; i < n; i++) {
       struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, ids[i]);
       if (bufObj) {
+         struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
          GLuint j;
 
          ASSERT(bufObj->Name == ids[i]);
@@ -796,23 +909,24 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
          if (bufObj->Pointer) {
             /* if mapped, unmap it now */
             ctx->Driver.UnmapBuffer(ctx, 0, bufObj);
-            bufObj->Access = DEFAULT_ACCESS;
+            bufObj->AccessFlags = DEFAULT_ACCESS;
             bufObj->Pointer = NULL;
          }
 
          /* unbind any vertex pointers bound to this buffer */
-         unbind(ctx, &ctx->Array.ArrayObj->Vertex.BufferObj, bufObj);
-         unbind(ctx, &ctx->Array.ArrayObj->Normal.BufferObj, bufObj);
-         unbind(ctx, &ctx->Array.ArrayObj->Color.BufferObj, bufObj);
-         unbind(ctx, &ctx->Array.ArrayObj->SecondaryColor.BufferObj, bufObj);
-         unbind(ctx, &ctx->Array.ArrayObj->FogCoord.BufferObj, bufObj);
-         unbind(ctx, &ctx->Array.ArrayObj->Index.BufferObj, bufObj);
-         unbind(ctx, &ctx->Array.ArrayObj->EdgeFlag.BufferObj, bufObj);
-         for (j = 0; j < MAX_TEXTURE_COORD_UNITS; j++) {
-            unbind(ctx, &ctx->Array.ArrayObj->TexCoord[j].BufferObj, bufObj);
+         unbind(ctx, &arrayObj->Vertex.BufferObj, bufObj);
+         unbind(ctx, &arrayObj->Weight.BufferObj, bufObj);
+         unbind(ctx, &arrayObj->Normal.BufferObj, bufObj);
+         unbind(ctx, &arrayObj->Color.BufferObj, bufObj);
+         unbind(ctx, &arrayObj->SecondaryColor.BufferObj, bufObj);
+         unbind(ctx, &arrayObj->FogCoord.BufferObj, bufObj);
+         unbind(ctx, &arrayObj->Index.BufferObj, bufObj);
+         unbind(ctx, &arrayObj->EdgeFlag.BufferObj, bufObj);
+         for (j = 0; j < Elements(arrayObj->TexCoord); j++) {
+            unbind(ctx, &arrayObj->TexCoord[j].BufferObj, bufObj);
          }
-         for (j = 0; j < VERT_ATTRIB_MAX; j++) {
-            unbind(ctx, &ctx->Array.ArrayObj->VertexAttrib[j].BufferObj, bufObj);
+         for (j = 0; j < Elements(arrayObj->VertexAttrib); j++) {
+            unbind(ctx, &arrayObj->VertexAttrib[j].BufferObj, bufObj);
          }
 
          if (ctx->Array.ArrayBufferObj == bufObj) {
@@ -947,19 +1061,31 @@ _mesa_BufferDataARB(GLenum target, GLsizeiptrARB size,
       return;
    }
    if (bufObj->Name == 0) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferDataARB" );
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferDataARB(buffer 0)" );
       return;
    }
    
    if (bufObj->Pointer) {
       /* Unmap the existing buffer.  We'll replace it now.  Not an error. */
       ctx->Driver.UnmapBuffer(ctx, target, bufObj);
-      bufObj->Access = DEFAULT_ACCESS;
+      bufObj->AccessFlags = DEFAULT_ACCESS;
       bufObj->Pointer = NULL;
    }  
 
+   FLUSH_VERTICES(ctx, _NEW_BUFFER_OBJECT);
+
    ASSERT(ctx->Driver.BufferData);
 
+   bufObj->Written = GL_TRUE;
+
+#ifdef VBO_DEBUG
+   _mesa_printf("glBufferDataARB(%u, sz %ld, from %p, usage 0x%x)\n",
+                bufObj->Name, size, data, usage);
+#endif
+
+#ifdef BOUNDS_CHECK
+   size += 100;
+#endif
    /* Give the buffer object to the driver!  <data> may be null! */
    ctx->Driver.BufferData( ctx, target, size, data, usage, bufObj );
 }
@@ -980,6 +1106,8 @@ _mesa_BufferSubDataARB(GLenum target, GLintptrARB offset,
       return;
    }
 
+   bufObj->Written = GL_TRUE;
+
    ASSERT(ctx->Driver.BufferSubData);
    ctx->Driver.BufferSubData( ctx, target, offset, size, data, bufObj );
 }
@@ -1010,13 +1138,18 @@ _mesa_MapBufferARB(GLenum target, GLenum access)
 {
    GET_CURRENT_CONTEXT(ctx);
    struct gl_buffer_object * bufObj;
+   GLbitfield accessFlags;
    ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL);
 
    switch (access) {
       case GL_READ_ONLY_ARB:
+         accessFlags = GL_MAP_READ_BIT;
+         break;
       case GL_WRITE_ONLY_ARB:
+         accessFlags = GL_MAP_WRITE_BIT;
+         break;
       case GL_READ_WRITE_ARB:
-         /* OK */
+         accessFlags = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT;
          break;
       default:
          _mesa_error(ctx, GL_INVALID_ENUM, "glMapBufferARB(access)");
@@ -1029,7 +1162,7 @@ _mesa_MapBufferARB(GLenum target, GLenum access)
       return NULL;
    }
    if (bufObj->Name == 0) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glMapBufferARB" );
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glMapBufferARB(buffer 0)" );
       return NULL;
    }
    if (bufObj->Pointer) {
@@ -1043,7 +1176,34 @@ _mesa_MapBufferARB(GLenum target, GLenum access)
       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(access)");
    }
 
-   bufObj->Access = access;
+   bufObj->AccessFlags = accessFlags;
+   bufObj->Offset = 0;
+   bufObj->Length = bufObj->Size;
+
+   if (access == GL_WRITE_ONLY_ARB || access == GL_READ_WRITE_ARB)
+      bufObj->Written = GL_TRUE;
+
+#ifdef VBO_DEBUG
+   _mesa_printf("glMapBufferARB(%u, sz %ld, access 0x%x)\n",
+                bufObj->Name, bufObj->Size, access);
+   if (access == GL_WRITE_ONLY_ARB) {
+      GLuint i;
+      GLubyte *b = (GLubyte *) bufObj->Pointer;
+      for (i = 0; i < bufObj->Size; i++)
+         b[i] = i & 0xff;
+   }
+#endif
+
+#ifdef BOUNDS_CHECK
+   {
+      GLubyte *buf = (GLubyte *) bufObj->Pointer;
+      GLuint i;
+      /* buffer is 100 bytes larger than requested, fill with magic value */
+      for (i = 0; i < 100; i++) {
+         buf[bufObj->Size - i - 1] = 123;
+      }
+   }
+#endif
 
    return bufObj->Pointer;
 }
@@ -1071,9 +1231,47 @@ _mesa_UnmapBufferARB(GLenum target)
       return GL_FALSE;
    }
 
+#ifdef BOUNDS_CHECK
+   if (bufObj->Access != GL_READ_ONLY_ARB) {
+      GLubyte *buf = (GLubyte *) bufObj->Pointer;
+      GLuint i;
+      /* check that last 100 bytes are still = magic value */
+      for (i = 0; i < 100; i++) {
+         GLuint pos = bufObj->Size - i - 1;
+         if (buf[pos] != 123) {
+            _mesa_warning(ctx, "Out of bounds buffer object write detected"
+                          " at position %d (value = %u)\n",
+                          pos, buf[pos]);
+         }
+      }
+   }
+#endif
+
+#ifdef VBO_DEBUG
+   if (bufObj->AccessFlags & GL_MAP_WRITE_BIT) {
+      GLuint i, unchanged = 0;
+      GLubyte *b = (GLubyte *) bufObj->Pointer;
+      GLint pos = -1;
+      /* check which bytes changed */
+      for (i = 0; i < bufObj->Size - 1; i++) {
+         if (b[i] == (i & 0xff) && b[i+1] == ((i+1) & 0xff)) {
+            unchanged++;
+            if (pos == -1)
+               pos = i;
+         }
+      }
+      if (unchanged) {
+         _mesa_printf("glUnmapBufferARB(%u): %u of %ld unchanged, starting at %d\n",
+                      bufObj->Name, unchanged, bufObj->Size, pos);
+      }
+   }
+#endif
+
    status = ctx->Driver.UnmapBuffer( ctx, target, bufObj );
-   bufObj->Access = DEFAULT_ACCESS;
+   bufObj->AccessFlags = DEFAULT_ACCESS;
    bufObj->Pointer = NULL;
+   bufObj->Offset = 0;
+   bufObj->Length = 0;
 
    return status;
 }
@@ -1104,7 +1302,7 @@ _mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params)
          *params = bufObj->Usage;
          break;
       case GL_BUFFER_ACCESS_ARB:
-         *params = bufObj->Access;
+         *params = simplified_access_mode(bufObj->AccessFlags);
          break;
       case GL_BUFFER_MAPPED_ARB:
          *params = (bufObj->Pointer != NULL);
@@ -1140,3 +1338,234 @@ _mesa_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params)
 
    *params = bufObj->Pointer;
 }
+
+
+void GLAPIENTRY
+_mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
+                        GLintptr readOffset, GLintptr writeOffset,
+                        GLsizeiptr size)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *src, *dst;
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   src = get_buffer(ctx, readTarget);
+   if (!src || src->Name == 0) {
+      _mesa_error(ctx, GL_INVALID_ENUM,
+                  "glCopyBuffserSubData(readTarget = 0x%x)", readTarget);
+      return;
+   }
+
+   dst = get_buffer(ctx, writeTarget);
+   if (!dst || dst->Name == 0) {
+      _mesa_error(ctx, GL_INVALID_ENUM,
+                  "glCopyBuffserSubData(writeTarget = 0x%x)", writeTarget);
+      return;
+   }
+
+   if (src->Pointer) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glCopyBuffserSubData(readBuffer is mapped)");
+      return;
+   }
+
+   if (dst->Pointer) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glCopyBuffserSubData(writeBuffer is mapped)");
+      return;
+   }
+
+   if (readOffset < 0) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "glCopyBuffserSubData(readOffset = %d)", readOffset);
+      return;
+   }
+
+   if (writeOffset < 0) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "glCopyBuffserSubData(writeOffset = %d)", writeOffset);
+      return;
+   }
+
+   if (readOffset + size > src->Size) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "glCopyBuffserSubData(readOffset + size = %d)",
+                  readOffset, size);
+      return;
+   }
+
+   if (writeOffset + size > dst->Size) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "glCopyBuffserSubData(writeOffset + size = %d)",
+                  writeOffset, size);
+      return;
+   }
+
+   if (src == dst) {
+      if (readOffset + size <= writeOffset) {
+         /* OK */
+      }
+      else if (writeOffset + size <= readOffset) {
+         /* OK */
+      }
+      else {
+         /* overlapping src/dst is illegal */
+         _mesa_error(ctx, GL_INVALID_VALUE,
+                     "glCopyBuffserSubData(overlapping src/dst)");
+         return;
+      }
+   }
+
+   ctx->Driver.CopyBufferSubData(ctx, src, dst, readOffset, writeOffset, size);
+}
+
+
+/**
+ * See GL_ARB_map_buffer_range spec
+ */
+void * GLAPIENTRY
+_mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length,
+                     GLbitfield access)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+   ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL);
+
+   if (!ctx->Extensions.ARB_map_buffer_range) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glMapBufferRange(extension not supported)");
+      return NULL;
+   }
+
+   if (offset < 0) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "glMapBufferRange(offset = %ld)", offset);
+      return NULL;
+   }
+
+   if (length < 0) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "glMapBufferRange(length = %ld)", length);
+      return NULL;
+   }
+
+   if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glMapBufferRange(access indicates neither read or write)");
+      return NULL;
+   }
+
+   if (access & GL_MAP_READ_BIT) {
+      if ((access & GL_MAP_INVALIDATE_RANGE_BIT) ||
+          (access & GL_MAP_INVALIDATE_BUFFER_BIT) ||
+          (access & GL_MAP_UNSYNCHRONIZED_BIT)) {
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "glMapBufferRange(invalid access flags)");
+         return NULL;
+      }
+   }
+
+   if ((access & GL_MAP_FLUSH_EXPLICIT_BIT) &&
+       ((access & GL_MAP_WRITE_BIT) == 0)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glMapBufferRange(invalid access flags)");
+      return NULL;
+   }
+
+   bufObj = get_buffer(ctx, target);
+   if (!bufObj || bufObj->Name == 0) {
+      _mesa_error(ctx, GL_INVALID_ENUM,
+                  "glMapBufferRange(target = 0x%x)", target);
+      return NULL;
+   }
+
+   if (offset + length > bufObj->Size) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "glMapBufferRange(offset + length > size)");
+      return NULL;
+   }
+
+   if (bufObj->Pointer) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glMapBufferRange(buffer already mapped)");
+      return NULL;
+   }
+      
+   ASSERT(ctx->Driver.MapBufferRange);
+   bufObj->Pointer = ctx->Driver.MapBufferRange(ctx, target, offset, length,
+                                                access, bufObj);
+
+   bufObj->Offset = offset;
+   bufObj->Length = length;
+   bufObj->AccessFlags = access;
+
+   return bufObj->Pointer;
+}
+
+
+/**
+ * See GL_ARB_map_buffer_range spec
+ */
+void GLAPIENTRY
+_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   if (!ctx->Extensions.ARB_map_buffer_range) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glMapBufferRange(extension not supported)");
+      return;
+   }
+
+   if (offset < 0) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "glMapBufferRange(offset = %ld)", offset);
+      return;
+   }
+
+   if (length < 0) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "glMapBufferRange(length = %ld)", length);
+      return;
+   }
+
+   bufObj = get_buffer(ctx, target);
+   if (!bufObj) {
+      _mesa_error(ctx, GL_INVALID_ENUM,
+                  "glMapBufferRange(target = 0x%x)", target);
+      return;
+   }
+
+   if (bufObj->Name == 0) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glMapBufferRange(current buffer is 0)");
+      return;
+   }
+
+   if (!bufObj->Pointer) {
+      /* buffer is not mapped */
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glMapBufferRange(buffer is not mapped)");
+      return;
+   }
+
+   if ((bufObj->AccessFlags & GL_MAP_FLUSH_EXPLICIT_BIT) == 0) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glMapBufferRange(GL_MAP_FLUSH_EXPLICIT_BIT not set)");
+      return;
+   }
+
+   if (offset + length > bufObj->Length) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+             "glMapBufferRange(offset %ld + length %ld > mapped length %ld)",
+             offset, length, bufObj->Length);
+      return;
+   }
+
+   ASSERT(bufObj->AccessFlags & GL_MAP_WRITE_BIT);
+
+   if (ctx->Driver.FlushMappedBufferRange)
+      ctx->Driver.FlushMappedBufferRange(ctx, target, offset, length, bufObj);
+}
index 3c08f0083cf64fcb08fa96a57e718da958fe1c6a..a8e2dcef933b9e55e574efbd7cfadc46611e887c 100644 (file)
@@ -1,8 +1,9 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.2
+ * Version:  7.6
  *
  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ * Copyright (C) 2009  VMware, 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"),
@@ -78,10 +79,27 @@ extern void *
 _mesa_buffer_map( GLcontext *ctx, GLenum target, GLenum access,
                  struct gl_buffer_object * bufObj );
 
+extern void *
+_mesa_buffer_map_range( GLcontext *ctx, GLenum target, GLintptr offset,
+                        GLsizeiptr length, GLbitfield access,
+                        struct gl_buffer_object *bufObj );
+
+extern void
+_mesa_buffer_flush_mapped_range( GLcontext *ctx, GLenum target, 
+                                 GLintptr offset, GLsizeiptr length,
+                                 struct gl_buffer_object *obj );
+
 extern GLboolean
 _mesa_buffer_unmap( GLcontext *ctx, GLenum target,
                     struct gl_buffer_object * bufObj );
 
+extern void
+_mesa_copy_buffer_subdata(GLcontext *ctx,
+                          struct gl_buffer_object *src,
+                          struct gl_buffer_object *dst,
+                          GLintptr readOffset, GLintptr writeOffset,
+                          GLsizeiptr size);
+
 extern GLboolean
 _mesa_validate_pbo_access(GLuint dimensions,
                           const struct gl_pixelstore_attrib *pack,
@@ -154,4 +172,16 @@ _mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params);
 extern void GLAPIENTRY
 _mesa_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params);
 
+extern void GLAPIENTRY
+_mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
+                        GLintptr readOffset, GLintptr writeOffset,
+                        GLsizeiptr size);
+
+extern void * GLAPIENTRY
+_mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length,
+                     GLbitfield access);
+
+extern void GLAPIENTRY
+_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length);
+
 #endif
index c5f13345f0481cf9a9316f2c6d21d4dbc21231f3..d8b5f3b1f4aafe02bbd5f53e27b8644210901682 100644 (file)
@@ -443,7 +443,7 @@ _mesa_readbuffer(GLcontext *ctx, GLenum buffer, GLint bufferIndex)
    fb->ColorReadBuffer = buffer;
    fb->_ColorReadBufferIndex = bufferIndex;
 
-   ctx->NewState |= _NEW_PIXEL;
+   ctx->NewState |= _NEW_BUFFERS;
 }
 
 
index bd66a4c2317b94cc3ba07a35f7aa870d780401ab..f77a29a43ece2eff178ac8f516715fd460428c70 100644 (file)
 /** For GL_ARB_vertex_program */
 /*@{*/
 #define MAX_VERTEX_PROGRAM_ADDRESS_REGS 1
-#define MAX_VERTEX_PROGRAM_ATTRIBS     16
 /*@}*/
 
 /** For GL_ARB_fragment_program */
 #define MAX_PROGRAM_TEMPS 256
 #define MAX_PROGRAM_ADDRESS_REGS 2
 #define MAX_UNIFORMS 1024  /**< number of vec4 uniforms */
-#define MAX_VARYING      /**< number of float[4] vectors */
+#define MAX_VARYING 16     /**< number of float[4] vectors */
 #define MAX_SAMPLERS MAX_TEXTURE_IMAGE_UNITS
 #define MAX_PROGRAM_INPUTS 32
 #define MAX_PROGRAM_OUTPUTS 32
 
 /** For GL_ARB_vertex_shader */
 /*@{*/
-#define MAX_VERTEX_ATTRIBS 16
+#define MAX_VERTEX_GENERIC_ATTRIBS 16
 #define MAX_VERTEX_TEXTURE_IMAGE_UNITS MAX_TEXTURE_IMAGE_UNITS
 #define MAX_COMBINED_TEXTURE_IMAGE_UNITS MAX_TEXTURE_IMAGE_UNITS
 /*@}*/
index a947f69632f308b67fe05af42afb5ab0213b8bc4..bf53bd34678e2717b05475ab6ea0661c87a8d57b 100644 (file)
@@ -455,7 +455,7 @@ _mesa_init_current(GLcontext *ctx)
    GLuint i;
 
    /* Init all to (0,0,0,1) */
-   for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+   for (i = 0; i < Elements(ctx->Current.Attrib); i++) {
       ASSIGN_4V( ctx->Current.Attrib[i], 0.0, 0.0, 0.0, 1.0 );
    }
 
@@ -602,6 +602,10 @@ _mesa_init_constants(GLcontext *ctx)
    ASSERT(MAX_NV_VERTEX_PROGRAM_TEMPS <= MAX_PROGRAM_TEMPS);
    ASSERT(MAX_NV_VERTEX_PROGRAM_INPUTS <= VERT_ATTRIB_MAX);
    ASSERT(MAX_NV_VERTEX_PROGRAM_OUTPUTS <= VERT_RESULT_MAX);
+
+   /* check that we don't exceed various 32-bit bitfields */
+   ASSERT(VERT_RESULT_MAX <= 32);
+   ASSERT(FRAG_ATTRIB_MAX <= 32);
 }
 
 
@@ -1017,10 +1021,6 @@ _mesa_free_context_data( GLcontext *ctx )
    _mesa_reference_buffer_object(ctx, &ctx->Array.ElementArrayBufferObj, NULL);
 #endif
 
-#if FEATURE_ARB_vertex_buffer_object
-   _mesa_delete_buffer_object(ctx, ctx->Array.NullBufferObj);
-#endif
-
    /* free dispatch tables */
    _mesa_free(ctx->Exec);
    _mesa_free(ctx->Save);
index 32b1d4e9faf9c43ade2582d73fdeaff74a9b9b41..1d92e510a4d5cb062d7622b27f1385c7b61ba15d 100644 (file)
@@ -798,6 +798,12 @@ struct dd_function_table {
    void * (*MapBuffer)( GLcontext *ctx, GLenum target, GLenum access,
                        struct gl_buffer_object *obj );
 
+   void (*CopyBufferSubData)( GLcontext *ctx,
+                              struct gl_buffer_object *src,
+                              struct gl_buffer_object *dst,
+                              GLintptr readOffset, GLintptr writeOffset,
+                              GLsizeiptr size );
+
    /* May return NULL if MESA_MAP_NOWAIT_BIT is set in access:
     */
    void * (*MapBufferRange)( GLcontext *ctx, GLenum target,
index b54e47919dd4b370de5513e751f0932a195a4ffa..1c8c44fcb96630d2397bf8b0dd0d795ad57d215b 100644 (file)
  */
 
 #include "mtypes.h"
+#include "attrib.h"
 #include "colormac.h"
 #include "context.h"
 #include "hash.h"
 #include "imports.h"
 #include "debug.h"
 #include "get.h"
+#include "pixelstore.h"
+#include "readpix.h"
 #include "texobj.h"
 #include "texformat.h"
 
@@ -341,3 +344,104 @@ _mesa_dump_textures(GLboolean dumpImages)
    DumpImages = dumpImages;
    _mesa_HashWalk(ctx->Shared->TexObjects, dump_texture_cb, ctx);
 }
+
+
+void
+_mesa_dump_color_buffer(const char *filename)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   const GLuint w = ctx->DrawBuffer->Width;
+   const GLuint h = ctx->DrawBuffer->Height;
+   GLubyte *buf;
+
+   buf = (GLubyte *) _mesa_malloc(w * h * 4);
+
+   _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
+   _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
+   _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
+
+   _mesa_ReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, buf);
+
+   _mesa_printf("ReadBuffer %p 0x%x  DrawBuffer %p 0x%x\n",
+                ctx->ReadBuffer->_ColorReadBuffer,
+                ctx->ReadBuffer->ColorReadBuffer,
+                ctx->DrawBuffer->_ColorDrawBuffers[0],
+                ctx->DrawBuffer->ColorDrawBuffer[0]);
+   _mesa_printf("Writing %d x %d color buffer to %s\n", w, h, filename);
+   write_ppm(filename, buf, w, h, 4, 0, 1, 2);
+
+   _mesa_PopClientAttrib();
+
+   _mesa_free(buf);
+}
+
+
+void
+_mesa_dump_depth_buffer(const char *filename)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   const GLuint w = ctx->DrawBuffer->Width;
+   const GLuint h = ctx->DrawBuffer->Height;
+   GLuint *buf;
+   GLubyte *buf2;
+   GLuint i;
+
+   buf = (GLuint *) _mesa_malloc(w * h * 4);  /* 4 bpp */
+   buf2 = (GLubyte *) _mesa_malloc(w * h * 3); /* 3 bpp */
+
+   _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
+   _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
+   _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
+
+   _mesa_ReadPixels(0, 0, w, h, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, buf);
+
+   /* spread 24 bits of Z across R, G, B */
+   for (i = 0; i < w * h; i++) {
+      buf2[i*3+0] = (buf[i] >> 24) & 0xff;
+      buf2[i*3+1] = (buf[i] >> 16) & 0xff;
+      buf2[i*3+2] = (buf[i] >>  8) & 0xff;
+   }
+
+   _mesa_printf("Writing %d x %d depth buffer to %s\n", w, h, filename);
+   write_ppm(filename, buf2, w, h, 3, 0, 1, 2);
+
+   _mesa_PopClientAttrib();
+
+   _mesa_free(buf);
+   _mesa_free(buf2);
+}
+
+
+void
+_mesa_dump_stencil_buffer(const char *filename)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   const GLuint w = ctx->DrawBuffer->Width;
+   const GLuint h = ctx->DrawBuffer->Height;
+   GLubyte *buf;
+   GLubyte *buf2;
+   GLuint i;
+
+   buf = (GLubyte *) _mesa_malloc(w * h);  /* 1 bpp */
+   buf2 = (GLubyte *) _mesa_malloc(w * h * 3); /* 3 bpp */
+
+   _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
+   _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
+   _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
+
+   _mesa_ReadPixels(0, 0, w, h, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, buf);
+
+   for (i = 0; i < w * h; i++) {
+      buf2[i*3+0] = buf[i];
+      buf2[i*3+1] = (buf[i] & 127) * 2;
+      buf2[i*3+2] = (buf[i] - 128) * 2;
+   }
+
+   _mesa_printf("Writing %d x %d stencil buffer to %s\n", w, h, filename);
+   write_ppm(filename, buf2, w, h, 3, 0, 1, 2);
+
+   _mesa_PopClientAttrib();
+
+   _mesa_free(buf);
+   _mesa_free(buf2);
+}
index 1862ec75b7bf7dfa9a4cd9470bce33648a4a491d..bb384c43242361dae7288b31bc285b99801737d9 100644 (file)
@@ -60,4 +60,13 @@ extern void _mesa_init_debug( GLcontext *ctx );
 extern void
 _mesa_dump_textures(GLboolean dumpImages);
 
+extern void
+_mesa_dump_color_buffer(const char *filename);
+
+extern void
+_mesa_dump_depth_buffer(const char *filename);
+
+extern void
+_mesa_dump_stencil_buffer(const char *filename);
+
 #endif
index 537ff5881f36f1f59671a3ef951954481297e72b..a9c2c306ec3f2f6695b41d29735c2f2c0c74f824 100644 (file)
@@ -4883,7 +4883,7 @@ save_Attr1fNV(GLenum attr, GLfloat x)
       n[2].f = x;
    }
 
-   ASSERT(attr < MAX_VERTEX_PROGRAM_ATTRIBS);
+   ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
    ctx->ListState.ActiveAttribSize[attr] = 1;
    ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
 
@@ -4905,7 +4905,7 @@ save_Attr2fNV(GLenum attr, GLfloat x, GLfloat y)
       n[3].f = y;
    }
 
-   ASSERT(attr < MAX_VERTEX_PROGRAM_ATTRIBS);
+   ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
    ctx->ListState.ActiveAttribSize[attr] = 2;
    ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1);
 
@@ -4928,7 +4928,7 @@ save_Attr3fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z)
       n[4].f = z;
    }
 
-   ASSERT(attr < MAX_VERTEX_PROGRAM_ATTRIBS);
+   ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
    ctx->ListState.ActiveAttribSize[attr] = 3;
    ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
 
@@ -4952,7 +4952,7 @@ save_Attr4fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
       n[5].f = w;
    }
 
-   ASSERT(attr < MAX_VERTEX_PROGRAM_ATTRIBS);
+   ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
    ctx->ListState.ActiveAttribSize[attr] = 4;
    ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w);
 
@@ -4974,7 +4974,7 @@ save_Attr1fARB(GLenum attr, GLfloat x)
       n[2].f = x;
    }
 
-   ASSERT(attr < MAX_VERTEX_ATTRIBS);
+   ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
    ctx->ListState.ActiveAttribSize[attr] = 1;
    ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
 
@@ -4996,7 +4996,7 @@ save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y)
       n[3].f = y;
    }
 
-   ASSERT(attr < MAX_VERTEX_ATTRIBS);
+   ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
    ctx->ListState.ActiveAttribSize[attr] = 2;
    ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1);
 
@@ -5019,7 +5019,7 @@ save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z)
       n[4].f = z;
    }
 
-   ASSERT(attr < MAX_VERTEX_ATTRIBS);
+   ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
    ctx->ListState.ActiveAttribSize[attr] = 3;
    ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
 
@@ -5043,7 +5043,7 @@ save_Attr4fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
       n[5].f = w;
    }
 
-   ASSERT(attr < MAX_VERTEX_ATTRIBS);
+   ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
    ctx->ListState.ActiveAttribSize[attr] = 4;
    ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w);
 
@@ -5506,7 +5506,7 @@ index_error(void)
 static void GLAPIENTRY
 save_VertexAttrib1fNV(GLuint index, GLfloat x)
 {
-   if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
+   if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
       save_Attr1fNV(index, x);
    else
       index_error();
@@ -5515,7 +5515,7 @@ save_VertexAttrib1fNV(GLuint index, GLfloat x)
 static void GLAPIENTRY
 save_VertexAttrib1fvNV(GLuint index, const GLfloat * v)
 {
-   if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
+   if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
       save_Attr1fNV(index, v[0]);
    else
       index_error();
@@ -5524,7 +5524,7 @@ save_VertexAttrib1fvNV(GLuint index, const GLfloat * v)
 static void GLAPIENTRY
 save_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y)
 {
-   if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
+   if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
       save_Attr2fNV(index, x, y);
    else
       index_error();
@@ -5533,7 +5533,7 @@ save_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y)
 static void GLAPIENTRY
 save_VertexAttrib2fvNV(GLuint index, const GLfloat * v)
 {
-   if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
+   if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
       save_Attr2fNV(index, v[0], v[1]);
    else
       index_error();
@@ -5542,7 +5542,7 @@ save_VertexAttrib2fvNV(GLuint index, const GLfloat * v)
 static void GLAPIENTRY
 save_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z)
 {
-   if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
+   if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
       save_Attr3fNV(index, x, y, z);
    else
       index_error();
@@ -5551,7 +5551,7 @@ save_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z)
 static void GLAPIENTRY
 save_VertexAttrib3fvNV(GLuint index, const GLfloat * v)
 {
-   if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
+   if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
       save_Attr3fNV(index, v[0], v[1], v[2]);
    else
       index_error();
@@ -5561,7 +5561,7 @@ static void GLAPIENTRY
 save_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y,
                       GLfloat z, GLfloat w)
 {
-   if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
+   if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
       save_Attr4fNV(index, x, y, z, w);
    else
       index_error();
@@ -5570,7 +5570,7 @@ save_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y,
 static void GLAPIENTRY
 save_VertexAttrib4fvNV(GLuint index, const GLfloat * v)
 {
-   if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
+   if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
       save_Attr4fNV(index, v[0], v[1], v[2], v[3]);
    else
       index_error();
@@ -5582,7 +5582,7 @@ save_VertexAttrib4fvNV(GLuint index, const GLfloat * v)
 static void GLAPIENTRY
 save_VertexAttrib1fARB(GLuint index, GLfloat x)
 {
-   if (index < MAX_VERTEX_ATTRIBS)
+   if (index < MAX_VERTEX_GENERIC_ATTRIBS)
       save_Attr1fARB(index, x);
    else
       index_error();
@@ -5591,7 +5591,7 @@ save_VertexAttrib1fARB(GLuint index, GLfloat x)
 static void GLAPIENTRY
 save_VertexAttrib1fvARB(GLuint index, const GLfloat * v)
 {
-   if (index < MAX_VERTEX_ATTRIBS)
+   if (index < MAX_VERTEX_GENERIC_ATTRIBS)
       save_Attr1fARB(index, v[0]);
    else
       index_error();
@@ -5600,7 +5600,7 @@ save_VertexAttrib1fvARB(GLuint index, const GLfloat * v)
 static void GLAPIENTRY
 save_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y)
 {
-   if (index < MAX_VERTEX_ATTRIBS)
+   if (index < MAX_VERTEX_GENERIC_ATTRIBS)
       save_Attr2fARB(index, x, y);
    else
       index_error();
@@ -5609,7 +5609,7 @@ save_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y)
 static void GLAPIENTRY
 save_VertexAttrib2fvARB(GLuint index, const GLfloat * v)
 {
-   if (index < MAX_VERTEX_ATTRIBS)
+   if (index < MAX_VERTEX_GENERIC_ATTRIBS)
       save_Attr2fARB(index, v[0], v[1]);
    else
       index_error();
@@ -5618,7 +5618,7 @@ save_VertexAttrib2fvARB(GLuint index, const GLfloat * v)
 static void GLAPIENTRY
 save_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z)
 {
-   if (index < MAX_VERTEX_ATTRIBS)
+   if (index < MAX_VERTEX_GENERIC_ATTRIBS)
       save_Attr3fARB(index, x, y, z);
    else
       index_error();
@@ -5627,7 +5627,7 @@ save_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z)
 static void GLAPIENTRY
 save_VertexAttrib3fvARB(GLuint index, const GLfloat * v)
 {
-   if (index < MAX_VERTEX_ATTRIBS)
+   if (index < MAX_VERTEX_GENERIC_ATTRIBS)
       save_Attr3fARB(index, v[0], v[1], v[2]);
    else
       index_error();
@@ -5637,7 +5637,7 @@ static void GLAPIENTRY
 save_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z,
                        GLfloat w)
 {
-   if (index < MAX_VERTEX_ATTRIBS)
+   if (index < MAX_VERTEX_GENERIC_ATTRIBS)
       save_Attr4fARB(index, x, y, z, w);
    else
       index_error();
@@ -5646,7 +5646,7 @@ save_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z,
 static void GLAPIENTRY
 save_VertexAttrib4fvARB(GLuint index, const GLfloat * v)
 {
-   if (index < MAX_VERTEX_ATTRIBS)
+   if (index < MAX_VERTEX_GENERIC_ATTRIBS)
       save_Attr4fARB(index, v[0], v[1], v[2], v[3]);
    else
       index_error();
@@ -6806,10 +6806,10 @@ _mesa_NewList(GLuint name, GLenum mode)
 
    /* Reset acumulated list state:
     */
-   for (i = 0; i < VERT_ATTRIB_MAX; i++)
+   for (i = 0; i < Elements(ctx->ListState.ActiveAttribSize); i++)
       ctx->ListState.ActiveAttribSize[i] = 0;
 
-   for (i = 0; i < MAT_ATTRIB_MAX; i++)
+   for (i = 0; i < Elements(ctx->ListState.ActiveMaterialSize); i++)
       ctx->ListState.ActiveMaterialSize[i] = 0;
 
    ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
@@ -8238,6 +8238,15 @@ _mesa_init_dlist_table(struct _glapi_table *table)
    SET_ProgramEnvParameters4fvEXT(table, save_ProgramEnvParameters4fvEXT);
    SET_ProgramLocalParameters4fvEXT(table, save_ProgramLocalParameters4fvEXT);
 #endif
+
+   /* ARB 50. GL_ARB_map_buffer_range */
+#if FEATURE_ARB_map_buffer_range
+   SET_MapBufferRange(table, _mesa_MapBufferRange); /* no dlist save */
+   SET_FlushMappedBufferRange(table, _mesa_FlushMappedBufferRange); /* no dl */
+#endif
+
+   /* ARB 59. GL_ARB_copy_buffer */
+   SET_CopyBufferSubData(table, _mesa_CopyBufferSubData); /* no dlist save */
 }
 
 
index f432be183cb8bad6899e134b45b8100d1c284e61..48268fcd277fab633d2c7ae18709bcb3d38bf97b 100644 (file)
@@ -119,6 +119,7 @@ client_state(GLcontext *ctx, GLenum cap, GLboolean state)
          CHECK_EXTENSION(NV_vertex_program, cap);
          {
             GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
+            ASSERT(n < Elements(ctx->Array.ArrayObj->VertexAttrib));
             var = &ctx->Array.ArrayObj->VertexAttrib[n].Enabled;
             flag = _NEW_ARRAY_ATTRIB(n);
          }
@@ -222,14 +223,16 @@ get_texcoord_unit(GLcontext *ctx)
 
 /**
  * Helper function to enable or disable a texture target.
+ * \param bit  one of the TEXTURE_x_BIT values
+ * \return GL_TRUE if state is changing or GL_FALSE if no change
  */
 static GLboolean
-enable_texture(GLcontext *ctx, GLboolean state, GLbitfield bit)
+enable_texture(GLcontext *ctx, GLboolean state, GLbitfield texBit)
 {
    const GLuint curr = ctx->Texture.CurrentUnit;
    struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
-   const GLuint newenabled = (!state)
-       ? (texUnit->Enabled & ~bit) :  (texUnit->Enabled | bit);
+   const GLbitfield newenabled = state
+      ? (texUnit->Enabled | texBit) : (texUnit->Enabled & ~texBit);
 
    if (!ctx->DrawBuffer->Visual.rgbMode || texUnit->Enabled == newenabled)
        return GL_FALSE;
@@ -1314,6 +1317,7 @@ _mesa_IsEnabled( GLenum cap )
          CHECK_EXTENSION(NV_vertex_program);
          {
             GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
+            ASSERT(n < Elements(ctx->Array.ArrayObj->VertexAttrib));
             return (ctx->Array.ArrayObj->VertexAttrib[n].Enabled != 0);
          }
       case GL_MAP1_VERTEX_ATTRIB0_4_NV:
index c077bc0a89a967857c627118fce77ac1403e0a0c..aa4351dfa162c632b12dd36bed69707b407495b1 100644 (file)
@@ -334,6 +334,8 @@ LONGSTRING static const char enum_string_table[] =
    "GL_COPY\0"
    "GL_COPY_INVERTED\0"
    "GL_COPY_PIXEL_TOKEN\0"
+   "GL_COPY_READ_BUFFER\0"
+   "GL_COPY_WRITE_BUFFER\0"
    "GL_CULL_FACE\0"
    "GL_CULL_FACE_MODE\0"
    "GL_CULL_VERTEX_EXT\0"
@@ -819,7 +821,13 @@ LONGSTRING static const char enum_string_table[] =
    "GL_MAP2_VERTEX_ATTRIB8_4_NV\0"
    "GL_MAP2_VERTEX_ATTRIB9_4_NV\0"
    "GL_MAP_COLOR\0"
+   "GL_MAP_FLUSH_EXPLICIT_BIT\0"
+   "GL_MAP_INVALIDATE_BUFFER_BIT\0"
+   "GL_MAP_INVALIDATE_RANGE_BIT\0"
+   "GL_MAP_READ_BIT\0"
    "GL_MAP_STENCIL\0"
+   "GL_MAP_UNSYNCHRONIZED_BIT\0"
+   "GL_MAP_WRITE_BIT\0"
    "GL_MATRIX0_ARB\0"
    "GL_MATRIX0_NV\0"
    "GL_MATRIX10_ARB\0"
@@ -1858,7 +1866,7 @@ LONGSTRING static const char enum_string_table[] =
    "GL_ZOOM_Y\0"
    ;
 
-static const enum_elt all_enums[1820] =
+static const enum_elt all_enums[1828] =
 {
    {     0, 0x00000600 }, /* GL_2D */
    {     6, 0x00001407 }, /* GL_2_BYTES */
@@ -2158,2131 +2166,2139 @@ static const enum_elt all_enums[1820] =
    {  6027, 0x00001503 }, /* GL_COPY */
    {  6035, 0x0000150C }, /* GL_COPY_INVERTED */
    {  6052, 0x00000706 }, /* GL_COPY_PIXEL_TOKEN */
-   {  6072, 0x00000B44 }, /* GL_CULL_FACE */
-   {  6085, 0x00000B45 }, /* GL_CULL_FACE_MODE */
-   {  6103, 0x000081AA }, /* GL_CULL_VERTEX_EXT */
-   {  6122, 0x000081AC }, /* GL_CULL_VERTEX_EYE_POSITION_EXT */
-   {  6154, 0x000081AB }, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */
-   {  6189, 0x00008626 }, /* GL_CURRENT_ATTRIB_NV */
-   {  6210, 0x00000001 }, /* GL_CURRENT_BIT */
-   {  6225, 0x00000B00 }, /* GL_CURRENT_COLOR */
-   {  6242, 0x00008453 }, /* GL_CURRENT_FOG_COORD */
-   {  6263, 0x00008453 }, /* GL_CURRENT_FOG_COORDINATE */
-   {  6289, 0x00000B01 }, /* GL_CURRENT_INDEX */
-   {  6306, 0x00008641 }, /* GL_CURRENT_MATRIX_ARB */
-   {  6328, 0x00008845 }, /* GL_CURRENT_MATRIX_INDEX_ARB */
-   {  6356, 0x00008641 }, /* GL_CURRENT_MATRIX_NV */
-   {  6377, 0x00008640 }, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */
-   {  6411, 0x00008640 }, /* GL_CURRENT_MATRIX_STACK_DEPTH_NV */
-   {  6444, 0x00000B02 }, /* GL_CURRENT_NORMAL */
-   {  6462, 0x00008843 }, /* GL_CURRENT_PALETTE_MATRIX_ARB */
-   {  6492, 0x00008B8D }, /* GL_CURRENT_PROGRAM */
-   {  6511, 0x00008865 }, /* GL_CURRENT_QUERY */
-   {  6528, 0x00008865 }, /* GL_CURRENT_QUERY_ARB */
-   {  6549, 0x00000B04 }, /* GL_CURRENT_RASTER_COLOR */
-   {  6573, 0x00000B09 }, /* GL_CURRENT_RASTER_DISTANCE */
-   {  6600, 0x00000B05 }, /* GL_CURRENT_RASTER_INDEX */
-   {  6624, 0x00000B07 }, /* GL_CURRENT_RASTER_POSITION */
-   {  6651, 0x00000B08 }, /* GL_CURRENT_RASTER_POSITION_VALID */
-   {  6684, 0x0000845F }, /* GL_CURRENT_RASTER_SECONDARY_COLOR */
-   {  6718, 0x00000B06 }, /* GL_CURRENT_RASTER_TEXTURE_COORDS */
-   {  6751, 0x00008459 }, /* GL_CURRENT_SECONDARY_COLOR */
-   {  6778, 0x00000B03 }, /* GL_CURRENT_TEXTURE_COORDS */
-   {  6804, 0x00008626 }, /* GL_CURRENT_VERTEX_ATTRIB */
-   {  6829, 0x00008626 }, /* GL_CURRENT_VERTEX_ATTRIB_ARB */
-   {  6858, 0x000086A8 }, /* GL_CURRENT_WEIGHT_ARB */
-   {  6880, 0x00000900 }, /* GL_CW */
-   {  6886, 0x0000875B }, /* GL_DEBUG_ASSERT_MESA */
-   {  6907, 0x00008759 }, /* GL_DEBUG_OBJECT_MESA */
-   {  6928, 0x0000875A }, /* GL_DEBUG_PRINT_MESA */
-   {  6948, 0x00002101 }, /* GL_DECAL */
-   {  6957, 0x00001E03 }, /* GL_DECR */
-   {  6965, 0x00008508 }, /* GL_DECR_WRAP */
-   {  6978, 0x00008508 }, /* GL_DECR_WRAP_EXT */
-   {  6995, 0x00008B80 }, /* GL_DELETE_STATUS */
-   {  7012, 0x00001801 }, /* GL_DEPTH */
-   {  7021, 0x000088F0 }, /* GL_DEPTH24_STENCIL8 */
-   {  7041, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT */
-   {  7061, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT_EXT */
-   {  7085, 0x00000D1F }, /* GL_DEPTH_BIAS */
-   {  7099, 0x00000D56 }, /* GL_DEPTH_BITS */
-   {  7113, 0x00008891 }, /* GL_DEPTH_BOUNDS_EXT */
-   {  7133, 0x00008890 }, /* GL_DEPTH_BOUNDS_TEST_EXT */
-   {  7158, 0x00000100 }, /* GL_DEPTH_BUFFER_BIT */
-   {  7178, 0x0000864F }, /* GL_DEPTH_CLAMP_NV */
-   {  7196, 0x00000B73 }, /* GL_DEPTH_CLEAR_VALUE */
-   {  7217, 0x00001902 }, /* GL_DEPTH_COMPONENT */
-   {  7236, 0x000081A5 }, /* GL_DEPTH_COMPONENT16 */
-   {  7257, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_ARB */
-   {  7282, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_SGIX */
-   {  7308, 0x000081A6 }, /* GL_DEPTH_COMPONENT24 */
-   {  7329, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_ARB */
-   {  7354, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_SGIX */
-   {  7380, 0x000081A7 }, /* GL_DEPTH_COMPONENT32 */
-   {  7401, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_ARB */
-   {  7426, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_SGIX */
-   {  7452, 0x00000B74 }, /* GL_DEPTH_FUNC */
-   {  7466, 0x00000B70 }, /* GL_DEPTH_RANGE */
-   {  7481, 0x00000D1E }, /* GL_DEPTH_SCALE */
-   {  7496, 0x000084F9 }, /* GL_DEPTH_STENCIL */
-   {  7513, 0x0000821A }, /* GL_DEPTH_STENCIL_ATTACHMENT */
-   {  7541, 0x000084F9 }, /* GL_DEPTH_STENCIL_NV */
-   {  7561, 0x0000886F }, /* GL_DEPTH_STENCIL_TO_BGRA_NV */
-   {  7589, 0x0000886E }, /* GL_DEPTH_STENCIL_TO_RGBA_NV */
-   {  7617, 0x00000B71 }, /* GL_DEPTH_TEST */
-   {  7631, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE */
-   {  7653, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE_ARB */
-   {  7679, 0x00000B72 }, /* GL_DEPTH_WRITEMASK */
-   {  7698, 0x00001201 }, /* GL_DIFFUSE */
-   {  7709, 0x00000BD0 }, /* GL_DITHER */
-   {  7719, 0x00000A02 }, /* GL_DOMAIN */
-   {  7729, 0x00001100 }, /* GL_DONT_CARE */
-   {  7742, 0x000086AE }, /* GL_DOT3_RGB */
-   {  7754, 0x000086AF }, /* GL_DOT3_RGBA */
-   {  7767, 0x000086AF }, /* GL_DOT3_RGBA_ARB */
-   {  7784, 0x00008741 }, /* GL_DOT3_RGBA_EXT */
-   {  7801, 0x000086AE }, /* GL_DOT3_RGB_ARB */
-   {  7817, 0x00008740 }, /* GL_DOT3_RGB_EXT */
-   {  7833, 0x0000140A }, /* GL_DOUBLE */
-   {  7843, 0x00000C32 }, /* GL_DOUBLEBUFFER */
-   {  7859, 0x00000C01 }, /* GL_DRAW_BUFFER */
-   {  7874, 0x00008825 }, /* GL_DRAW_BUFFER0 */
-   {  7890, 0x00008825 }, /* GL_DRAW_BUFFER0_ARB */
-   {  7910, 0x00008825 }, /* GL_DRAW_BUFFER0_ATI */
-   {  7930, 0x00008826 }, /* GL_DRAW_BUFFER1 */
-   {  7946, 0x0000882F }, /* GL_DRAW_BUFFER10 */
-   {  7963, 0x0000882F }, /* GL_DRAW_BUFFER10_ARB */
-   {  7984, 0x0000882F }, /* GL_DRAW_BUFFER10_ATI */
-   {  8005, 0x00008830 }, /* GL_DRAW_BUFFER11 */
-   {  8022, 0x00008830 }, /* GL_DRAW_BUFFER11_ARB */
-   {  8043, 0x00008830 }, /* GL_DRAW_BUFFER11_ATI */
-   {  8064, 0x00008831 }, /* GL_DRAW_BUFFER12 */
-   {  8081, 0x00008831 }, /* GL_DRAW_BUFFER12_ARB */
-   {  8102, 0x00008831 }, /* GL_DRAW_BUFFER12_ATI */
-   {  8123, 0x00008832 }, /* GL_DRAW_BUFFER13 */
-   {  8140, 0x00008832 }, /* GL_DRAW_BUFFER13_ARB */
-   {  8161, 0x00008832 }, /* GL_DRAW_BUFFER13_ATI */
-   {  8182, 0x00008833 }, /* GL_DRAW_BUFFER14 */
-   {  8199, 0x00008833 }, /* GL_DRAW_BUFFER14_ARB */
-   {  8220, 0x00008833 }, /* GL_DRAW_BUFFER14_ATI */
-   {  8241, 0x00008834 }, /* GL_DRAW_BUFFER15 */
-   {  8258, 0x00008834 }, /* GL_DRAW_BUFFER15_ARB */
-   {  8279, 0x00008834 }, /* GL_DRAW_BUFFER15_ATI */
-   {  8300, 0x00008826 }, /* GL_DRAW_BUFFER1_ARB */
-   {  8320, 0x00008826 }, /* GL_DRAW_BUFFER1_ATI */
-   {  8340, 0x00008827 }, /* GL_DRAW_BUFFER2 */
-   {  8356, 0x00008827 }, /* GL_DRAW_BUFFER2_ARB */
-   {  8376, 0x00008827 }, /* GL_DRAW_BUFFER2_ATI */
-   {  8396, 0x00008828 }, /* GL_DRAW_BUFFER3 */
-   {  8412, 0x00008828 }, /* GL_DRAW_BUFFER3_ARB */
-   {  8432, 0x00008828 }, /* GL_DRAW_BUFFER3_ATI */
-   {  8452, 0x00008829 }, /* GL_DRAW_BUFFER4 */
-   {  8468, 0x00008829 }, /* GL_DRAW_BUFFER4_ARB */
-   {  8488, 0x00008829 }, /* GL_DRAW_BUFFER4_ATI */
-   {  8508, 0x0000882A }, /* GL_DRAW_BUFFER5 */
-   {  8524, 0x0000882A }, /* GL_DRAW_BUFFER5_ARB */
-   {  8544, 0x0000882A }, /* GL_DRAW_BUFFER5_ATI */
-   {  8564, 0x0000882B }, /* GL_DRAW_BUFFER6 */
-   {  8580, 0x0000882B }, /* GL_DRAW_BUFFER6_ARB */
-   {  8600, 0x0000882B }, /* GL_DRAW_BUFFER6_ATI */
-   {  8620, 0x0000882C }, /* GL_DRAW_BUFFER7 */
-   {  8636, 0x0000882C }, /* GL_DRAW_BUFFER7_ARB */
-   {  8656, 0x0000882C }, /* GL_DRAW_BUFFER7_ATI */
-   {  8676, 0x0000882D }, /* GL_DRAW_BUFFER8 */
-   {  8692, 0x0000882D }, /* GL_DRAW_BUFFER8_ARB */
-   {  8712, 0x0000882D }, /* GL_DRAW_BUFFER8_ATI */
-   {  8732, 0x0000882E }, /* GL_DRAW_BUFFER9 */
-   {  8748, 0x0000882E }, /* GL_DRAW_BUFFER9_ARB */
-   {  8768, 0x0000882E }, /* GL_DRAW_BUFFER9_ATI */
-   {  8788, 0x00008CA9 }, /* GL_DRAW_FRAMEBUFFER */
-   {  8808, 0x00008CA6 }, /* GL_DRAW_FRAMEBUFFER_BINDING_EXT */
-   {  8840, 0x00008CA9 }, /* GL_DRAW_FRAMEBUFFER_EXT */
-   {  8864, 0x00000705 }, /* GL_DRAW_PIXEL_TOKEN */
-   {  8884, 0x00000304 }, /* GL_DST_ALPHA */
-   {  8897, 0x00000306 }, /* GL_DST_COLOR */
-   {  8910, 0x0000877A }, /* GL_DU8DV8_ATI */
-   {  8924, 0x00008779 }, /* GL_DUDV_ATI */
-   {  8936, 0x000088EA }, /* GL_DYNAMIC_COPY */
-   {  8952, 0x000088EA }, /* GL_DYNAMIC_COPY_ARB */
-   {  8972, 0x000088E8 }, /* GL_DYNAMIC_DRAW */
-   {  8988, 0x000088E8 }, /* GL_DYNAMIC_DRAW_ARB */
-   {  9008, 0x000088E9 }, /* GL_DYNAMIC_READ */
-   {  9024, 0x000088E9 }, /* GL_DYNAMIC_READ_ARB */
-   {  9044, 0x00000B43 }, /* GL_EDGE_FLAG */
-   {  9057, 0x00008079 }, /* GL_EDGE_FLAG_ARRAY */
-   {  9076, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */
-   {  9110, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB */
-   {  9148, 0x00008093 }, /* GL_EDGE_FLAG_ARRAY_POINTER */
-   {  9175, 0x0000808C }, /* GL_EDGE_FLAG_ARRAY_STRIDE */
-   {  9201, 0x00008893 }, /* GL_ELEMENT_ARRAY_BUFFER */
-   {  9225, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */
-   {  9257, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB */
-   {  9293, 0x00001600 }, /* GL_EMISSION */
-   {  9305, 0x00002000 }, /* GL_ENABLE_BIT */
-   {  9319, 0x00000202 }, /* GL_EQUAL */
-   {  9328, 0x00001509 }, /* GL_EQUIV */
-   {  9337, 0x00010000 }, /* GL_EVAL_BIT */
-   {  9349, 0x00000800 }, /* GL_EXP */
-   {  9356, 0x00000801 }, /* GL_EXP2 */
-   {  9364, 0x00001F03 }, /* GL_EXTENSIONS */
-   {  9378, 0x00002400 }, /* GL_EYE_LINEAR */
-   {  9392, 0x00002502 }, /* GL_EYE_PLANE */
-   {  9405, 0x0000855C }, /* GL_EYE_PLANE_ABSOLUTE_NV */
-   {  9430, 0x0000855B }, /* GL_EYE_RADIAL_NV */
-   {  9447, 0x00000000 }, /* GL_FALSE */
-   {  9456, 0x00001101 }, /* GL_FASTEST */
-   {  9467, 0x00001C01 }, /* GL_FEEDBACK */
-   {  9479, 0x00000DF0 }, /* GL_FEEDBACK_BUFFER_POINTER */
-   {  9506, 0x00000DF1 }, /* GL_FEEDBACK_BUFFER_SIZE */
-   {  9530, 0x00000DF2 }, /* GL_FEEDBACK_BUFFER_TYPE */
-   {  9554, 0x00001B02 }, /* GL_FILL */
-   {  9562, 0x00001D00 }, /* GL_FLAT */
-   {  9570, 0x00001406 }, /* GL_FLOAT */
-   {  9579, 0x00008B5A }, /* GL_FLOAT_MAT2 */
-   {  9593, 0x00008B5A }, /* GL_FLOAT_MAT2_ARB */
-   {  9611, 0x00008B65 }, /* GL_FLOAT_MAT2x3 */
-   {  9627, 0x00008B66 }, /* GL_FLOAT_MAT2x4 */
-   {  9643, 0x00008B5B }, /* GL_FLOAT_MAT3 */
-   {  9657, 0x00008B5B }, /* GL_FLOAT_MAT3_ARB */
-   {  9675, 0x00008B67 }, /* GL_FLOAT_MAT3x2 */
-   {  9691, 0x00008B68 }, /* GL_FLOAT_MAT3x4 */
-   {  9707, 0x00008B5C }, /* GL_FLOAT_MAT4 */
-   {  9721, 0x00008B5C }, /* GL_FLOAT_MAT4_ARB */
-   {  9739, 0x00008B69 }, /* GL_FLOAT_MAT4x2 */
-   {  9755, 0x00008B6A }, /* GL_FLOAT_MAT4x3 */
-   {  9771, 0x00008B50 }, /* GL_FLOAT_VEC2 */
-   {  9785, 0x00008B50 }, /* GL_FLOAT_VEC2_ARB */
-   {  9803, 0x00008B51 }, /* GL_FLOAT_VEC3 */
-   {  9817, 0x00008B51 }, /* GL_FLOAT_VEC3_ARB */
-   {  9835, 0x00008B52 }, /* GL_FLOAT_VEC4 */
-   {  9849, 0x00008B52 }, /* GL_FLOAT_VEC4_ARB */
-   {  9867, 0x00000B60 }, /* GL_FOG */
-   {  9874, 0x00000080 }, /* GL_FOG_BIT */
-   {  9885, 0x00000B66 }, /* GL_FOG_COLOR */
-   {  9898, 0x00008451 }, /* GL_FOG_COORD */
-   {  9911, 0x00008451 }, /* GL_FOG_COORDINATE */
-   {  9929, 0x00008457 }, /* GL_FOG_COORDINATE_ARRAY */
-   {  9953, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */
-   {  9992, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB */
-   { 10035, 0x00008456 }, /* GL_FOG_COORDINATE_ARRAY_POINTER */
-   { 10067, 0x00008455 }, /* GL_FOG_COORDINATE_ARRAY_STRIDE */
-   { 10098, 0x00008454 }, /* GL_FOG_COORDINATE_ARRAY_TYPE */
-   { 10127, 0x00008450 }, /* GL_FOG_COORDINATE_SOURCE */
-   { 10152, 0x00008457 }, /* GL_FOG_COORD_ARRAY */
-   { 10171, 0x0000889D }, /* GL_FOG_COORD_ARRAY_BUFFER_BINDING */
-   { 10205, 0x00008456 }, /* GL_FOG_COORD_ARRAY_POINTER */
-   { 10232, 0x00008455 }, /* GL_FOG_COORD_ARRAY_STRIDE */
-   { 10258, 0x00008454 }, /* GL_FOG_COORD_ARRAY_TYPE */
-   { 10282, 0x00008450 }, /* GL_FOG_COORD_SRC */
-   { 10299, 0x00000B62 }, /* GL_FOG_DENSITY */
-   { 10314, 0x0000855A }, /* GL_FOG_DISTANCE_MODE_NV */
-   { 10338, 0x00000B64 }, /* GL_FOG_END */
-   { 10349, 0x00000C54 }, /* GL_FOG_HINT */
-   { 10361, 0x00000B61 }, /* GL_FOG_INDEX */
-   { 10374, 0x00000B65 }, /* GL_FOG_MODE */
-   { 10386, 0x00008198 }, /* GL_FOG_OFFSET_SGIX */
-   { 10405, 0x00008199 }, /* GL_FOG_OFFSET_VALUE_SGIX */
-   { 10430, 0x00000B63 }, /* GL_FOG_START */
-   { 10443, 0x00008452 }, /* GL_FRAGMENT_DEPTH */
-   { 10461, 0x00008804 }, /* GL_FRAGMENT_PROGRAM_ARB */
-   { 10485, 0x00008B30 }, /* GL_FRAGMENT_SHADER */
-   { 10504, 0x00008B30 }, /* GL_FRAGMENT_SHADER_ARB */
-   { 10527, 0x00008B8B }, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */
-   { 10562, 0x00008D40 }, /* GL_FRAMEBUFFER */
-   { 10577, 0x00008215 }, /* GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */
-   { 10614, 0x00008214 }, /* GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */
-   { 10650, 0x00008210 }, /* GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */
-   { 10691, 0x00008211 }, /* GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */
-   { 10732, 0x00008216 }, /* GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */
-   { 10769, 0x00008213 }, /* GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */
-   { 10806, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */
-   { 10844, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT */
-   { 10886, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */
-   { 10924, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT */
-   { 10966, 0x00008212 }, /* GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */
-   { 11001, 0x00008217 }, /* GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */
-   { 11040, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT */
-   { 11089, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */
-   { 11137, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT */
-   { 11189, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */
-   { 11229, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */
-   { 11273, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */
-   { 11313, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT */
-   { 11357, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING_EXT */
-   { 11384, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE */
-   { 11408, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE_EXT */
-   { 11436, 0x00008218 }, /* GL_FRAMEBUFFER_DEFAULT */
-   { 11459, 0x00008D40 }, /* GL_FRAMEBUFFER_EXT */
-   { 11478, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */
-   { 11515, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT */
-   { 11556, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */
-   { 11597, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT */
-   { 11639, 0x00008CD8 }, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */
-   { 11690, 0x00008CDA }, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */
-   { 11728, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */
-   { 11773, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT */
-   { 11822, 0x00008D56 }, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */
-   { 11860, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT */
-   { 11902, 0x00008CDE }, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */
-   { 11934, 0x00008219 }, /* GL_FRAMEBUFFER_UNDEFINED */
-   { 11959, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED */
-   { 11986, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED_EXT */
-   { 12017, 0x00000404 }, /* GL_FRONT */
-   { 12026, 0x00000408 }, /* GL_FRONT_AND_BACK */
-   { 12044, 0x00000B46 }, /* GL_FRONT_FACE */
-   { 12058, 0x00000400 }, /* GL_FRONT_LEFT */
-   { 12072, 0x00000401 }, /* GL_FRONT_RIGHT */
-   { 12087, 0x00008006 }, /* GL_FUNC_ADD */
-   { 12099, 0x00008006 }, /* GL_FUNC_ADD_EXT */
-   { 12115, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT */
-   { 12140, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT_EXT */
-   { 12169, 0x0000800A }, /* GL_FUNC_SUBTRACT */
-   { 12186, 0x0000800A }, /* GL_FUNC_SUBTRACT_EXT */
-   { 12207, 0x00008191 }, /* GL_GENERATE_MIPMAP */
-   { 12226, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT */
-   { 12250, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT_SGIS */
-   { 12279, 0x00008191 }, /* GL_GENERATE_MIPMAP_SGIS */
-   { 12303, 0x00000206 }, /* GL_GEQUAL */
-   { 12313, 0x00000204 }, /* GL_GREATER */
-   { 12324, 0x00001904 }, /* GL_GREEN */
-   { 12333, 0x00000D19 }, /* GL_GREEN_BIAS */
-   { 12347, 0x00000D53 }, /* GL_GREEN_BITS */
-   { 12361, 0x00000D18 }, /* GL_GREEN_SCALE */
-   { 12376, 0x00008000 }, /* GL_HINT_BIT */
-   { 12388, 0x00008024 }, /* GL_HISTOGRAM */
-   { 12401, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE */
-   { 12425, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE_EXT */
-   { 12453, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE */
-   { 12476, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE_EXT */
-   { 12503, 0x00008024 }, /* GL_HISTOGRAM_EXT */
-   { 12520, 0x00008027 }, /* GL_HISTOGRAM_FORMAT */
-   { 12540, 0x00008027 }, /* GL_HISTOGRAM_FORMAT_EXT */
-   { 12564, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE */
-   { 12588, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE_EXT */
-   { 12616, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE */
-   { 12644, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE_EXT */
-   { 12676, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE */
-   { 12698, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE_EXT */
-   { 12724, 0x0000802D }, /* GL_HISTOGRAM_SINK */
-   { 12742, 0x0000802D }, /* GL_HISTOGRAM_SINK_EXT */
-   { 12764, 0x00008026 }, /* GL_HISTOGRAM_WIDTH */
-   { 12783, 0x00008026 }, /* GL_HISTOGRAM_WIDTH_EXT */
-   { 12806, 0x0000862A }, /* GL_IDENTITY_NV */
-   { 12821, 0x00008150 }, /* GL_IGNORE_BORDER_HP */
-   { 12841, 0x00008B9B }, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */
-   { 12881, 0x00008B9A }, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */
-   { 12919, 0x00001E02 }, /* GL_INCR */
-   { 12927, 0x00008507 }, /* GL_INCR_WRAP */
-   { 12940, 0x00008507 }, /* GL_INCR_WRAP_EXT */
-   { 12957, 0x00008222 }, /* GL_INDEX */
-   { 12966, 0x00008077 }, /* GL_INDEX_ARRAY */
-   { 12981, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING */
-   { 13011, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING_ARB */
-   { 13045, 0x00008091 }, /* GL_INDEX_ARRAY_POINTER */
-   { 13068, 0x00008086 }, /* GL_INDEX_ARRAY_STRIDE */
-   { 13090, 0x00008085 }, /* GL_INDEX_ARRAY_TYPE */
-   { 13110, 0x00000D51 }, /* GL_INDEX_BITS */
-   { 13124, 0x00000C20 }, /* GL_INDEX_CLEAR_VALUE */
-   { 13145, 0x00000BF1 }, /* GL_INDEX_LOGIC_OP */
-   { 13163, 0x00000C30 }, /* GL_INDEX_MODE */
-   { 13177, 0x00000D13 }, /* GL_INDEX_OFFSET */
-   { 13193, 0x00000D12 }, /* GL_INDEX_SHIFT */
-   { 13208, 0x00000C21 }, /* GL_INDEX_WRITEMASK */
-   { 13227, 0x00008B84 }, /* GL_INFO_LOG_LENGTH */
-   { 13246, 0x00001404 }, /* GL_INT */
-   { 13253, 0x00008049 }, /* GL_INTENSITY */
-   { 13266, 0x0000804C }, /* GL_INTENSITY12 */
-   { 13281, 0x0000804C }, /* GL_INTENSITY12_EXT */
-   { 13300, 0x0000804D }, /* GL_INTENSITY16 */
-   { 13315, 0x0000804D }, /* GL_INTENSITY16_EXT */
-   { 13334, 0x0000804A }, /* GL_INTENSITY4 */
-   { 13348, 0x0000804A }, /* GL_INTENSITY4_EXT */
-   { 13366, 0x0000804B }, /* GL_INTENSITY8 */
-   { 13380, 0x0000804B }, /* GL_INTENSITY8_EXT */
-   { 13398, 0x00008049 }, /* GL_INTENSITY_EXT */
-   { 13415, 0x00008575 }, /* GL_INTERPOLATE */
-   { 13430, 0x00008575 }, /* GL_INTERPOLATE_ARB */
-   { 13449, 0x00008575 }, /* GL_INTERPOLATE_EXT */
-   { 13468, 0x00008B53 }, /* GL_INT_VEC2 */
-   { 13480, 0x00008B53 }, /* GL_INT_VEC2_ARB */
-   { 13496, 0x00008B54 }, /* GL_INT_VEC3 */
-   { 13508, 0x00008B54 }, /* GL_INT_VEC3_ARB */
-   { 13524, 0x00008B55 }, /* GL_INT_VEC4 */
-   { 13536, 0x00008B55 }, /* GL_INT_VEC4_ARB */
-   { 13552, 0x00000500 }, /* GL_INVALID_ENUM */
-   { 13568, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION */
-   { 13601, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION_EXT */
-   { 13638, 0x00000502 }, /* GL_INVALID_OPERATION */
-   { 13659, 0x00000501 }, /* GL_INVALID_VALUE */
-   { 13676, 0x0000862B }, /* GL_INVERSE_NV */
-   { 13690, 0x0000862D }, /* GL_INVERSE_TRANSPOSE_NV */
-   { 13714, 0x0000150A }, /* GL_INVERT */
-   { 13724, 0x00001E00 }, /* GL_KEEP */
-   { 13732, 0x00000406 }, /* GL_LEFT */
-   { 13740, 0x00000203 }, /* GL_LEQUAL */
-   { 13750, 0x00000201 }, /* GL_LESS */
-   { 13758, 0x00004000 }, /* GL_LIGHT0 */
-   { 13768, 0x00004001 }, /* GL_LIGHT1 */
-   { 13778, 0x00004002 }, /* GL_LIGHT2 */
-   { 13788, 0x00004003 }, /* GL_LIGHT3 */
-   { 13798, 0x00004004 }, /* GL_LIGHT4 */
-   { 13808, 0x00004005 }, /* GL_LIGHT5 */
-   { 13818, 0x00004006 }, /* GL_LIGHT6 */
-   { 13828, 0x00004007 }, /* GL_LIGHT7 */
-   { 13838, 0x00000B50 }, /* GL_LIGHTING */
-   { 13850, 0x00000040 }, /* GL_LIGHTING_BIT */
-   { 13866, 0x00000B53 }, /* GL_LIGHT_MODEL_AMBIENT */
-   { 13889, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL */
-   { 13918, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL_EXT */
-   { 13951, 0x00000B51 }, /* GL_LIGHT_MODEL_LOCAL_VIEWER */
-   { 13979, 0x00000B52 }, /* GL_LIGHT_MODEL_TWO_SIDE */
-   { 14003, 0x00001B01 }, /* GL_LINE */
-   { 14011, 0x00002601 }, /* GL_LINEAR */
-   { 14021, 0x00001208 }, /* GL_LINEAR_ATTENUATION */
-   { 14043, 0x00008170 }, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */
-   { 14073, 0x0000844F }, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */
-   { 14104, 0x00002703 }, /* GL_LINEAR_MIPMAP_LINEAR */
-   { 14128, 0x00002701 }, /* GL_LINEAR_MIPMAP_NEAREST */
-   { 14153, 0x00000001 }, /* GL_LINES */
-   { 14162, 0x00000004 }, /* GL_LINE_BIT */
-   { 14174, 0x00000002 }, /* GL_LINE_LOOP */
-   { 14187, 0x00000707 }, /* GL_LINE_RESET_TOKEN */
-   { 14207, 0x00000B20 }, /* GL_LINE_SMOOTH */
-   { 14222, 0x00000C52 }, /* GL_LINE_SMOOTH_HINT */
-   { 14242, 0x00000B24 }, /* GL_LINE_STIPPLE */
-   { 14258, 0x00000B25 }, /* GL_LINE_STIPPLE_PATTERN */
-   { 14282, 0x00000B26 }, /* GL_LINE_STIPPLE_REPEAT */
-   { 14305, 0x00000003 }, /* GL_LINE_STRIP */
-   { 14319, 0x00000702 }, /* GL_LINE_TOKEN */
-   { 14333, 0x00000B21 }, /* GL_LINE_WIDTH */
-   { 14347, 0x00000B23 }, /* GL_LINE_WIDTH_GRANULARITY */
-   { 14373, 0x00000B22 }, /* GL_LINE_WIDTH_RANGE */
-   { 14393, 0x00008B82 }, /* GL_LINK_STATUS */
-   { 14408, 0x00000B32 }, /* GL_LIST_BASE */
-   { 14421, 0x00020000 }, /* GL_LIST_BIT */
-   { 14433, 0x00000B33 }, /* GL_LIST_INDEX */
-   { 14447, 0x00000B30 }, /* GL_LIST_MODE */
-   { 14460, 0x00000101 }, /* GL_LOAD */
-   { 14468, 0x00000BF1 }, /* GL_LOGIC_OP */
-   { 14480, 0x00000BF0 }, /* GL_LOGIC_OP_MODE */
-   { 14497, 0x00008CA1 }, /* GL_LOWER_LEFT */
-   { 14511, 0x00001909 }, /* GL_LUMINANCE */
-   { 14524, 0x00008041 }, /* GL_LUMINANCE12 */
-   { 14539, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12 */
-   { 14562, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12_EXT */
-   { 14589, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4 */
-   { 14611, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4_EXT */
-   { 14637, 0x00008041 }, /* GL_LUMINANCE12_EXT */
-   { 14656, 0x00008042 }, /* GL_LUMINANCE16 */
-   { 14671, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16 */
-   { 14694, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16_EXT */
-   { 14721, 0x00008042 }, /* GL_LUMINANCE16_EXT */
-   { 14740, 0x0000803F }, /* GL_LUMINANCE4 */
-   { 14754, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4 */
-   { 14775, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4_EXT */
-   { 14800, 0x0000803F }, /* GL_LUMINANCE4_EXT */
-   { 14818, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2 */
-   { 14839, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2_EXT */
-   { 14864, 0x00008040 }, /* GL_LUMINANCE8 */
-   { 14878, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8 */
-   { 14899, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8_EXT */
-   { 14924, 0x00008040 }, /* GL_LUMINANCE8_EXT */
-   { 14942, 0x0000190A }, /* GL_LUMINANCE_ALPHA */
-   { 14961, 0x00000D90 }, /* GL_MAP1_COLOR_4 */
-   { 14977, 0x00000DD0 }, /* GL_MAP1_GRID_DOMAIN */
-   { 14997, 0x00000DD1 }, /* GL_MAP1_GRID_SEGMENTS */
-   { 15019, 0x00000D91 }, /* GL_MAP1_INDEX */
-   { 15033, 0x00000D92 }, /* GL_MAP1_NORMAL */
-   { 15048, 0x00000D93 }, /* GL_MAP1_TEXTURE_COORD_1 */
-   { 15072, 0x00000D94 }, /* GL_MAP1_TEXTURE_COORD_2 */
-   { 15096, 0x00000D95 }, /* GL_MAP1_TEXTURE_COORD_3 */
-   { 15120, 0x00000D96 }, /* GL_MAP1_TEXTURE_COORD_4 */
-   { 15144, 0x00000D97 }, /* GL_MAP1_VERTEX_3 */
-   { 15161, 0x00000D98 }, /* GL_MAP1_VERTEX_4 */
-   { 15178, 0x00008660 }, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */
-   { 15206, 0x0000866A }, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */
-   { 15235, 0x0000866B }, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */
-   { 15264, 0x0000866C }, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */
-   { 15293, 0x0000866D }, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */
-   { 15322, 0x0000866E }, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */
-   { 15351, 0x0000866F }, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */
-   { 15380, 0x00008661 }, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */
-   { 15408, 0x00008662 }, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */
-   { 15436, 0x00008663 }, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */
-   { 15464, 0x00008664 }, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */
-   { 15492, 0x00008665 }, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */
-   { 15520, 0x00008666 }, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */
-   { 15548, 0x00008667 }, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */
-   { 15576, 0x00008668 }, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */
-   { 15604, 0x00008669 }, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */
-   { 15632, 0x00000DB0 }, /* GL_MAP2_COLOR_4 */
-   { 15648, 0x00000DD2 }, /* GL_MAP2_GRID_DOMAIN */
-   { 15668, 0x00000DD3 }, /* GL_MAP2_GRID_SEGMENTS */
-   { 15690, 0x00000DB1 }, /* GL_MAP2_INDEX */
-   { 15704, 0x00000DB2 }, /* GL_MAP2_NORMAL */
-   { 15719, 0x00000DB3 }, /* GL_MAP2_TEXTURE_COORD_1 */
-   { 15743, 0x00000DB4 }, /* GL_MAP2_TEXTURE_COORD_2 */
-   { 15767, 0x00000DB5 }, /* GL_MAP2_TEXTURE_COORD_3 */
-   { 15791, 0x00000DB6 }, /* GL_MAP2_TEXTURE_COORD_4 */
-   { 15815, 0x00000DB7 }, /* GL_MAP2_VERTEX_3 */
-   { 15832, 0x00000DB8 }, /* GL_MAP2_VERTEX_4 */
-   { 15849, 0x00008670 }, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */
-   { 15877, 0x0000867A }, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */
-   { 15906, 0x0000867B }, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */
-   { 15935, 0x0000867C }, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */
-   { 15964, 0x0000867D }, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */
-   { 15993, 0x0000867E }, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */
-   { 16022, 0x0000867F }, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */
-   { 16051, 0x00008671 }, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */
-   { 16079, 0x00008672 }, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */
-   { 16107, 0x00008673 }, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */
-   { 16135, 0x00008674 }, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */
-   { 16163, 0x00008675 }, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */
-   { 16191, 0x00008676 }, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */
-   { 16219, 0x00008677 }, /* GL_MAP2_VERTEX_ATTRIB7_4_NV */
-   { 16247, 0x00008678 }, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */
-   { 16275, 0x00008679 }, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */
-   { 16303, 0x00000D10 }, /* GL_MAP_COLOR */
-   { 16316, 0x00000D11 }, /* GL_MAP_STENCIL */
-   { 16331, 0x000088C0 }, /* GL_MATRIX0_ARB */
-   { 16346, 0x00008630 }, /* GL_MATRIX0_NV */
-   { 16360, 0x000088CA }, /* GL_MATRIX10_ARB */
-   { 16376, 0x000088CB }, /* GL_MATRIX11_ARB */
-   { 16392, 0x000088CC }, /* GL_MATRIX12_ARB */
-   { 16408, 0x000088CD }, /* GL_MATRIX13_ARB */
-   { 16424, 0x000088CE }, /* GL_MATRIX14_ARB */
-   { 16440, 0x000088CF }, /* GL_MATRIX15_ARB */
-   { 16456, 0x000088D0 }, /* GL_MATRIX16_ARB */
-   { 16472, 0x000088D1 }, /* GL_MATRIX17_ARB */
-   { 16488, 0x000088D2 }, /* GL_MATRIX18_ARB */
-   { 16504, 0x000088D3 }, /* GL_MATRIX19_ARB */
-   { 16520, 0x000088C1 }, /* GL_MATRIX1_ARB */
-   { 16535, 0x00008631 }, /* GL_MATRIX1_NV */
-   { 16549, 0x000088D4 }, /* GL_MATRIX20_ARB */
-   { 16565, 0x000088D5 }, /* GL_MATRIX21_ARB */
-   { 16581, 0x000088D6 }, /* GL_MATRIX22_ARB */
-   { 16597, 0x000088D7 }, /* GL_MATRIX23_ARB */
-   { 16613, 0x000088D8 }, /* GL_MATRIX24_ARB */
-   { 16629, 0x000088D9 }, /* GL_MATRIX25_ARB */
-   { 16645, 0x000088DA }, /* GL_MATRIX26_ARB */
-   { 16661, 0x000088DB }, /* GL_MATRIX27_ARB */
-   { 16677, 0x000088DC }, /* GL_MATRIX28_ARB */
-   { 16693, 0x000088DD }, /* GL_MATRIX29_ARB */
-   { 16709, 0x000088C2 }, /* GL_MATRIX2_ARB */
-   { 16724, 0x00008632 }, /* GL_MATRIX2_NV */
-   { 16738, 0x000088DE }, /* GL_MATRIX30_ARB */
-   { 16754, 0x000088DF }, /* GL_MATRIX31_ARB */
-   { 16770, 0x000088C3 }, /* GL_MATRIX3_ARB */
-   { 16785, 0x00008633 }, /* GL_MATRIX3_NV */
-   { 16799, 0x000088C4 }, /* GL_MATRIX4_ARB */
-   { 16814, 0x00008634 }, /* GL_MATRIX4_NV */
-   { 16828, 0x000088C5 }, /* GL_MATRIX5_ARB */
-   { 16843, 0x00008635 }, /* GL_MATRIX5_NV */
-   { 16857, 0x000088C6 }, /* GL_MATRIX6_ARB */
-   { 16872, 0x00008636 }, /* GL_MATRIX6_NV */
-   { 16886, 0x000088C7 }, /* GL_MATRIX7_ARB */
-   { 16901, 0x00008637 }, /* GL_MATRIX7_NV */
-   { 16915, 0x000088C8 }, /* GL_MATRIX8_ARB */
-   { 16930, 0x000088C9 }, /* GL_MATRIX9_ARB */
-   { 16945, 0x00008844 }, /* GL_MATRIX_INDEX_ARRAY_ARB */
-   { 16971, 0x00008849 }, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */
-   { 17005, 0x00008846 }, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */
-   { 17036, 0x00008848 }, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */
-   { 17069, 0x00008847 }, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */
-   { 17100, 0x00000BA0 }, /* GL_MATRIX_MODE */
-   { 17115, 0x00008840 }, /* GL_MATRIX_PALETTE_ARB */
-   { 17137, 0x00008008 }, /* GL_MAX */
-   { 17144, 0x00008073 }, /* GL_MAX_3D_TEXTURE_SIZE */
-   { 17167, 0x000088FF }, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */
-   { 17199, 0x00000D35 }, /* GL_MAX_ATTRIB_STACK_DEPTH */
-   { 17225, 0x00000D3B }, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */
-   { 17258, 0x00008177 }, /* GL_MAX_CLIPMAP_DEPTH_SGIX */
-   { 17284, 0x00008178 }, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */
-   { 17318, 0x00000D32 }, /* GL_MAX_CLIP_PLANES */
-   { 17337, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS_EXT */
-   { 17366, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */
-   { 17398, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI */
-   { 17434, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */
-   { 17470, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB */
-   { 17510, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT */
-   { 17536, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT_EXT */
-   { 17566, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH */
-   { 17591, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH_EXT */
-   { 17620, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */
-   { 17649, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB */
-   { 17682, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS */
-   { 17702, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ARB */
-   { 17726, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ATI */
-   { 17750, 0x000080E9 }, /* GL_MAX_ELEMENTS_INDICES */
-   { 17774, 0x000080E8 }, /* GL_MAX_ELEMENTS_VERTICES */
-   { 17799, 0x00000D30 }, /* GL_MAX_EVAL_ORDER */
-   { 17817, 0x00008008 }, /* GL_MAX_EXT */
-   { 17828, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */
-   { 17863, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB */
-   { 17902, 0x00000D31 }, /* GL_MAX_LIGHTS */
-   { 17916, 0x00000B31 }, /* GL_MAX_LIST_NESTING */
-   { 17936, 0x00008841 }, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */
-   { 17974, 0x00000D36 }, /* GL_MAX_MODELVIEW_STACK_DEPTH */
-   { 18003, 0x00000D37 }, /* GL_MAX_NAME_STACK_DEPTH */
-   { 18027, 0x00008842 }, /* GL_MAX_PALETTE_MATRICES_ARB */
-   { 18055, 0x00000D34 }, /* GL_MAX_PIXEL_MAP_TABLE */
-   { 18078, 0x000088B1 }, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */
-   { 18115, 0x0000880B }, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */
-   { 18151, 0x000088AD }, /* GL_MAX_PROGRAM_ATTRIBS_ARB */
-   { 18178, 0x000088F5 }, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */
-   { 18207, 0x000088B5 }, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */
-   { 18241, 0x000088F4 }, /* GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */
-   { 18277, 0x000088F6 }, /* GL_MAX_PROGRAM_IF_DEPTH_NV */
-   { 18304, 0x000088A1 }, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */
-   { 18336, 0x000088B4 }, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */
-   { 18372, 0x000088F8 }, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */
-   { 18401, 0x000088F7 }, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */
-   { 18430, 0x0000862F }, /* GL_MAX_PROGRAM_MATRICES_ARB */
-   { 18458, 0x0000862E }, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */
-   { 18496, 0x000088B3 }, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
-   { 18540, 0x0000880E }, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
-   { 18583, 0x000088AF }, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */
-   { 18617, 0x000088A3 }, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
-   { 18656, 0x000088AB }, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */
-   { 18693, 0x000088A7 }, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */
-   { 18731, 0x00008810 }, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
-   { 18774, 0x0000880F }, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
-   { 18817, 0x000088A9 }, /* GL_MAX_PROGRAM_PARAMETERS_ARB */
-   { 18847, 0x000088A5 }, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */
-   { 18878, 0x0000880D }, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */
-   { 18914, 0x0000880C }, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */
-   { 18950, 0x00000D38 }, /* GL_MAX_PROJECTION_STACK_DEPTH */
-   { 18980, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */
-   { 19014, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_NV */
-   { 19047, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE_EXT */
-   { 19076, 0x00008D57 }, /* GL_MAX_SAMPLES */
-   { 19091, 0x00008504 }, /* GL_MAX_SHININESS_NV */
-   { 19111, 0x00008505 }, /* GL_MAX_SPOT_EXPONENT_NV */
-   { 19135, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS */
-   { 19157, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS_ARB */
-   { 19183, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS */
-   { 19210, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS_ARB */
-   { 19241, 0x000084FD }, /* GL_MAX_TEXTURE_LOD_BIAS */
-   { 19265, 0x000084FF }, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */
-   { 19299, 0x00000D33 }, /* GL_MAX_TEXTURE_SIZE */
-   { 19319, 0x00000D39 }, /* GL_MAX_TEXTURE_STACK_DEPTH */
-   { 19346, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS */
-   { 19367, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS_ARB */
-   { 19392, 0x0000862F }, /* GL_MAX_TRACK_MATRICES_NV */
-   { 19417, 0x0000862E }, /* GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */
-   { 19452, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS */
-   { 19474, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS_ARB */
-   { 19500, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS */
-   { 19522, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS_ARB */
-   { 19548, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */
-   { 19582, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */
-   { 19620, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */
-   { 19653, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB */
-   { 19690, 0x000086A4 }, /* GL_MAX_VERTEX_UNITS_ARB */
-   { 19714, 0x00000D3A }, /* GL_MAX_VIEWPORT_DIMS */
-   { 19735, 0x00008007 }, /* GL_MIN */
-   { 19742, 0x0000802E }, /* GL_MINMAX */
-   { 19752, 0x0000802E }, /* GL_MINMAX_EXT */
-   { 19766, 0x0000802F }, /* GL_MINMAX_FORMAT */
-   { 19783, 0x0000802F }, /* GL_MINMAX_FORMAT_EXT */
-   { 19804, 0x00008030 }, /* GL_MINMAX_SINK */
-   { 19819, 0x00008030 }, /* GL_MINMAX_SINK_EXT */
-   { 19838, 0x00008007 }, /* GL_MIN_EXT */
-   { 19849, 0x00008370 }, /* GL_MIRRORED_REPEAT */
-   { 19868, 0x00008370 }, /* GL_MIRRORED_REPEAT_ARB */
-   { 19891, 0x00008370 }, /* GL_MIRRORED_REPEAT_IBM */
-   { 19914, 0x00008742 }, /* GL_MIRROR_CLAMP_ATI */
-   { 19934, 0x00008742 }, /* GL_MIRROR_CLAMP_EXT */
-   { 19954, 0x00008912 }, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */
-   { 19984, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_ATI */
-   { 20012, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */
-   { 20040, 0x00001700 }, /* GL_MODELVIEW */
-   { 20053, 0x00001700 }, /* GL_MODELVIEW0_ARB */
-   { 20071, 0x0000872A }, /* GL_MODELVIEW10_ARB */
-   { 20090, 0x0000872B }, /* GL_MODELVIEW11_ARB */
-   { 20109, 0x0000872C }, /* GL_MODELVIEW12_ARB */
-   { 20128, 0x0000872D }, /* GL_MODELVIEW13_ARB */
-   { 20147, 0x0000872E }, /* GL_MODELVIEW14_ARB */
-   { 20166, 0x0000872F }, /* GL_MODELVIEW15_ARB */
-   { 20185, 0x00008730 }, /* GL_MODELVIEW16_ARB */
-   { 20204, 0x00008731 }, /* GL_MODELVIEW17_ARB */
-   { 20223, 0x00008732 }, /* GL_MODELVIEW18_ARB */
-   { 20242, 0x00008733 }, /* GL_MODELVIEW19_ARB */
-   { 20261, 0x0000850A }, /* GL_MODELVIEW1_ARB */
-   { 20279, 0x00008734 }, /* GL_MODELVIEW20_ARB */
-   { 20298, 0x00008735 }, /* GL_MODELVIEW21_ARB */
-   { 20317, 0x00008736 }, /* GL_MODELVIEW22_ARB */
-   { 20336, 0x00008737 }, /* GL_MODELVIEW23_ARB */
-   { 20355, 0x00008738 }, /* GL_MODELVIEW24_ARB */
-   { 20374, 0x00008739 }, /* GL_MODELVIEW25_ARB */
-   { 20393, 0x0000873A }, /* GL_MODELVIEW26_ARB */
-   { 20412, 0x0000873B }, /* GL_MODELVIEW27_ARB */
-   { 20431, 0x0000873C }, /* GL_MODELVIEW28_ARB */
-   { 20450, 0x0000873D }, /* GL_MODELVIEW29_ARB */
-   { 20469, 0x00008722 }, /* GL_MODELVIEW2_ARB */
-   { 20487, 0x0000873E }, /* GL_MODELVIEW30_ARB */
-   { 20506, 0x0000873F }, /* GL_MODELVIEW31_ARB */
-   { 20525, 0x00008723 }, /* GL_MODELVIEW3_ARB */
-   { 20543, 0x00008724 }, /* GL_MODELVIEW4_ARB */
-   { 20561, 0x00008725 }, /* GL_MODELVIEW5_ARB */
-   { 20579, 0x00008726 }, /* GL_MODELVIEW6_ARB */
-   { 20597, 0x00008727 }, /* GL_MODELVIEW7_ARB */
-   { 20615, 0x00008728 }, /* GL_MODELVIEW8_ARB */
-   { 20633, 0x00008729 }, /* GL_MODELVIEW9_ARB */
-   { 20651, 0x00000BA6 }, /* GL_MODELVIEW_MATRIX */
-   { 20671, 0x00008629 }, /* GL_MODELVIEW_PROJECTION_NV */
-   { 20698, 0x00000BA3 }, /* GL_MODELVIEW_STACK_DEPTH */
-   { 20723, 0x00002100 }, /* GL_MODULATE */
-   { 20735, 0x00008744 }, /* GL_MODULATE_ADD_ATI */
-   { 20755, 0x00008745 }, /* GL_MODULATE_SIGNED_ADD_ATI */
-   { 20782, 0x00008746 }, /* GL_MODULATE_SUBTRACT_ATI */
-   { 20807, 0x00000103 }, /* GL_MULT */
-   { 20815, 0x0000809D }, /* GL_MULTISAMPLE */
-   { 20830, 0x000086B2 }, /* GL_MULTISAMPLE_3DFX */
-   { 20850, 0x0000809D }, /* GL_MULTISAMPLE_ARB */
-   { 20869, 0x20000000 }, /* GL_MULTISAMPLE_BIT */
-   { 20888, 0x20000000 }, /* GL_MULTISAMPLE_BIT_3DFX */
-   { 20912, 0x20000000 }, /* GL_MULTISAMPLE_BIT_ARB */
-   { 20935, 0x00008534 }, /* GL_MULTISAMPLE_FILTER_HINT_NV */
-   { 20965, 0x00002A25 }, /* GL_N3F_V3F */
-   { 20976, 0x00000D70 }, /* GL_NAME_STACK_DEPTH */
-   { 20996, 0x0000150E }, /* GL_NAND */
-   { 21004, 0x00002600 }, /* GL_NEAREST */
-   { 21015, 0x0000844E }, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */
-   { 21046, 0x0000844D }, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */
-   { 21078, 0x00002702 }, /* GL_NEAREST_MIPMAP_LINEAR */
-   { 21103, 0x00002700 }, /* GL_NEAREST_MIPMAP_NEAREST */
-   { 21129, 0x00000200 }, /* GL_NEVER */
-   { 21138, 0x00001102 }, /* GL_NICEST */
-   { 21148, 0x00000000 }, /* GL_NONE */
-   { 21156, 0x00001505 }, /* GL_NOOP */
-   { 21164, 0x00001508 }, /* GL_NOR */
-   { 21171, 0x00000BA1 }, /* GL_NORMALIZE */
-   { 21184, 0x00008075 }, /* GL_NORMAL_ARRAY */
-   { 21200, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING */
-   { 21231, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING_ARB */
-   { 21266, 0x0000808F }, /* GL_NORMAL_ARRAY_POINTER */
-   { 21290, 0x0000807F }, /* GL_NORMAL_ARRAY_STRIDE */
-   { 21313, 0x0000807E }, /* GL_NORMAL_ARRAY_TYPE */
-   { 21334, 0x00008511 }, /* GL_NORMAL_MAP */
-   { 21348, 0x00008511 }, /* GL_NORMAL_MAP_ARB */
-   { 21366, 0x00008511 }, /* GL_NORMAL_MAP_NV */
-   { 21383, 0x00000205 }, /* GL_NOTEQUAL */
-   { 21395, 0x00000000 }, /* GL_NO_ERROR */
-   { 21407, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */
-   { 21441, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB */
-   { 21479, 0x00008B89 }, /* GL_OBJECT_ACTIVE_ATTRIBUTES_ARB */
-   { 21511, 0x00008B8A }, /* GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB */
-   { 21553, 0x00008B86 }, /* GL_OBJECT_ACTIVE_UNIFORMS_ARB */
-   { 21583, 0x00008B87 }, /* GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB */
-   { 21623, 0x00008B85 }, /* GL_OBJECT_ATTACHED_OBJECTS_ARB */
-   { 21654, 0x00008B81 }, /* GL_OBJECT_COMPILE_STATUS_ARB */
-   { 21683, 0x00008B80 }, /* GL_OBJECT_DELETE_STATUS_ARB */
-   { 21711, 0x00008B84 }, /* GL_OBJECT_INFO_LOG_LENGTH_ARB */
-   { 21741, 0x00002401 }, /* GL_OBJECT_LINEAR */
-   { 21758, 0x00008B82 }, /* GL_OBJECT_LINK_STATUS_ARB */
-   { 21784, 0x00002501 }, /* GL_OBJECT_PLANE */
-   { 21800, 0x00008B88 }, /* GL_OBJECT_SHADER_SOURCE_LENGTH_ARB */
-   { 21835, 0x00008B4F }, /* GL_OBJECT_SUBTYPE_ARB */
-   { 21857, 0x00008B4E }, /* GL_OBJECT_TYPE_ARB */
-   { 21876, 0x00008B83 }, /* GL_OBJECT_VALIDATE_STATUS_ARB */
-   { 21906, 0x00008165 }, /* GL_OCCLUSION_TEST_HP */
-   { 21927, 0x00008166 }, /* GL_OCCLUSION_TEST_RESULT_HP */
-   { 21955, 0x00000001 }, /* GL_ONE */
-   { 21962, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA */
-   { 21990, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA_EXT */
-   { 22022, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR */
-   { 22050, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR_EXT */
-   { 22082, 0x00000305 }, /* GL_ONE_MINUS_DST_ALPHA */
-   { 22105, 0x00000307 }, /* GL_ONE_MINUS_DST_COLOR */
-   { 22128, 0x00000303 }, /* GL_ONE_MINUS_SRC_ALPHA */
-   { 22151, 0x00000301 }, /* GL_ONE_MINUS_SRC_COLOR */
-   { 22174, 0x00008598 }, /* GL_OPERAND0_ALPHA */
-   { 22192, 0x00008598 }, /* GL_OPERAND0_ALPHA_ARB */
-   { 22214, 0x00008598 }, /* GL_OPERAND0_ALPHA_EXT */
-   { 22236, 0x00008590 }, /* GL_OPERAND0_RGB */
-   { 22252, 0x00008590 }, /* GL_OPERAND0_RGB_ARB */
-   { 22272, 0x00008590 }, /* GL_OPERAND0_RGB_EXT */
-   { 22292, 0x00008599 }, /* GL_OPERAND1_ALPHA */
-   { 22310, 0x00008599 }, /* GL_OPERAND1_ALPHA_ARB */
-   { 22332, 0x00008599 }, /* GL_OPERAND1_ALPHA_EXT */
-   { 22354, 0x00008591 }, /* GL_OPERAND1_RGB */
-   { 22370, 0x00008591 }, /* GL_OPERAND1_RGB_ARB */
-   { 22390, 0x00008591 }, /* GL_OPERAND1_RGB_EXT */
-   { 22410, 0x0000859A }, /* GL_OPERAND2_ALPHA */
-   { 22428, 0x0000859A }, /* GL_OPERAND2_ALPHA_ARB */
-   { 22450, 0x0000859A }, /* GL_OPERAND2_ALPHA_EXT */
-   { 22472, 0x00008592 }, /* GL_OPERAND2_RGB */
-   { 22488, 0x00008592 }, /* GL_OPERAND2_RGB_ARB */
-   { 22508, 0x00008592 }, /* GL_OPERAND2_RGB_EXT */
-   { 22528, 0x0000859B }, /* GL_OPERAND3_ALPHA_NV */
-   { 22549, 0x00008593 }, /* GL_OPERAND3_RGB_NV */
-   { 22568, 0x00001507 }, /* GL_OR */
-   { 22574, 0x00000A01 }, /* GL_ORDER */
-   { 22583, 0x0000150D }, /* GL_OR_INVERTED */
-   { 22598, 0x0000150B }, /* GL_OR_REVERSE */
-   { 22612, 0x00000505 }, /* GL_OUT_OF_MEMORY */
-   { 22629, 0x00000D05 }, /* GL_PACK_ALIGNMENT */
-   { 22647, 0x0000806C }, /* GL_PACK_IMAGE_HEIGHT */
-   { 22668, 0x00008758 }, /* GL_PACK_INVERT_MESA */
-   { 22688, 0x00000D01 }, /* GL_PACK_LSB_FIRST */
-   { 22706, 0x00000D02 }, /* GL_PACK_ROW_LENGTH */
-   { 22725, 0x0000806B }, /* GL_PACK_SKIP_IMAGES */
-   { 22745, 0x00000D04 }, /* GL_PACK_SKIP_PIXELS */
-   { 22765, 0x00000D03 }, /* GL_PACK_SKIP_ROWS */
-   { 22783, 0x00000D00 }, /* GL_PACK_SWAP_BYTES */
-   { 22802, 0x00008B92 }, /* GL_PALETTE4_R5_G6_B5_OES */
-   { 22827, 0x00008B94 }, /* GL_PALETTE4_RGB5_A1_OES */
-   { 22851, 0x00008B90 }, /* GL_PALETTE4_RGB8_OES */
-   { 22872, 0x00008B93 }, /* GL_PALETTE4_RGBA4_OES */
-   { 22894, 0x00008B91 }, /* GL_PALETTE4_RGBA8_OES */
-   { 22916, 0x00008B97 }, /* GL_PALETTE8_R5_G6_B5_OES */
-   { 22941, 0x00008B99 }, /* GL_PALETTE8_RGB5_A1_OES */
-   { 22965, 0x00008B95 }, /* GL_PALETTE8_RGB8_OES */
-   { 22986, 0x00008B98 }, /* GL_PALETTE8_RGBA4_OES */
-   { 23008, 0x00008B96 }, /* GL_PALETTE8_RGBA8_OES */
-   { 23030, 0x00000700 }, /* GL_PASS_THROUGH_TOKEN */
-   { 23052, 0x00000C50 }, /* GL_PERSPECTIVE_CORRECTION_HINT */
-   { 23083, 0x00000C79 }, /* GL_PIXEL_MAP_A_TO_A */
-   { 23103, 0x00000CB9 }, /* GL_PIXEL_MAP_A_TO_A_SIZE */
-   { 23128, 0x00000C78 }, /* GL_PIXEL_MAP_B_TO_B */
-   { 23148, 0x00000CB8 }, /* GL_PIXEL_MAP_B_TO_B_SIZE */
-   { 23173, 0x00000C77 }, /* GL_PIXEL_MAP_G_TO_G */
-   { 23193, 0x00000CB7 }, /* GL_PIXEL_MAP_G_TO_G_SIZE */
-   { 23218, 0x00000C75 }, /* GL_PIXEL_MAP_I_TO_A */
-   { 23238, 0x00000CB5 }, /* GL_PIXEL_MAP_I_TO_A_SIZE */
-   { 23263, 0x00000C74 }, /* GL_PIXEL_MAP_I_TO_B */
-   { 23283, 0x00000CB4 }, /* GL_PIXEL_MAP_I_TO_B_SIZE */
-   { 23308, 0x00000C73 }, /* GL_PIXEL_MAP_I_TO_G */
-   { 23328, 0x00000CB3 }, /* GL_PIXEL_MAP_I_TO_G_SIZE */
-   { 23353, 0x00000C70 }, /* GL_PIXEL_MAP_I_TO_I */
-   { 23373, 0x00000CB0 }, /* GL_PIXEL_MAP_I_TO_I_SIZE */
-   { 23398, 0x00000C72 }, /* GL_PIXEL_MAP_I_TO_R */
-   { 23418, 0x00000CB2 }, /* GL_PIXEL_MAP_I_TO_R_SIZE */
-   { 23443, 0x00000C76 }, /* GL_PIXEL_MAP_R_TO_R */
-   { 23463, 0x00000CB6 }, /* GL_PIXEL_MAP_R_TO_R_SIZE */
-   { 23488, 0x00000C71 }, /* GL_PIXEL_MAP_S_TO_S */
-   { 23508, 0x00000CB1 }, /* GL_PIXEL_MAP_S_TO_S_SIZE */
-   { 23533, 0x00000020 }, /* GL_PIXEL_MODE_BIT */
-   { 23551, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER */
-   { 23572, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING */
-   { 23601, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING_EXT */
-   { 23634, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER_EXT */
-   { 23659, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER */
-   { 23682, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING */
-   { 23713, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING_EXT */
-   { 23748, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER_EXT */
-   { 23775, 0x00001B00 }, /* GL_POINT */
-   { 23784, 0x00000000 }, /* GL_POINTS */
-   { 23794, 0x00000002 }, /* GL_POINT_BIT */
-   { 23807, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION */
-   { 23837, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_ARB */
-   { 23871, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_EXT */
-   { 23905, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_SGIS */
-   { 23940, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE */
-   { 23969, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_ARB */
-   { 24002, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_EXT */
-   { 24035, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_SGIS */
-   { 24069, 0x00000B11 }, /* GL_POINT_SIZE */
-   { 24083, 0x00000B13 }, /* GL_POINT_SIZE_GRANULARITY */
-   { 24109, 0x00008127 }, /* GL_POINT_SIZE_MAX */
-   { 24127, 0x00008127 }, /* GL_POINT_SIZE_MAX_ARB */
-   { 24149, 0x00008127 }, /* GL_POINT_SIZE_MAX_EXT */
-   { 24171, 0x00008127 }, /* GL_POINT_SIZE_MAX_SGIS */
-   { 24194, 0x00008126 }, /* GL_POINT_SIZE_MIN */
-   { 24212, 0x00008126 }, /* GL_POINT_SIZE_MIN_ARB */
-   { 24234, 0x00008126 }, /* GL_POINT_SIZE_MIN_EXT */
-   { 24256, 0x00008126 }, /* GL_POINT_SIZE_MIN_SGIS */
-   { 24279, 0x00000B12 }, /* GL_POINT_SIZE_RANGE */
-   { 24299, 0x00000B10 }, /* GL_POINT_SMOOTH */
-   { 24315, 0x00000C51 }, /* GL_POINT_SMOOTH_HINT */
-   { 24336, 0x00008861 }, /* GL_POINT_SPRITE */
-   { 24352, 0x00008861 }, /* GL_POINT_SPRITE_ARB */
-   { 24372, 0x00008CA0 }, /* GL_POINT_SPRITE_COORD_ORIGIN */
-   { 24401, 0x00008861 }, /* GL_POINT_SPRITE_NV */
-   { 24420, 0x00008863 }, /* GL_POINT_SPRITE_R_MODE_NV */
-   { 24446, 0x00000701 }, /* GL_POINT_TOKEN */
-   { 24461, 0x00000009 }, /* GL_POLYGON */
-   { 24472, 0x00000008 }, /* GL_POLYGON_BIT */
-   { 24487, 0x00000B40 }, /* GL_POLYGON_MODE */
-   { 24503, 0x00008039 }, /* GL_POLYGON_OFFSET_BIAS */
-   { 24526, 0x00008038 }, /* GL_POLYGON_OFFSET_FACTOR */
-   { 24551, 0x00008037 }, /* GL_POLYGON_OFFSET_FILL */
-   { 24574, 0x00002A02 }, /* GL_POLYGON_OFFSET_LINE */
-   { 24597, 0x00002A01 }, /* GL_POLYGON_OFFSET_POINT */
-   { 24621, 0x00002A00 }, /* GL_POLYGON_OFFSET_UNITS */
-   { 24645, 0x00000B41 }, /* GL_POLYGON_SMOOTH */
-   { 24663, 0x00000C53 }, /* GL_POLYGON_SMOOTH_HINT */
-   { 24686, 0x00000B42 }, /* GL_POLYGON_STIPPLE */
-   { 24705, 0x00000010 }, /* GL_POLYGON_STIPPLE_BIT */
-   { 24728, 0x00000703 }, /* GL_POLYGON_TOKEN */
-   { 24745, 0x00001203 }, /* GL_POSITION */
-   { 24757, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */
-   { 24789, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI */
-   { 24825, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */
-   { 24858, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI */
-   { 24895, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */
-   { 24926, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI */
-   { 24961, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */
-   { 24993, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI */
-   { 25029, 0x000080D2 }, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */
-   { 25062, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */
-   { 25094, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI */
-   { 25130, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */
-   { 25163, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI */
-   { 25200, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS */
-   { 25230, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS_SGI */
-   { 25264, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE */
-   { 25295, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE_SGI */
-   { 25330, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS */
-   { 25361, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS_EXT */
-   { 25396, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE */
-   { 25428, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE_EXT */
-   { 25464, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS */
-   { 25494, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS_EXT */
-   { 25528, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE */
-   { 25559, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE_EXT */
-   { 25594, 0x000080D1 }, /* GL_POST_CONVOLUTION_COLOR_TABLE */
-   { 25626, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS */
-   { 25657, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS_EXT */
-   { 25692, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE */
-   { 25724, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE_EXT */
-   { 25760, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS */
-   { 25789, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS_EXT */
-   { 25822, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE */
-   { 25852, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE_EXT */
-   { 25886, 0x0000817B }, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */
-   { 25925, 0x00008179 }, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */
-   { 25958, 0x0000817C }, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */
-   { 25998, 0x0000817A }, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */
-   { 26032, 0x00008578 }, /* GL_PREVIOUS */
-   { 26044, 0x00008578 }, /* GL_PREVIOUS_ARB */
-   { 26060, 0x00008578 }, /* GL_PREVIOUS_EXT */
-   { 26076, 0x00008577 }, /* GL_PRIMARY_COLOR */
-   { 26093, 0x00008577 }, /* GL_PRIMARY_COLOR_ARB */
-   { 26114, 0x00008577 }, /* GL_PRIMARY_COLOR_EXT */
-   { 26135, 0x000088B0 }, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */
-   { 26168, 0x00008805 }, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */
-   { 26200, 0x000088AC }, /* GL_PROGRAM_ATTRIBS_ARB */
-   { 26223, 0x00008677 }, /* GL_PROGRAM_BINDING_ARB */
-   { 26246, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_ARB */
-   { 26276, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_NV */
-   { 26305, 0x00008874 }, /* GL_PROGRAM_ERROR_STRING_ARB */
-   { 26333, 0x00008876 }, /* GL_PROGRAM_FORMAT_ARB */
-   { 26355, 0x00008875 }, /* GL_PROGRAM_FORMAT_ASCII_ARB */
-   { 26383, 0x000088A0 }, /* GL_PROGRAM_INSTRUCTIONS_ARB */
-   { 26411, 0x00008627 }, /* GL_PROGRAM_LENGTH_ARB */
-   { 26433, 0x00008627 }, /* GL_PROGRAM_LENGTH_NV */
-   { 26454, 0x000088B2 }, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
-   { 26494, 0x00008808 }, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
-   { 26533, 0x000088AE }, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */
-   { 26563, 0x000088A2 }, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
-   { 26598, 0x000088AA }, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */
-   { 26631, 0x000088A6 }, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */
-   { 26665, 0x0000880A }, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
-   { 26704, 0x00008809 }, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
-   { 26743, 0x00008B40 }, /* GL_PROGRAM_OBJECT_ARB */
-   { 26765, 0x000088A8 }, /* GL_PROGRAM_PARAMETERS_ARB */
-   { 26791, 0x00008644 }, /* GL_PROGRAM_PARAMETER_NV */
-   { 26815, 0x00008647 }, /* GL_PROGRAM_RESIDENT_NV */
-   { 26838, 0x00008628 }, /* GL_PROGRAM_STRING_ARB */
-   { 26860, 0x00008628 }, /* GL_PROGRAM_STRING_NV */
-   { 26881, 0x00008646 }, /* GL_PROGRAM_TARGET_NV */
-   { 26902, 0x000088A4 }, /* GL_PROGRAM_TEMPORARIES_ARB */
-   { 26929, 0x00008807 }, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */
-   { 26961, 0x00008806 }, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */
-   { 26993, 0x000088B6 }, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */
-   { 27028, 0x00001701 }, /* GL_PROJECTION */
-   { 27042, 0x00000BA7 }, /* GL_PROJECTION_MATRIX */
-   { 27063, 0x00000BA4 }, /* GL_PROJECTION_STACK_DEPTH */
-   { 27089, 0x000080D3 }, /* GL_PROXY_COLOR_TABLE */
-   { 27110, 0x00008025 }, /* GL_PROXY_HISTOGRAM */
-   { 27129, 0x00008025 }, /* GL_PROXY_HISTOGRAM_EXT */
-   { 27152, 0x000080D5 }, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */
-   { 27191, 0x000080D4 }, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */
-   { 27229, 0x00008063 }, /* GL_PROXY_TEXTURE_1D */
-   { 27249, 0x00008C19 }, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */
-   { 27279, 0x00008063 }, /* GL_PROXY_TEXTURE_1D_EXT */
-   { 27303, 0x00008064 }, /* GL_PROXY_TEXTURE_2D */
-   { 27323, 0x00008C1B }, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */
-   { 27353, 0x00008064 }, /* GL_PROXY_TEXTURE_2D_EXT */
-   { 27377, 0x00008070 }, /* GL_PROXY_TEXTURE_3D */
-   { 27397, 0x000080BD }, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */
-   { 27430, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP */
-   { 27456, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP_ARB */
-   { 27486, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */
-   { 27517, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_NV */
-   { 27547, 0x00002003 }, /* GL_Q */
-   { 27552, 0x00001209 }, /* GL_QUADRATIC_ATTENUATION */
-   { 27577, 0x00000007 }, /* GL_QUADS */
-   { 27586, 0x00008614 }, /* GL_QUAD_MESH_SUN */
-   { 27603, 0x00000008 }, /* GL_QUAD_STRIP */
-   { 27617, 0x00008864 }, /* GL_QUERY_COUNTER_BITS */
-   { 27639, 0x00008864 }, /* GL_QUERY_COUNTER_BITS_ARB */
-   { 27665, 0x00008866 }, /* GL_QUERY_RESULT */
-   { 27681, 0x00008866 }, /* GL_QUERY_RESULT_ARB */
-   { 27701, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE */
-   { 27727, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE_ARB */
-   { 27757, 0x00002002 }, /* GL_R */
-   { 27762, 0x00002A10 }, /* GL_R3_G3_B2 */
-   { 27774, 0x00019262 }, /* GL_RASTER_POSITION_UNCLIPPED_IBM */
-   { 27807, 0x00000C02 }, /* GL_READ_BUFFER */
-   { 27822, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER */
-   { 27842, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING_EXT */
-   { 27874, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER_EXT */
-   { 27898, 0x000088B8 }, /* GL_READ_ONLY */
-   { 27911, 0x000088B8 }, /* GL_READ_ONLY_ARB */
-   { 27928, 0x000088BA }, /* GL_READ_WRITE */
-   { 27942, 0x000088BA }, /* GL_READ_WRITE_ARB */
-   { 27960, 0x00001903 }, /* GL_RED */
-   { 27967, 0x00008016 }, /* GL_REDUCE */
-   { 27977, 0x00008016 }, /* GL_REDUCE_EXT */
-   { 27991, 0x00000D15 }, /* GL_RED_BIAS */
-   { 28003, 0x00000D52 }, /* GL_RED_BITS */
-   { 28015, 0x00000D14 }, /* GL_RED_SCALE */
-   { 28028, 0x00008512 }, /* GL_REFLECTION_MAP */
-   { 28046, 0x00008512 }, /* GL_REFLECTION_MAP_ARB */
-   { 28068, 0x00008512 }, /* GL_REFLECTION_MAP_NV */
-   { 28089, 0x00001C00 }, /* GL_RENDER */
-   { 28099, 0x00008D41 }, /* GL_RENDERBUFFER */
-   { 28115, 0x00008D53 }, /* GL_RENDERBUFFER_ALPHA_SIZE */
-   { 28142, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING_EXT */
-   { 28170, 0x00008D52 }, /* GL_RENDERBUFFER_BLUE_SIZE */
-   { 28196, 0x00008D54 }, /* GL_RENDERBUFFER_DEPTH_SIZE */
-   { 28223, 0x00008D41 }, /* GL_RENDERBUFFER_EXT */
-   { 28243, 0x00008D51 }, /* GL_RENDERBUFFER_GREEN_SIZE */
-   { 28270, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT */
-   { 28293, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT_EXT */
-   { 28320, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT */
-   { 28352, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT_EXT */
-   { 28388, 0x00008D50 }, /* GL_RENDERBUFFER_RED_SIZE */
-   { 28413, 0x00008CAB }, /* GL_RENDERBUFFER_SAMPLES */
-   { 28437, 0x00008D55 }, /* GL_RENDERBUFFER_STENCIL_SIZE */
-   { 28466, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH */
-   { 28488, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH_EXT */
-   { 28514, 0x00001F01 }, /* GL_RENDERER */
-   { 28526, 0x00000C40 }, /* GL_RENDER_MODE */
-   { 28541, 0x00002901 }, /* GL_REPEAT */
-   { 28551, 0x00001E01 }, /* GL_REPLACE */
-   { 28562, 0x00008062 }, /* GL_REPLACE_EXT */
-   { 28577, 0x00008153 }, /* GL_REPLICATE_BORDER_HP */
-   { 28600, 0x0000803A }, /* GL_RESCALE_NORMAL */
-   { 28618, 0x0000803A }, /* GL_RESCALE_NORMAL_EXT */
-   { 28640, 0x00000102 }, /* GL_RETURN */
-   { 28650, 0x00001907 }, /* GL_RGB */
-   { 28657, 0x00008052 }, /* GL_RGB10 */
-   { 28666, 0x00008059 }, /* GL_RGB10_A2 */
-   { 28678, 0x00008059 }, /* GL_RGB10_A2_EXT */
-   { 28694, 0x00008052 }, /* GL_RGB10_EXT */
-   { 28707, 0x00008053 }, /* GL_RGB12 */
-   { 28716, 0x00008053 }, /* GL_RGB12_EXT */
-   { 28729, 0x00008054 }, /* GL_RGB16 */
-   { 28738, 0x00008054 }, /* GL_RGB16_EXT */
-   { 28751, 0x0000804E }, /* GL_RGB2_EXT */
-   { 28763, 0x0000804F }, /* GL_RGB4 */
-   { 28771, 0x0000804F }, /* GL_RGB4_EXT */
-   { 28783, 0x000083A1 }, /* GL_RGB4_S3TC */
-   { 28796, 0x00008050 }, /* GL_RGB5 */
-   { 28804, 0x00008057 }, /* GL_RGB5_A1 */
-   { 28815, 0x00008057 }, /* GL_RGB5_A1_EXT */
-   { 28830, 0x00008050 }, /* GL_RGB5_EXT */
-   { 28842, 0x00008051 }, /* GL_RGB8 */
-   { 28850, 0x00008051 }, /* GL_RGB8_EXT */
-   { 28862, 0x00001908 }, /* GL_RGBA */
-   { 28870, 0x0000805A }, /* GL_RGBA12 */
-   { 28880, 0x0000805A }, /* GL_RGBA12_EXT */
-   { 28894, 0x0000805B }, /* GL_RGBA16 */
-   { 28904, 0x0000805B }, /* GL_RGBA16_EXT */
-   { 28918, 0x00008055 }, /* GL_RGBA2 */
-   { 28927, 0x00008055 }, /* GL_RGBA2_EXT */
-   { 28940, 0x00008056 }, /* GL_RGBA4 */
-   { 28949, 0x000083A5 }, /* GL_RGBA4_DXT5_S3TC */
-   { 28968, 0x00008056 }, /* GL_RGBA4_EXT */
-   { 28981, 0x000083A3 }, /* GL_RGBA4_S3TC */
-   { 28995, 0x00008058 }, /* GL_RGBA8 */
-   { 29004, 0x00008058 }, /* GL_RGBA8_EXT */
-   { 29017, 0x00008F97 }, /* GL_RGBA8_SNORM */
-   { 29032, 0x000083A4 }, /* GL_RGBA_DXT5_S3TC */
-   { 29050, 0x00000C31 }, /* GL_RGBA_MODE */
-   { 29063, 0x000083A2 }, /* GL_RGBA_S3TC */
-   { 29076, 0x00008F93 }, /* GL_RGBA_SNORM */
-   { 29090, 0x000083A0 }, /* GL_RGB_S3TC */
-   { 29102, 0x00008573 }, /* GL_RGB_SCALE */
-   { 29115, 0x00008573 }, /* GL_RGB_SCALE_ARB */
-   { 29132, 0x00008573 }, /* GL_RGB_SCALE_EXT */
-   { 29149, 0x00000407 }, /* GL_RIGHT */
-   { 29158, 0x00002000 }, /* GL_S */
-   { 29163, 0x00008B5D }, /* GL_SAMPLER_1D */
-   { 29177, 0x00008B61 }, /* GL_SAMPLER_1D_SHADOW */
-   { 29198, 0x00008B5E }, /* GL_SAMPLER_2D */
-   { 29212, 0x00008B62 }, /* GL_SAMPLER_2D_SHADOW */
-   { 29233, 0x00008B5F }, /* GL_SAMPLER_3D */
-   { 29247, 0x00008B60 }, /* GL_SAMPLER_CUBE */
-   { 29263, 0x000080A9 }, /* GL_SAMPLES */
-   { 29274, 0x000086B4 }, /* GL_SAMPLES_3DFX */
-   { 29290, 0x000080A9 }, /* GL_SAMPLES_ARB */
-   { 29305, 0x00008914 }, /* GL_SAMPLES_PASSED */
-   { 29323, 0x00008914 }, /* GL_SAMPLES_PASSED_ARB */
-   { 29345, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE */
-   { 29373, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE_ARB */
-   { 29405, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE */
-   { 29428, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE_ARB */
-   { 29455, 0x000080A8 }, /* GL_SAMPLE_BUFFERS */
-   { 29473, 0x000086B3 }, /* GL_SAMPLE_BUFFERS_3DFX */
-   { 29496, 0x000080A8 }, /* GL_SAMPLE_BUFFERS_ARB */
-   { 29518, 0x000080A0 }, /* GL_SAMPLE_COVERAGE */
-   { 29537, 0x000080A0 }, /* GL_SAMPLE_COVERAGE_ARB */
-   { 29560, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT */
-   { 29586, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT_ARB */
-   { 29616, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE */
-   { 29641, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE_ARB */
-   { 29670, 0x00080000 }, /* GL_SCISSOR_BIT */
-   { 29685, 0x00000C10 }, /* GL_SCISSOR_BOX */
-   { 29700, 0x00000C11 }, /* GL_SCISSOR_TEST */
-   { 29716, 0x0000845E }, /* GL_SECONDARY_COLOR_ARRAY */
-   { 29741, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */
-   { 29781, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB */
-   { 29825, 0x0000845D }, /* GL_SECONDARY_COLOR_ARRAY_POINTER */
-   { 29858, 0x0000845A }, /* GL_SECONDARY_COLOR_ARRAY_SIZE */
-   { 29888, 0x0000845C }, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */
-   { 29920, 0x0000845B }, /* GL_SECONDARY_COLOR_ARRAY_TYPE */
-   { 29950, 0x00001C02 }, /* GL_SELECT */
-   { 29960, 0x00000DF3 }, /* GL_SELECTION_BUFFER_POINTER */
-   { 29988, 0x00000DF4 }, /* GL_SELECTION_BUFFER_SIZE */
-   { 30013, 0x00008012 }, /* GL_SEPARABLE_2D */
-   { 30029, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR */
-   { 30056, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR_EXT */
-   { 30087, 0x0000150F }, /* GL_SET */
-   { 30094, 0x00008B48 }, /* GL_SHADER_OBJECT_ARB */
-   { 30115, 0x00008B88 }, /* GL_SHADER_SOURCE_LENGTH */
-   { 30139, 0x00008B4F }, /* GL_SHADER_TYPE */
-   { 30154, 0x00000B54 }, /* GL_SHADE_MODEL */
-   { 30169, 0x00008B8C }, /* GL_SHADING_LANGUAGE_VERSION */
-   { 30197, 0x000080BF }, /* GL_SHADOW_AMBIENT_SGIX */
-   { 30220, 0x000081FB }, /* GL_SHARED_TEXTURE_PALETTE_EXT */
-   { 30250, 0x00001601 }, /* GL_SHININESS */
-   { 30263, 0x00001402 }, /* GL_SHORT */
-   { 30272, 0x00008F9C }, /* GL_SIGNED_NORMALIZED */
-   { 30293, 0x000081F9 }, /* GL_SINGLE_COLOR */
-   { 30309, 0x000081F9 }, /* GL_SINGLE_COLOR_EXT */
-   { 30329, 0x000085CC }, /* GL_SLICE_ACCUM_SUN */
-   { 30348, 0x00008C46 }, /* GL_SLUMINANCE */
-   { 30362, 0x00008C47 }, /* GL_SLUMINANCE8 */
-   { 30377, 0x00008C45 }, /* GL_SLUMINANCE8_ALPHA8 */
-   { 30399, 0x00008C44 }, /* GL_SLUMINANCE_ALPHA */
-   { 30419, 0x00001D01 }, /* GL_SMOOTH */
-   { 30429, 0x00000B23 }, /* GL_SMOOTH_LINE_WIDTH_GRANULARITY */
-   { 30462, 0x00000B22 }, /* GL_SMOOTH_LINE_WIDTH_RANGE */
-   { 30489, 0x00000B13 }, /* GL_SMOOTH_POINT_SIZE_GRANULARITY */
-   { 30522, 0x00000B12 }, /* GL_SMOOTH_POINT_SIZE_RANGE */
-   { 30549, 0x00008588 }, /* GL_SOURCE0_ALPHA */
-   { 30566, 0x00008588 }, /* GL_SOURCE0_ALPHA_ARB */
-   { 30587, 0x00008588 }, /* GL_SOURCE0_ALPHA_EXT */
-   { 30608, 0x00008580 }, /* GL_SOURCE0_RGB */
-   { 30623, 0x00008580 }, /* GL_SOURCE0_RGB_ARB */
-   { 30642, 0x00008580 }, /* GL_SOURCE0_RGB_EXT */
-   { 30661, 0x00008589 }, /* GL_SOURCE1_ALPHA */
-   { 30678, 0x00008589 }, /* GL_SOURCE1_ALPHA_ARB */
-   { 30699, 0x00008589 }, /* GL_SOURCE1_ALPHA_EXT */
-   { 30720, 0x00008581 }, /* GL_SOURCE1_RGB */
-   { 30735, 0x00008581 }, /* GL_SOURCE1_RGB_ARB */
-   { 30754, 0x00008581 }, /* GL_SOURCE1_RGB_EXT */
-   { 30773, 0x0000858A }, /* GL_SOURCE2_ALPHA */
-   { 30790, 0x0000858A }, /* GL_SOURCE2_ALPHA_ARB */
-   { 30811, 0x0000858A }, /* GL_SOURCE2_ALPHA_EXT */
-   { 30832, 0x00008582 }, /* GL_SOURCE2_RGB */
-   { 30847, 0x00008582 }, /* GL_SOURCE2_RGB_ARB */
-   { 30866, 0x00008582 }, /* GL_SOURCE2_RGB_EXT */
-   { 30885, 0x0000858B }, /* GL_SOURCE3_ALPHA_NV */
-   { 30905, 0x00008583 }, /* GL_SOURCE3_RGB_NV */
-   { 30923, 0x00001202 }, /* GL_SPECULAR */
-   { 30935, 0x00002402 }, /* GL_SPHERE_MAP */
-   { 30949, 0x00001206 }, /* GL_SPOT_CUTOFF */
-   { 30964, 0x00001204 }, /* GL_SPOT_DIRECTION */
-   { 30982, 0x00001205 }, /* GL_SPOT_EXPONENT */
-   { 30999, 0x00008588 }, /* GL_SRC0_ALPHA */
-   { 31013, 0x00008580 }, /* GL_SRC0_RGB */
-   { 31025, 0x00008589 }, /* GL_SRC1_ALPHA */
-   { 31039, 0x00008581 }, /* GL_SRC1_RGB */
-   { 31051, 0x0000858A }, /* GL_SRC2_ALPHA */
-   { 31065, 0x00008582 }, /* GL_SRC2_RGB */
-   { 31077, 0x00000302 }, /* GL_SRC_ALPHA */
-   { 31090, 0x00000308 }, /* GL_SRC_ALPHA_SATURATE */
-   { 31112, 0x00000300 }, /* GL_SRC_COLOR */
-   { 31125, 0x00008C40 }, /* GL_SRGB */
-   { 31133, 0x00008C41 }, /* GL_SRGB8 */
-   { 31142, 0x00008C43 }, /* GL_SRGB8_ALPHA8 */
-   { 31158, 0x00008C42 }, /* GL_SRGB_ALPHA */
-   { 31172, 0x00000503 }, /* GL_STACK_OVERFLOW */
-   { 31190, 0x00000504 }, /* GL_STACK_UNDERFLOW */
-   { 31209, 0x000088E6 }, /* GL_STATIC_COPY */
-   { 31224, 0x000088E6 }, /* GL_STATIC_COPY_ARB */
-   { 31243, 0x000088E4 }, /* GL_STATIC_DRAW */
-   { 31258, 0x000088E4 }, /* GL_STATIC_DRAW_ARB */
-   { 31277, 0x000088E5 }, /* GL_STATIC_READ */
-   { 31292, 0x000088E5 }, /* GL_STATIC_READ_ARB */
-   { 31311, 0x00001802 }, /* GL_STENCIL */
-   { 31322, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT */
-   { 31344, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT_EXT */
-   { 31370, 0x00008801 }, /* GL_STENCIL_BACK_FAIL */
-   { 31391, 0x00008801 }, /* GL_STENCIL_BACK_FAIL_ATI */
-   { 31416, 0x00008800 }, /* GL_STENCIL_BACK_FUNC */
-   { 31437, 0x00008800 }, /* GL_STENCIL_BACK_FUNC_ATI */
-   { 31462, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */
-   { 31494, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI */
-   { 31530, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */
-   { 31562, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI */
-   { 31598, 0x00008CA3 }, /* GL_STENCIL_BACK_REF */
-   { 31618, 0x00008CA4 }, /* GL_STENCIL_BACK_VALUE_MASK */
-   { 31645, 0x00008CA5 }, /* GL_STENCIL_BACK_WRITEMASK */
-   { 31671, 0x00000D57 }, /* GL_STENCIL_BITS */
-   { 31687, 0x00000400 }, /* GL_STENCIL_BUFFER_BIT */
-   { 31709, 0x00000B91 }, /* GL_STENCIL_CLEAR_VALUE */
-   { 31732, 0x00000B94 }, /* GL_STENCIL_FAIL */
-   { 31748, 0x00000B92 }, /* GL_STENCIL_FUNC */
-   { 31764, 0x00001901 }, /* GL_STENCIL_INDEX */
-   { 31781, 0x00008D49 }, /* GL_STENCIL_INDEX16_EXT */
-   { 31804, 0x00008D46 }, /* GL_STENCIL_INDEX1_EXT */
-   { 31826, 0x00008D47 }, /* GL_STENCIL_INDEX4_EXT */
-   { 31848, 0x00008D48 }, /* GL_STENCIL_INDEX8_EXT */
-   { 31870, 0x00008D45 }, /* GL_STENCIL_INDEX_EXT */
-   { 31891, 0x00000B95 }, /* GL_STENCIL_PASS_DEPTH_FAIL */
-   { 31918, 0x00000B96 }, /* GL_STENCIL_PASS_DEPTH_PASS */
-   { 31945, 0x00000B97 }, /* GL_STENCIL_REF */
-   { 31960, 0x00000B90 }, /* GL_STENCIL_TEST */
-   { 31976, 0x00008910 }, /* GL_STENCIL_TEST_TWO_SIDE_EXT */
-   { 32005, 0x00000B93 }, /* GL_STENCIL_VALUE_MASK */
-   { 32027, 0x00000B98 }, /* GL_STENCIL_WRITEMASK */
-   { 32048, 0x00000C33 }, /* GL_STEREO */
-   { 32058, 0x000088E2 }, /* GL_STREAM_COPY */
-   { 32073, 0x000088E2 }, /* GL_STREAM_COPY_ARB */
-   { 32092, 0x000088E0 }, /* GL_STREAM_DRAW */
-   { 32107, 0x000088E0 }, /* GL_STREAM_DRAW_ARB */
-   { 32126, 0x000088E1 }, /* GL_STREAM_READ */
-   { 32141, 0x000088E1 }, /* GL_STREAM_READ_ARB */
-   { 32160, 0x00000D50 }, /* GL_SUBPIXEL_BITS */
-   { 32177, 0x000084E7 }, /* GL_SUBTRACT */
-   { 32189, 0x000084E7 }, /* GL_SUBTRACT_ARB */
-   { 32205, 0x00002001 }, /* GL_T */
-   { 32210, 0x00002A2A }, /* GL_T2F_C3F_V3F */
-   { 32225, 0x00002A2C }, /* GL_T2F_C4F_N3F_V3F */
-   { 32244, 0x00002A29 }, /* GL_T2F_C4UB_V3F */
-   { 32260, 0x00002A2B }, /* GL_T2F_N3F_V3F */
-   { 32275, 0x00002A27 }, /* GL_T2F_V3F */
-   { 32286, 0x00002A2D }, /* GL_T4F_C4F_N3F_V4F */
-   { 32305, 0x00002A28 }, /* GL_T4F_V4F */
-   { 32316, 0x00008031 }, /* GL_TABLE_TOO_LARGE_EXT */
-   { 32339, 0x00001702 }, /* GL_TEXTURE */
-   { 32350, 0x000084C0 }, /* GL_TEXTURE0 */
-   { 32362, 0x000084C0 }, /* GL_TEXTURE0_ARB */
-   { 32378, 0x000084C1 }, /* GL_TEXTURE1 */
-   { 32390, 0x000084CA }, /* GL_TEXTURE10 */
-   { 32403, 0x000084CA }, /* GL_TEXTURE10_ARB */
-   { 32420, 0x000084CB }, /* GL_TEXTURE11 */
-   { 32433, 0x000084CB }, /* GL_TEXTURE11_ARB */
-   { 32450, 0x000084CC }, /* GL_TEXTURE12 */
-   { 32463, 0x000084CC }, /* GL_TEXTURE12_ARB */
-   { 32480, 0x000084CD }, /* GL_TEXTURE13 */
-   { 32493, 0x000084CD }, /* GL_TEXTURE13_ARB */
-   { 32510, 0x000084CE }, /* GL_TEXTURE14 */
-   { 32523, 0x000084CE }, /* GL_TEXTURE14_ARB */
-   { 32540, 0x000084CF }, /* GL_TEXTURE15 */
-   { 32553, 0x000084CF }, /* GL_TEXTURE15_ARB */
-   { 32570, 0x000084D0 }, /* GL_TEXTURE16 */
-   { 32583, 0x000084D0 }, /* GL_TEXTURE16_ARB */
-   { 32600, 0x000084D1 }, /* GL_TEXTURE17 */
-   { 32613, 0x000084D1 }, /* GL_TEXTURE17_ARB */
-   { 32630, 0x000084D2 }, /* GL_TEXTURE18 */
-   { 32643, 0x000084D2 }, /* GL_TEXTURE18_ARB */
-   { 32660, 0x000084D3 }, /* GL_TEXTURE19 */
-   { 32673, 0x000084D3 }, /* GL_TEXTURE19_ARB */
-   { 32690, 0x000084C1 }, /* GL_TEXTURE1_ARB */
-   { 32706, 0x000084C2 }, /* GL_TEXTURE2 */
-   { 32718, 0x000084D4 }, /* GL_TEXTURE20 */
-   { 32731, 0x000084D4 }, /* GL_TEXTURE20_ARB */
-   { 32748, 0x000084D5 }, /* GL_TEXTURE21 */
-   { 32761, 0x000084D5 }, /* GL_TEXTURE21_ARB */
-   { 32778, 0x000084D6 }, /* GL_TEXTURE22 */
-   { 32791, 0x000084D6 }, /* GL_TEXTURE22_ARB */
-   { 32808, 0x000084D7 }, /* GL_TEXTURE23 */
-   { 32821, 0x000084D7 }, /* GL_TEXTURE23_ARB */
-   { 32838, 0x000084D8 }, /* GL_TEXTURE24 */
-   { 32851, 0x000084D8 }, /* GL_TEXTURE24_ARB */
-   { 32868, 0x000084D9 }, /* GL_TEXTURE25 */
-   { 32881, 0x000084D9 }, /* GL_TEXTURE25_ARB */
-   { 32898, 0x000084DA }, /* GL_TEXTURE26 */
-   { 32911, 0x000084DA }, /* GL_TEXTURE26_ARB */
-   { 32928, 0x000084DB }, /* GL_TEXTURE27 */
-   { 32941, 0x000084DB }, /* GL_TEXTURE27_ARB */
-   { 32958, 0x000084DC }, /* GL_TEXTURE28 */
-   { 32971, 0x000084DC }, /* GL_TEXTURE28_ARB */
-   { 32988, 0x000084DD }, /* GL_TEXTURE29 */
-   { 33001, 0x000084DD }, /* GL_TEXTURE29_ARB */
-   { 33018, 0x000084C2 }, /* GL_TEXTURE2_ARB */
-   { 33034, 0x000084C3 }, /* GL_TEXTURE3 */
-   { 33046, 0x000084DE }, /* GL_TEXTURE30 */
-   { 33059, 0x000084DE }, /* GL_TEXTURE30_ARB */
-   { 33076, 0x000084DF }, /* GL_TEXTURE31 */
-   { 33089, 0x000084DF }, /* GL_TEXTURE31_ARB */
-   { 33106, 0x000084C3 }, /* GL_TEXTURE3_ARB */
-   { 33122, 0x000084C4 }, /* GL_TEXTURE4 */
-   { 33134, 0x000084C4 }, /* GL_TEXTURE4_ARB */
-   { 33150, 0x000084C5 }, /* GL_TEXTURE5 */
-   { 33162, 0x000084C5 }, /* GL_TEXTURE5_ARB */
-   { 33178, 0x000084C6 }, /* GL_TEXTURE6 */
-   { 33190, 0x000084C6 }, /* GL_TEXTURE6_ARB */
-   { 33206, 0x000084C7 }, /* GL_TEXTURE7 */
-   { 33218, 0x000084C7 }, /* GL_TEXTURE7_ARB */
-   { 33234, 0x000084C8 }, /* GL_TEXTURE8 */
-   { 33246, 0x000084C8 }, /* GL_TEXTURE8_ARB */
-   { 33262, 0x000084C9 }, /* GL_TEXTURE9 */
-   { 33274, 0x000084C9 }, /* GL_TEXTURE9_ARB */
-   { 33290, 0x00000DE0 }, /* GL_TEXTURE_1D */
-   { 33304, 0x00008C18 }, /* GL_TEXTURE_1D_ARRAY_EXT */
-   { 33328, 0x00000DE1 }, /* GL_TEXTURE_2D */
-   { 33342, 0x00008C1A }, /* GL_TEXTURE_2D_ARRAY_EXT */
-   { 33366, 0x0000806F }, /* GL_TEXTURE_3D */
-   { 33380, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE */
-   { 33402, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE_EXT */
-   { 33428, 0x0000813C }, /* GL_TEXTURE_BASE_LEVEL */
-   { 33450, 0x00008068 }, /* GL_TEXTURE_BINDING_1D */
-   { 33472, 0x00008C1C }, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */
-   { 33504, 0x00008069 }, /* GL_TEXTURE_BINDING_2D */
-   { 33526, 0x00008C1D }, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */
-   { 33558, 0x0000806A }, /* GL_TEXTURE_BINDING_3D */
-   { 33580, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP */
-   { 33608, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP_ARB */
-   { 33640, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */
-   { 33673, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_NV */
-   { 33705, 0x00040000 }, /* GL_TEXTURE_BIT */
-   { 33720, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE */
-   { 33741, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE_EXT */
-   { 33766, 0x00001005 }, /* GL_TEXTURE_BORDER */
-   { 33784, 0x00001004 }, /* GL_TEXTURE_BORDER_COLOR */
-   { 33808, 0x00008171 }, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */
-   { 33839, 0x00008176 }, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */
-   { 33869, 0x00008172 }, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */
-   { 33899, 0x00008175 }, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */
-   { 33934, 0x00008173 }, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */
-   { 33965, 0x00008174 }, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */
-   { 34003, 0x000080BC }, /* GL_TEXTURE_COLOR_TABLE_SGI */
-   { 34030, 0x000081EF }, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */
-   { 34062, 0x000080BF }, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
-   { 34096, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC */
-   { 34120, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC_ARB */
-   { 34148, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE */
-   { 34172, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE_ARB */
-   { 34200, 0x0000819B }, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */
-   { 34233, 0x0000819A }, /* GL_TEXTURE_COMPARE_SGIX */
-   { 34257, 0x00001003 }, /* GL_TEXTURE_COMPONENTS */
-   { 34279, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED */
-   { 34301, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED_ARB */
-   { 34327, 0x000086A3 }, /* GL_TEXTURE_COMPRESSED_FORMATS_ARB */
-   { 34361, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */
-   { 34394, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB */
-   { 34431, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT */
-   { 34459, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT_ARB */
-   { 34491, 0x00008078 }, /* GL_TEXTURE_COORD_ARRAY */
-   { 34514, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */
-   { 34552, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB */
-   { 34594, 0x00008092 }, /* GL_TEXTURE_COORD_ARRAY_POINTER */
-   { 34625, 0x00008088 }, /* GL_TEXTURE_COORD_ARRAY_SIZE */
-   { 34653, 0x0000808A }, /* GL_TEXTURE_COORD_ARRAY_STRIDE */
-   { 34683, 0x00008089 }, /* GL_TEXTURE_COORD_ARRAY_TYPE */
-   { 34711, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP */
-   { 34731, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP_ARB */
-   { 34755, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */
-   { 34786, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB */
-   { 34821, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */
-   { 34852, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB */
-   { 34887, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */
-   { 34918, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB */
-   { 34953, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */
-   { 34984, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB */
-   { 35019, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */
-   { 35050, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB */
-   { 35085, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */
-   { 35116, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB */
-   { 35151, 0x00008071 }, /* GL_TEXTURE_DEPTH */
-   { 35168, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE */
-   { 35190, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE_ARB */
-   { 35216, 0x00002300 }, /* GL_TEXTURE_ENV */
-   { 35231, 0x00002201 }, /* GL_TEXTURE_ENV_COLOR */
-   { 35252, 0x00002200 }, /* GL_TEXTURE_ENV_MODE */
-   { 35272, 0x00008500 }, /* GL_TEXTURE_FILTER_CONTROL */
-   { 35298, 0x00002500 }, /* GL_TEXTURE_GEN_MODE */
-   { 35318, 0x00000C63 }, /* GL_TEXTURE_GEN_Q */
-   { 35335, 0x00000C62 }, /* GL_TEXTURE_GEN_R */
-   { 35352, 0x00000C60 }, /* GL_TEXTURE_GEN_S */
-   { 35369, 0x00000C61 }, /* GL_TEXTURE_GEN_T */
-   { 35386, 0x0000819D }, /* GL_TEXTURE_GEQUAL_R_SGIX */
-   { 35411, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE */
-   { 35433, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE_EXT */
-   { 35459, 0x00001001 }, /* GL_TEXTURE_HEIGHT */
-   { 35477, 0x000080ED }, /* GL_TEXTURE_INDEX_SIZE_EXT */
-   { 35503, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE */
-   { 35529, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE_EXT */
-   { 35559, 0x00001003 }, /* GL_TEXTURE_INTERNAL_FORMAT */
-   { 35586, 0x0000819C }, /* GL_TEXTURE_LEQUAL_R_SGIX */
-   { 35611, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS */
-   { 35631, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS_EXT */
-   { 35655, 0x00008190 }, /* GL_TEXTURE_LOD_BIAS_R_SGIX */
-   { 35682, 0x0000818E }, /* GL_TEXTURE_LOD_BIAS_S_SGIX */
-   { 35709, 0x0000818F }, /* GL_TEXTURE_LOD_BIAS_T_SGIX */
-   { 35736, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE */
-   { 35762, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE_EXT */
-   { 35792, 0x00002800 }, /* GL_TEXTURE_MAG_FILTER */
-   { 35814, 0x00000BA8 }, /* GL_TEXTURE_MATRIX */
-   { 35832, 0x000084FE }, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */
-   { 35862, 0x0000836B }, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */
-   { 35890, 0x00008369 }, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */
-   { 35918, 0x0000836A }, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */
-   { 35946, 0x0000813D }, /* GL_TEXTURE_MAX_LEVEL */
-   { 35967, 0x0000813B }, /* GL_TEXTURE_MAX_LOD */
-   { 35986, 0x00002801 }, /* GL_TEXTURE_MIN_FILTER */
-   { 36008, 0x0000813A }, /* GL_TEXTURE_MIN_LOD */
-   { 36027, 0x00008066 }, /* GL_TEXTURE_PRIORITY */
-   { 36047, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_ARB */
-   { 36072, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_NV */
-   { 36096, 0x0000805C }, /* GL_TEXTURE_RED_SIZE */
-   { 36116, 0x0000805C }, /* GL_TEXTURE_RED_SIZE_EXT */
-   { 36140, 0x00008067 }, /* GL_TEXTURE_RESIDENT */
-   { 36160, 0x00000BA5 }, /* GL_TEXTURE_STACK_DEPTH */
-   { 36183, 0x000088F1 }, /* GL_TEXTURE_STENCIL_SIZE */
-   { 36207, 0x00008065 }, /* GL_TEXTURE_TOO_LARGE_EXT */
-   { 36232, 0x0000888F }, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */
-   { 36266, 0x00001000 }, /* GL_TEXTURE_WIDTH */
-   { 36283, 0x00008072 }, /* GL_TEXTURE_WRAP_R */
-   { 36301, 0x00002802 }, /* GL_TEXTURE_WRAP_S */
-   { 36319, 0x00002803 }, /* GL_TEXTURE_WRAP_T */
-   { 36337, 0x000088BF }, /* GL_TIME_ELAPSED_EXT */
-   { 36357, 0x00008648 }, /* GL_TRACK_MATRIX_NV */
-   { 36376, 0x00008649 }, /* GL_TRACK_MATRIX_TRANSFORM_NV */
-   { 36405, 0x00001000 }, /* GL_TRANSFORM_BIT */
-   { 36422, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX */
-   { 36448, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX_ARB */
-   { 36478, 0x000088B7 }, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */
-   { 36510, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX */
-   { 36540, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX_ARB */
-   { 36574, 0x0000862C }, /* GL_TRANSPOSE_NV */
-   { 36590, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX */
-   { 36621, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX_ARB */
-   { 36656, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX */
-   { 36684, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX_ARB */
-   { 36716, 0x00000004 }, /* GL_TRIANGLES */
-   { 36729, 0x00000006 }, /* GL_TRIANGLE_FAN */
-   { 36745, 0x00008615 }, /* GL_TRIANGLE_MESH_SUN */
-   { 36766, 0x00000005 }, /* GL_TRIANGLE_STRIP */
-   { 36784, 0x00000001 }, /* GL_TRUE */
-   { 36792, 0x00000CF5 }, /* GL_UNPACK_ALIGNMENT */
-   { 36812, 0x0000806E }, /* GL_UNPACK_IMAGE_HEIGHT */
-   { 36835, 0x00000CF1 }, /* GL_UNPACK_LSB_FIRST */
-   { 36855, 0x00000CF2 }, /* GL_UNPACK_ROW_LENGTH */
-   { 36876, 0x0000806D }, /* GL_UNPACK_SKIP_IMAGES */
-   { 36898, 0x00000CF4 }, /* GL_UNPACK_SKIP_PIXELS */
-   { 36920, 0x00000CF3 }, /* GL_UNPACK_SKIP_ROWS */
-   { 36940, 0x00000CF0 }, /* GL_UNPACK_SWAP_BYTES */
-   { 36961, 0x00001401 }, /* GL_UNSIGNED_BYTE */
-   { 36978, 0x00008362 }, /* GL_UNSIGNED_BYTE_2_3_3_REV */
-   { 37005, 0x00008032 }, /* GL_UNSIGNED_BYTE_3_3_2 */
-   { 37028, 0x00001405 }, /* GL_UNSIGNED_INT */
-   { 37044, 0x00008036 }, /* GL_UNSIGNED_INT_10_10_10_2 */
-   { 37071, 0x000084FA }, /* GL_UNSIGNED_INT_24_8 */
-   { 37092, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_NV */
-   { 37116, 0x00008368 }, /* GL_UNSIGNED_INT_2_10_10_10_REV */
-   { 37147, 0x00008035 }, /* GL_UNSIGNED_INT_8_8_8_8 */
-   { 37171, 0x00008367 }, /* GL_UNSIGNED_INT_8_8_8_8_REV */
-   { 37199, 0x00008C17 }, /* GL_UNSIGNED_NORMALIZED */
-   { 37222, 0x00001403 }, /* GL_UNSIGNED_SHORT */
-   { 37240, 0x00008366 }, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */
-   { 37270, 0x00008033 }, /* GL_UNSIGNED_SHORT_4_4_4_4 */
-   { 37296, 0x00008365 }, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */
-   { 37326, 0x00008034 }, /* GL_UNSIGNED_SHORT_5_5_5_1 */
-   { 37352, 0x00008363 }, /* GL_UNSIGNED_SHORT_5_6_5 */
-   { 37376, 0x00008364 }, /* GL_UNSIGNED_SHORT_5_6_5_REV */
-   { 37404, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_APPLE */
-   { 37432, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_MESA */
-   { 37459, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */
-   { 37491, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_MESA */
-   { 37522, 0x00008CA2 }, /* GL_UPPER_LEFT */
-   { 37536, 0x00002A20 }, /* GL_V2F */
-   { 37543, 0x00002A21 }, /* GL_V3F */
-   { 37550, 0x00008B83 }, /* GL_VALIDATE_STATUS */
-   { 37569, 0x00001F00 }, /* GL_VENDOR */
-   { 37579, 0x00001F02 }, /* GL_VERSION */
-   { 37590, 0x00008074 }, /* GL_VERTEX_ARRAY */
-   { 37606, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING_APPLE */
-   { 37636, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING */
-   { 37667, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING_ARB */
-   { 37702, 0x0000808E }, /* GL_VERTEX_ARRAY_POINTER */
-   { 37726, 0x0000807A }, /* GL_VERTEX_ARRAY_SIZE */
-   { 37747, 0x0000807C }, /* GL_VERTEX_ARRAY_STRIDE */
-   { 37770, 0x0000807B }, /* GL_VERTEX_ARRAY_TYPE */
-   { 37791, 0x00008650 }, /* GL_VERTEX_ATTRIB_ARRAY0_NV */
-   { 37818, 0x0000865A }, /* GL_VERTEX_ATTRIB_ARRAY10_NV */
-   { 37846, 0x0000865B }, /* GL_VERTEX_ATTRIB_ARRAY11_NV */
-   { 37874, 0x0000865C }, /* GL_VERTEX_ATTRIB_ARRAY12_NV */
-   { 37902, 0x0000865D }, /* GL_VERTEX_ATTRIB_ARRAY13_NV */
-   { 37930, 0x0000865E }, /* GL_VERTEX_ATTRIB_ARRAY14_NV */
-   { 37958, 0x0000865F }, /* GL_VERTEX_ATTRIB_ARRAY15_NV */
-   { 37986, 0x00008651 }, /* GL_VERTEX_ATTRIB_ARRAY1_NV */
-   { 38013, 0x00008652 }, /* GL_VERTEX_ATTRIB_ARRAY2_NV */
-   { 38040, 0x00008653 }, /* GL_VERTEX_ATTRIB_ARRAY3_NV */
-   { 38067, 0x00008654 }, /* GL_VERTEX_ATTRIB_ARRAY4_NV */
-   { 38094, 0x00008655 }, /* GL_VERTEX_ATTRIB_ARRAY5_NV */
-   { 38121, 0x00008656 }, /* GL_VERTEX_ATTRIB_ARRAY6_NV */
-   { 38148, 0x00008657 }, /* GL_VERTEX_ATTRIB_ARRAY7_NV */
-   { 38175, 0x00008658 }, /* GL_VERTEX_ATTRIB_ARRAY8_NV */
-   { 38202, 0x00008659 }, /* GL_VERTEX_ATTRIB_ARRAY9_NV */
-   { 38229, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */
-   { 38267, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB */
-   { 38309, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */
-   { 38340, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB */
-   { 38375, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */
-   { 38409, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB */
-   { 38447, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */
-   { 38478, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB */
-   { 38513, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */
-   { 38541, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB */
-   { 38573, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */
-   { 38603, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB */
-   { 38637, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */
-   { 38665, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB */
-   { 38697, 0x000086A7 }, /* GL_VERTEX_BLEND_ARB */
-   { 38717, 0x00008620 }, /* GL_VERTEX_PROGRAM_ARB */
-   { 38739, 0x0000864A }, /* GL_VERTEX_PROGRAM_BINDING_NV */
-   { 38768, 0x00008620 }, /* GL_VERTEX_PROGRAM_NV */
-   { 38789, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE */
-   { 38818, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_ARB */
-   { 38851, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_NV */
-   { 38883, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE */
-   { 38910, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_ARB */
-   { 38941, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_NV */
-   { 38971, 0x00008B31 }, /* GL_VERTEX_SHADER */
-   { 38988, 0x00008B31 }, /* GL_VERTEX_SHADER_ARB */
-   { 39009, 0x00008621 }, /* GL_VERTEX_STATE_PROGRAM_NV */
-   { 39036, 0x00000BA2 }, /* GL_VIEWPORT */
-   { 39048, 0x00000800 }, /* GL_VIEWPORT_BIT */
-   { 39064, 0x000086AD }, /* GL_WEIGHT_ARRAY_ARB */
-   { 39084, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */
-   { 39115, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB */
-   { 39150, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_ARB */
-   { 39178, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_ARB */
-   { 39203, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_ARB */
-   { 39230, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_ARB */
-   { 39255, 0x000086A6 }, /* GL_WEIGHT_SUM_UNITY_ARB */
-   { 39279, 0x000081D4 }, /* GL_WRAP_BORDER_SUN */
-   { 39298, 0x000088B9 }, /* GL_WRITE_ONLY */
-   { 39312, 0x000088B9 }, /* GL_WRITE_ONLY_ARB */
-   { 39330, 0x00001506 }, /* GL_XOR */
-   { 39337, 0x000085B9 }, /* GL_YCBCR_422_APPLE */
-   { 39356, 0x00008757 }, /* GL_YCBCR_MESA */
-   { 39370, 0x00000000 }, /* GL_ZERO */
-   { 39378, 0x00000D16 }, /* GL_ZOOM_X */
-   { 39388, 0x00000D17 }, /* GL_ZOOM_Y */
+   {  6072, 0x00008F36 }, /* GL_COPY_READ_BUFFER */
+   {  6092, 0x00008F37 }, /* GL_COPY_WRITE_BUFFER */
+   {  6113, 0x00000B44 }, /* GL_CULL_FACE */
+   {  6126, 0x00000B45 }, /* GL_CULL_FACE_MODE */
+   {  6144, 0x000081AA }, /* GL_CULL_VERTEX_EXT */
+   {  6163, 0x000081AC }, /* GL_CULL_VERTEX_EYE_POSITION_EXT */
+   {  6195, 0x000081AB }, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */
+   {  6230, 0x00008626 }, /* GL_CURRENT_ATTRIB_NV */
+   {  6251, 0x00000001 }, /* GL_CURRENT_BIT */
+   {  6266, 0x00000B00 }, /* GL_CURRENT_COLOR */
+   {  6283, 0x00008453 }, /* GL_CURRENT_FOG_COORD */
+   {  6304, 0x00008453 }, /* GL_CURRENT_FOG_COORDINATE */
+   {  6330, 0x00000B01 }, /* GL_CURRENT_INDEX */
+   {  6347, 0x00008641 }, /* GL_CURRENT_MATRIX_ARB */
+   {  6369, 0x00008845 }, /* GL_CURRENT_MATRIX_INDEX_ARB */
+   {  6397, 0x00008641 }, /* GL_CURRENT_MATRIX_NV */
+   {  6418, 0x00008640 }, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */
+   {  6452, 0x00008640 }, /* GL_CURRENT_MATRIX_STACK_DEPTH_NV */
+   {  6485, 0x00000B02 }, /* GL_CURRENT_NORMAL */
+   {  6503, 0x00008843 }, /* GL_CURRENT_PALETTE_MATRIX_ARB */
+   {  6533, 0x00008B8D }, /* GL_CURRENT_PROGRAM */
+   {  6552, 0x00008865 }, /* GL_CURRENT_QUERY */
+   {  6569, 0x00008865 }, /* GL_CURRENT_QUERY_ARB */
+   {  6590, 0x00000B04 }, /* GL_CURRENT_RASTER_COLOR */
+   {  6614, 0x00000B09 }, /* GL_CURRENT_RASTER_DISTANCE */
+   {  6641, 0x00000B05 }, /* GL_CURRENT_RASTER_INDEX */
+   {  6665, 0x00000B07 }, /* GL_CURRENT_RASTER_POSITION */
+   {  6692, 0x00000B08 }, /* GL_CURRENT_RASTER_POSITION_VALID */
+   {  6725, 0x0000845F }, /* GL_CURRENT_RASTER_SECONDARY_COLOR */
+   {  6759, 0x00000B06 }, /* GL_CURRENT_RASTER_TEXTURE_COORDS */
+   {  6792, 0x00008459 }, /* GL_CURRENT_SECONDARY_COLOR */
+   {  6819, 0x00000B03 }, /* GL_CURRENT_TEXTURE_COORDS */
+   {  6845, 0x00008626 }, /* GL_CURRENT_VERTEX_ATTRIB */
+   {  6870, 0x00008626 }, /* GL_CURRENT_VERTEX_ATTRIB_ARB */
+   {  6899, 0x000086A8 }, /* GL_CURRENT_WEIGHT_ARB */
+   {  6921, 0x00000900 }, /* GL_CW */
+   {  6927, 0x0000875B }, /* GL_DEBUG_ASSERT_MESA */
+   {  6948, 0x00008759 }, /* GL_DEBUG_OBJECT_MESA */
+   {  6969, 0x0000875A }, /* GL_DEBUG_PRINT_MESA */
+   {  6989, 0x00002101 }, /* GL_DECAL */
+   {  6998, 0x00001E03 }, /* GL_DECR */
+   {  7006, 0x00008508 }, /* GL_DECR_WRAP */
+   {  7019, 0x00008508 }, /* GL_DECR_WRAP_EXT */
+   {  7036, 0x00008B80 }, /* GL_DELETE_STATUS */
+   {  7053, 0x00001801 }, /* GL_DEPTH */
+   {  7062, 0x000088F0 }, /* GL_DEPTH24_STENCIL8 */
+   {  7082, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT */
+   {  7102, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT_EXT */
+   {  7126, 0x00000D1F }, /* GL_DEPTH_BIAS */
+   {  7140, 0x00000D56 }, /* GL_DEPTH_BITS */
+   {  7154, 0x00008891 }, /* GL_DEPTH_BOUNDS_EXT */
+   {  7174, 0x00008890 }, /* GL_DEPTH_BOUNDS_TEST_EXT */
+   {  7199, 0x00000100 }, /* GL_DEPTH_BUFFER_BIT */
+   {  7219, 0x0000864F }, /* GL_DEPTH_CLAMP_NV */
+   {  7237, 0x00000B73 }, /* GL_DEPTH_CLEAR_VALUE */
+   {  7258, 0x00001902 }, /* GL_DEPTH_COMPONENT */
+   {  7277, 0x000081A5 }, /* GL_DEPTH_COMPONENT16 */
+   {  7298, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_ARB */
+   {  7323, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_SGIX */
+   {  7349, 0x000081A6 }, /* GL_DEPTH_COMPONENT24 */
+   {  7370, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_ARB */
+   {  7395, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_SGIX */
+   {  7421, 0x000081A7 }, /* GL_DEPTH_COMPONENT32 */
+   {  7442, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_ARB */
+   {  7467, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_SGIX */
+   {  7493, 0x00000B74 }, /* GL_DEPTH_FUNC */
+   {  7507, 0x00000B70 }, /* GL_DEPTH_RANGE */
+   {  7522, 0x00000D1E }, /* GL_DEPTH_SCALE */
+   {  7537, 0x000084F9 }, /* GL_DEPTH_STENCIL */
+   {  7554, 0x0000821A }, /* GL_DEPTH_STENCIL_ATTACHMENT */
+   {  7582, 0x000084F9 }, /* GL_DEPTH_STENCIL_NV */
+   {  7602, 0x0000886F }, /* GL_DEPTH_STENCIL_TO_BGRA_NV */
+   {  7630, 0x0000886E }, /* GL_DEPTH_STENCIL_TO_RGBA_NV */
+   {  7658, 0x00000B71 }, /* GL_DEPTH_TEST */
+   {  7672, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE */
+   {  7694, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE_ARB */
+   {  7720, 0x00000B72 }, /* GL_DEPTH_WRITEMASK */
+   {  7739, 0x00001201 }, /* GL_DIFFUSE */
+   {  7750, 0x00000BD0 }, /* GL_DITHER */
+   {  7760, 0x00000A02 }, /* GL_DOMAIN */
+   {  7770, 0x00001100 }, /* GL_DONT_CARE */
+   {  7783, 0x000086AE }, /* GL_DOT3_RGB */
+   {  7795, 0x000086AF }, /* GL_DOT3_RGBA */
+   {  7808, 0x000086AF }, /* GL_DOT3_RGBA_ARB */
+   {  7825, 0x00008741 }, /* GL_DOT3_RGBA_EXT */
+   {  7842, 0x000086AE }, /* GL_DOT3_RGB_ARB */
+   {  7858, 0x00008740 }, /* GL_DOT3_RGB_EXT */
+   {  7874, 0x0000140A }, /* GL_DOUBLE */
+   {  7884, 0x00000C32 }, /* GL_DOUBLEBUFFER */
+   {  7900, 0x00000C01 }, /* GL_DRAW_BUFFER */
+   {  7915, 0x00008825 }, /* GL_DRAW_BUFFER0 */
+   {  7931, 0x00008825 }, /* GL_DRAW_BUFFER0_ARB */
+   {  7951, 0x00008825 }, /* GL_DRAW_BUFFER0_ATI */
+   {  7971, 0x00008826 }, /* GL_DRAW_BUFFER1 */
+   {  7987, 0x0000882F }, /* GL_DRAW_BUFFER10 */
+   {  8004, 0x0000882F }, /* GL_DRAW_BUFFER10_ARB */
+   {  8025, 0x0000882F }, /* GL_DRAW_BUFFER10_ATI */
+   {  8046, 0x00008830 }, /* GL_DRAW_BUFFER11 */
+   {  8063, 0x00008830 }, /* GL_DRAW_BUFFER11_ARB */
+   {  8084, 0x00008830 }, /* GL_DRAW_BUFFER11_ATI */
+   {  8105, 0x00008831 }, /* GL_DRAW_BUFFER12 */
+   {  8122, 0x00008831 }, /* GL_DRAW_BUFFER12_ARB */
+   {  8143, 0x00008831 }, /* GL_DRAW_BUFFER12_ATI */
+   {  8164, 0x00008832 }, /* GL_DRAW_BUFFER13 */
+   {  8181, 0x00008832 }, /* GL_DRAW_BUFFER13_ARB */
+   {  8202, 0x00008832 }, /* GL_DRAW_BUFFER13_ATI */
+   {  8223, 0x00008833 }, /* GL_DRAW_BUFFER14 */
+   {  8240, 0x00008833 }, /* GL_DRAW_BUFFER14_ARB */
+   {  8261, 0x00008833 }, /* GL_DRAW_BUFFER14_ATI */
+   {  8282, 0x00008834 }, /* GL_DRAW_BUFFER15 */
+   {  8299, 0x00008834 }, /* GL_DRAW_BUFFER15_ARB */
+   {  8320, 0x00008834 }, /* GL_DRAW_BUFFER15_ATI */
+   {  8341, 0x00008826 }, /* GL_DRAW_BUFFER1_ARB */
+   {  8361, 0x00008826 }, /* GL_DRAW_BUFFER1_ATI */
+   {  8381, 0x00008827 }, /* GL_DRAW_BUFFER2 */
+   {  8397, 0x00008827 }, /* GL_DRAW_BUFFER2_ARB */
+   {  8417, 0x00008827 }, /* GL_DRAW_BUFFER2_ATI */
+   {  8437, 0x00008828 }, /* GL_DRAW_BUFFER3 */
+   {  8453, 0x00008828 }, /* GL_DRAW_BUFFER3_ARB */
+   {  8473, 0x00008828 }, /* GL_DRAW_BUFFER3_ATI */
+   {  8493, 0x00008829 }, /* GL_DRAW_BUFFER4 */
+   {  8509, 0x00008829 }, /* GL_DRAW_BUFFER4_ARB */
+   {  8529, 0x00008829 }, /* GL_DRAW_BUFFER4_ATI */
+   {  8549, 0x0000882A }, /* GL_DRAW_BUFFER5 */
+   {  8565, 0x0000882A }, /* GL_DRAW_BUFFER5_ARB */
+   {  8585, 0x0000882A }, /* GL_DRAW_BUFFER5_ATI */
+   {  8605, 0x0000882B }, /* GL_DRAW_BUFFER6 */
+   {  8621, 0x0000882B }, /* GL_DRAW_BUFFER6_ARB */
+   {  8641, 0x0000882B }, /* GL_DRAW_BUFFER6_ATI */
+   {  8661, 0x0000882C }, /* GL_DRAW_BUFFER7 */
+   {  8677, 0x0000882C }, /* GL_DRAW_BUFFER7_ARB */
+   {  8697, 0x0000882C }, /* GL_DRAW_BUFFER7_ATI */
+   {  8717, 0x0000882D }, /* GL_DRAW_BUFFER8 */
+   {  8733, 0x0000882D }, /* GL_DRAW_BUFFER8_ARB */
+   {  8753, 0x0000882D }, /* GL_DRAW_BUFFER8_ATI */
+   {  8773, 0x0000882E }, /* GL_DRAW_BUFFER9 */
+   {  8789, 0x0000882E }, /* GL_DRAW_BUFFER9_ARB */
+   {  8809, 0x0000882E }, /* GL_DRAW_BUFFER9_ATI */
+   {  8829, 0x00008CA9 }, /* GL_DRAW_FRAMEBUFFER */
+   {  8849, 0x00008CA6 }, /* GL_DRAW_FRAMEBUFFER_BINDING_EXT */
+   {  8881, 0x00008CA9 }, /* GL_DRAW_FRAMEBUFFER_EXT */
+   {  8905, 0x00000705 }, /* GL_DRAW_PIXEL_TOKEN */
+   {  8925, 0x00000304 }, /* GL_DST_ALPHA */
+   {  8938, 0x00000306 }, /* GL_DST_COLOR */
+   {  8951, 0x0000877A }, /* GL_DU8DV8_ATI */
+   {  8965, 0x00008779 }, /* GL_DUDV_ATI */
+   {  8977, 0x000088EA }, /* GL_DYNAMIC_COPY */
+   {  8993, 0x000088EA }, /* GL_DYNAMIC_COPY_ARB */
+   {  9013, 0x000088E8 }, /* GL_DYNAMIC_DRAW */
+   {  9029, 0x000088E8 }, /* GL_DYNAMIC_DRAW_ARB */
+   {  9049, 0x000088E9 }, /* GL_DYNAMIC_READ */
+   {  9065, 0x000088E9 }, /* GL_DYNAMIC_READ_ARB */
+   {  9085, 0x00000B43 }, /* GL_EDGE_FLAG */
+   {  9098, 0x00008079 }, /* GL_EDGE_FLAG_ARRAY */
+   {  9117, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */
+   {  9151, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB */
+   {  9189, 0x00008093 }, /* GL_EDGE_FLAG_ARRAY_POINTER */
+   {  9216, 0x0000808C }, /* GL_EDGE_FLAG_ARRAY_STRIDE */
+   {  9242, 0x00008893 }, /* GL_ELEMENT_ARRAY_BUFFER */
+   {  9266, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */
+   {  9298, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB */
+   {  9334, 0x00001600 }, /* GL_EMISSION */
+   {  9346, 0x00002000 }, /* GL_ENABLE_BIT */
+   {  9360, 0x00000202 }, /* GL_EQUAL */
+   {  9369, 0x00001509 }, /* GL_EQUIV */
+   {  9378, 0x00010000 }, /* GL_EVAL_BIT */
+   {  9390, 0x00000800 }, /* GL_EXP */
+   {  9397, 0x00000801 }, /* GL_EXP2 */
+   {  9405, 0x00001F03 }, /* GL_EXTENSIONS */
+   {  9419, 0x00002400 }, /* GL_EYE_LINEAR */
+   {  9433, 0x00002502 }, /* GL_EYE_PLANE */
+   {  9446, 0x0000855C }, /* GL_EYE_PLANE_ABSOLUTE_NV */
+   {  9471, 0x0000855B }, /* GL_EYE_RADIAL_NV */
+   {  9488, 0x00000000 }, /* GL_FALSE */
+   {  9497, 0x00001101 }, /* GL_FASTEST */
+   {  9508, 0x00001C01 }, /* GL_FEEDBACK */
+   {  9520, 0x00000DF0 }, /* GL_FEEDBACK_BUFFER_POINTER */
+   {  9547, 0x00000DF1 }, /* GL_FEEDBACK_BUFFER_SIZE */
+   {  9571, 0x00000DF2 }, /* GL_FEEDBACK_BUFFER_TYPE */
+   {  9595, 0x00001B02 }, /* GL_FILL */
+   {  9603, 0x00001D00 }, /* GL_FLAT */
+   {  9611, 0x00001406 }, /* GL_FLOAT */
+   {  9620, 0x00008B5A }, /* GL_FLOAT_MAT2 */
+   {  9634, 0x00008B5A }, /* GL_FLOAT_MAT2_ARB */
+   {  9652, 0x00008B65 }, /* GL_FLOAT_MAT2x3 */
+   {  9668, 0x00008B66 }, /* GL_FLOAT_MAT2x4 */
+   {  9684, 0x00008B5B }, /* GL_FLOAT_MAT3 */
+   {  9698, 0x00008B5B }, /* GL_FLOAT_MAT3_ARB */
+   {  9716, 0x00008B67 }, /* GL_FLOAT_MAT3x2 */
+   {  9732, 0x00008B68 }, /* GL_FLOAT_MAT3x4 */
+   {  9748, 0x00008B5C }, /* GL_FLOAT_MAT4 */
+   {  9762, 0x00008B5C }, /* GL_FLOAT_MAT4_ARB */
+   {  9780, 0x00008B69 }, /* GL_FLOAT_MAT4x2 */
+   {  9796, 0x00008B6A }, /* GL_FLOAT_MAT4x3 */
+   {  9812, 0x00008B50 }, /* GL_FLOAT_VEC2 */
+   {  9826, 0x00008B50 }, /* GL_FLOAT_VEC2_ARB */
+   {  9844, 0x00008B51 }, /* GL_FLOAT_VEC3 */
+   {  9858, 0x00008B51 }, /* GL_FLOAT_VEC3_ARB */
+   {  9876, 0x00008B52 }, /* GL_FLOAT_VEC4 */
+   {  9890, 0x00008B52 }, /* GL_FLOAT_VEC4_ARB */
+   {  9908, 0x00000B60 }, /* GL_FOG */
+   {  9915, 0x00000080 }, /* GL_FOG_BIT */
+   {  9926, 0x00000B66 }, /* GL_FOG_COLOR */
+   {  9939, 0x00008451 }, /* GL_FOG_COORD */
+   {  9952, 0x00008451 }, /* GL_FOG_COORDINATE */
+   {  9970, 0x00008457 }, /* GL_FOG_COORDINATE_ARRAY */
+   {  9994, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */
+   { 10033, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB */
+   { 10076, 0x00008456 }, /* GL_FOG_COORDINATE_ARRAY_POINTER */
+   { 10108, 0x00008455 }, /* GL_FOG_COORDINATE_ARRAY_STRIDE */
+   { 10139, 0x00008454 }, /* GL_FOG_COORDINATE_ARRAY_TYPE */
+   { 10168, 0x00008450 }, /* GL_FOG_COORDINATE_SOURCE */
+   { 10193, 0x00008457 }, /* GL_FOG_COORD_ARRAY */
+   { 10212, 0x0000889D }, /* GL_FOG_COORD_ARRAY_BUFFER_BINDING */
+   { 10246, 0x00008456 }, /* GL_FOG_COORD_ARRAY_POINTER */
+   { 10273, 0x00008455 }, /* GL_FOG_COORD_ARRAY_STRIDE */
+   { 10299, 0x00008454 }, /* GL_FOG_COORD_ARRAY_TYPE */
+   { 10323, 0x00008450 }, /* GL_FOG_COORD_SRC */
+   { 10340, 0x00000B62 }, /* GL_FOG_DENSITY */
+   { 10355, 0x0000855A }, /* GL_FOG_DISTANCE_MODE_NV */
+   { 10379, 0x00000B64 }, /* GL_FOG_END */
+   { 10390, 0x00000C54 }, /* GL_FOG_HINT */
+   { 10402, 0x00000B61 }, /* GL_FOG_INDEX */
+   { 10415, 0x00000B65 }, /* GL_FOG_MODE */
+   { 10427, 0x00008198 }, /* GL_FOG_OFFSET_SGIX */
+   { 10446, 0x00008199 }, /* GL_FOG_OFFSET_VALUE_SGIX */
+   { 10471, 0x00000B63 }, /* GL_FOG_START */
+   { 10484, 0x00008452 }, /* GL_FRAGMENT_DEPTH */
+   { 10502, 0x00008804 }, /* GL_FRAGMENT_PROGRAM_ARB */
+   { 10526, 0x00008B30 }, /* GL_FRAGMENT_SHADER */
+   { 10545, 0x00008B30 }, /* GL_FRAGMENT_SHADER_ARB */
+   { 10568, 0x00008B8B }, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */
+   { 10603, 0x00008D40 }, /* GL_FRAMEBUFFER */
+   { 10618, 0x00008215 }, /* GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */
+   { 10655, 0x00008214 }, /* GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */
+   { 10691, 0x00008210 }, /* GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */
+   { 10732, 0x00008211 }, /* GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */
+   { 10773, 0x00008216 }, /* GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */
+   { 10810, 0x00008213 }, /* GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */
+   { 10847, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */
+   { 10885, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT */
+   { 10927, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */
+   { 10965, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT */
+   { 11007, 0x00008212 }, /* GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */
+   { 11042, 0x00008217 }, /* GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */
+   { 11081, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT */
+   { 11130, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */
+   { 11178, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT */
+   { 11230, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */
+   { 11270, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */
+   { 11314, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */
+   { 11354, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT */
+   { 11398, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING_EXT */
+   { 11425, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE */
+   { 11449, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE_EXT */
+   { 11477, 0x00008218 }, /* GL_FRAMEBUFFER_DEFAULT */
+   { 11500, 0x00008D40 }, /* GL_FRAMEBUFFER_EXT */
+   { 11519, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */
+   { 11556, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT */
+   { 11597, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */
+   { 11638, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT */
+   { 11680, 0x00008CD8 }, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */
+   { 11731, 0x00008CDA }, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */
+   { 11769, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */
+   { 11814, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT */
+   { 11863, 0x00008D56 }, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */
+   { 11901, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT */
+   { 11943, 0x00008CDE }, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */
+   { 11975, 0x00008219 }, /* GL_FRAMEBUFFER_UNDEFINED */
+   { 12000, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED */
+   { 12027, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED_EXT */
+   { 12058, 0x00000404 }, /* GL_FRONT */
+   { 12067, 0x00000408 }, /* GL_FRONT_AND_BACK */
+   { 12085, 0x00000B46 }, /* GL_FRONT_FACE */
+   { 12099, 0x00000400 }, /* GL_FRONT_LEFT */
+   { 12113, 0x00000401 }, /* GL_FRONT_RIGHT */
+   { 12128, 0x00008006 }, /* GL_FUNC_ADD */
+   { 12140, 0x00008006 }, /* GL_FUNC_ADD_EXT */
+   { 12156, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT */
+   { 12181, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT_EXT */
+   { 12210, 0x0000800A }, /* GL_FUNC_SUBTRACT */
+   { 12227, 0x0000800A }, /* GL_FUNC_SUBTRACT_EXT */
+   { 12248, 0x00008191 }, /* GL_GENERATE_MIPMAP */
+   { 12267, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT */
+   { 12291, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT_SGIS */
+   { 12320, 0x00008191 }, /* GL_GENERATE_MIPMAP_SGIS */
+   { 12344, 0x00000206 }, /* GL_GEQUAL */
+   { 12354, 0x00000204 }, /* GL_GREATER */
+   { 12365, 0x00001904 }, /* GL_GREEN */
+   { 12374, 0x00000D19 }, /* GL_GREEN_BIAS */
+   { 12388, 0x00000D53 }, /* GL_GREEN_BITS */
+   { 12402, 0x00000D18 }, /* GL_GREEN_SCALE */
+   { 12417, 0x00008000 }, /* GL_HINT_BIT */
+   { 12429, 0x00008024 }, /* GL_HISTOGRAM */
+   { 12442, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE */
+   { 12466, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE_EXT */
+   { 12494, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE */
+   { 12517, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE_EXT */
+   { 12544, 0x00008024 }, /* GL_HISTOGRAM_EXT */
+   { 12561, 0x00008027 }, /* GL_HISTOGRAM_FORMAT */
+   { 12581, 0x00008027 }, /* GL_HISTOGRAM_FORMAT_EXT */
+   { 12605, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE */
+   { 12629, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE_EXT */
+   { 12657, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE */
+   { 12685, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE_EXT */
+   { 12717, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE */
+   { 12739, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE_EXT */
+   { 12765, 0x0000802D }, /* GL_HISTOGRAM_SINK */
+   { 12783, 0x0000802D }, /* GL_HISTOGRAM_SINK_EXT */
+   { 12805, 0x00008026 }, /* GL_HISTOGRAM_WIDTH */
+   { 12824, 0x00008026 }, /* GL_HISTOGRAM_WIDTH_EXT */
+   { 12847, 0x0000862A }, /* GL_IDENTITY_NV */
+   { 12862, 0x00008150 }, /* GL_IGNORE_BORDER_HP */
+   { 12882, 0x00008B9B }, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */
+   { 12922, 0x00008B9A }, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */
+   { 12960, 0x00001E02 }, /* GL_INCR */
+   { 12968, 0x00008507 }, /* GL_INCR_WRAP */
+   { 12981, 0x00008507 }, /* GL_INCR_WRAP_EXT */
+   { 12998, 0x00008222 }, /* GL_INDEX */
+   { 13007, 0x00008077 }, /* GL_INDEX_ARRAY */
+   { 13022, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING */
+   { 13052, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING_ARB */
+   { 13086, 0x00008091 }, /* GL_INDEX_ARRAY_POINTER */
+   { 13109, 0x00008086 }, /* GL_INDEX_ARRAY_STRIDE */
+   { 13131, 0x00008085 }, /* GL_INDEX_ARRAY_TYPE */
+   { 13151, 0x00000D51 }, /* GL_INDEX_BITS */
+   { 13165, 0x00000C20 }, /* GL_INDEX_CLEAR_VALUE */
+   { 13186, 0x00000BF1 }, /* GL_INDEX_LOGIC_OP */
+   { 13204, 0x00000C30 }, /* GL_INDEX_MODE */
+   { 13218, 0x00000D13 }, /* GL_INDEX_OFFSET */
+   { 13234, 0x00000D12 }, /* GL_INDEX_SHIFT */
+   { 13249, 0x00000C21 }, /* GL_INDEX_WRITEMASK */
+   { 13268, 0x00008B84 }, /* GL_INFO_LOG_LENGTH */
+   { 13287, 0x00001404 }, /* GL_INT */
+   { 13294, 0x00008049 }, /* GL_INTENSITY */
+   { 13307, 0x0000804C }, /* GL_INTENSITY12 */
+   { 13322, 0x0000804C }, /* GL_INTENSITY12_EXT */
+   { 13341, 0x0000804D }, /* GL_INTENSITY16 */
+   { 13356, 0x0000804D }, /* GL_INTENSITY16_EXT */
+   { 13375, 0x0000804A }, /* GL_INTENSITY4 */
+   { 13389, 0x0000804A }, /* GL_INTENSITY4_EXT */
+   { 13407, 0x0000804B }, /* GL_INTENSITY8 */
+   { 13421, 0x0000804B }, /* GL_INTENSITY8_EXT */
+   { 13439, 0x00008049 }, /* GL_INTENSITY_EXT */
+   { 13456, 0x00008575 }, /* GL_INTERPOLATE */
+   { 13471, 0x00008575 }, /* GL_INTERPOLATE_ARB */
+   { 13490, 0x00008575 }, /* GL_INTERPOLATE_EXT */
+   { 13509, 0x00008B53 }, /* GL_INT_VEC2 */
+   { 13521, 0x00008B53 }, /* GL_INT_VEC2_ARB */
+   { 13537, 0x00008B54 }, /* GL_INT_VEC3 */
+   { 13549, 0x00008B54 }, /* GL_INT_VEC3_ARB */
+   { 13565, 0x00008B55 }, /* GL_INT_VEC4 */
+   { 13577, 0x00008B55 }, /* GL_INT_VEC4_ARB */
+   { 13593, 0x00000500 }, /* GL_INVALID_ENUM */
+   { 13609, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION */
+   { 13642, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION_EXT */
+   { 13679, 0x00000502 }, /* GL_INVALID_OPERATION */
+   { 13700, 0x00000501 }, /* GL_INVALID_VALUE */
+   { 13717, 0x0000862B }, /* GL_INVERSE_NV */
+   { 13731, 0x0000862D }, /* GL_INVERSE_TRANSPOSE_NV */
+   { 13755, 0x0000150A }, /* GL_INVERT */
+   { 13765, 0x00001E00 }, /* GL_KEEP */
+   { 13773, 0x00000406 }, /* GL_LEFT */
+   { 13781, 0x00000203 }, /* GL_LEQUAL */
+   { 13791, 0x00000201 }, /* GL_LESS */
+   { 13799, 0x00004000 }, /* GL_LIGHT0 */
+   { 13809, 0x00004001 }, /* GL_LIGHT1 */
+   { 13819, 0x00004002 }, /* GL_LIGHT2 */
+   { 13829, 0x00004003 }, /* GL_LIGHT3 */
+   { 13839, 0x00004004 }, /* GL_LIGHT4 */
+   { 13849, 0x00004005 }, /* GL_LIGHT5 */
+   { 13859, 0x00004006 }, /* GL_LIGHT6 */
+   { 13869, 0x00004007 }, /* GL_LIGHT7 */
+   { 13879, 0x00000B50 }, /* GL_LIGHTING */
+   { 13891, 0x00000040 }, /* GL_LIGHTING_BIT */
+   { 13907, 0x00000B53 }, /* GL_LIGHT_MODEL_AMBIENT */
+   { 13930, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL */
+   { 13959, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL_EXT */
+   { 13992, 0x00000B51 }, /* GL_LIGHT_MODEL_LOCAL_VIEWER */
+   { 14020, 0x00000B52 }, /* GL_LIGHT_MODEL_TWO_SIDE */
+   { 14044, 0x00001B01 }, /* GL_LINE */
+   { 14052, 0x00002601 }, /* GL_LINEAR */
+   { 14062, 0x00001208 }, /* GL_LINEAR_ATTENUATION */
+   { 14084, 0x00008170 }, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */
+   { 14114, 0x0000844F }, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */
+   { 14145, 0x00002703 }, /* GL_LINEAR_MIPMAP_LINEAR */
+   { 14169, 0x00002701 }, /* GL_LINEAR_MIPMAP_NEAREST */
+   { 14194, 0x00000001 }, /* GL_LINES */
+   { 14203, 0x00000004 }, /* GL_LINE_BIT */
+   { 14215, 0x00000002 }, /* GL_LINE_LOOP */
+   { 14228, 0x00000707 }, /* GL_LINE_RESET_TOKEN */
+   { 14248, 0x00000B20 }, /* GL_LINE_SMOOTH */
+   { 14263, 0x00000C52 }, /* GL_LINE_SMOOTH_HINT */
+   { 14283, 0x00000B24 }, /* GL_LINE_STIPPLE */
+   { 14299, 0x00000B25 }, /* GL_LINE_STIPPLE_PATTERN */
+   { 14323, 0x00000B26 }, /* GL_LINE_STIPPLE_REPEAT */
+   { 14346, 0x00000003 }, /* GL_LINE_STRIP */
+   { 14360, 0x00000702 }, /* GL_LINE_TOKEN */
+   { 14374, 0x00000B21 }, /* GL_LINE_WIDTH */
+   { 14388, 0x00000B23 }, /* GL_LINE_WIDTH_GRANULARITY */
+   { 14414, 0x00000B22 }, /* GL_LINE_WIDTH_RANGE */
+   { 14434, 0x00008B82 }, /* GL_LINK_STATUS */
+   { 14449, 0x00000B32 }, /* GL_LIST_BASE */
+   { 14462, 0x00020000 }, /* GL_LIST_BIT */
+   { 14474, 0x00000B33 }, /* GL_LIST_INDEX */
+   { 14488, 0x00000B30 }, /* GL_LIST_MODE */
+   { 14501, 0x00000101 }, /* GL_LOAD */
+   { 14509, 0x00000BF1 }, /* GL_LOGIC_OP */
+   { 14521, 0x00000BF0 }, /* GL_LOGIC_OP_MODE */
+   { 14538, 0x00008CA1 }, /* GL_LOWER_LEFT */
+   { 14552, 0x00001909 }, /* GL_LUMINANCE */
+   { 14565, 0x00008041 }, /* GL_LUMINANCE12 */
+   { 14580, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12 */
+   { 14603, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12_EXT */
+   { 14630, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4 */
+   { 14652, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4_EXT */
+   { 14678, 0x00008041 }, /* GL_LUMINANCE12_EXT */
+   { 14697, 0x00008042 }, /* GL_LUMINANCE16 */
+   { 14712, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16 */
+   { 14735, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16_EXT */
+   { 14762, 0x00008042 }, /* GL_LUMINANCE16_EXT */
+   { 14781, 0x0000803F }, /* GL_LUMINANCE4 */
+   { 14795, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4 */
+   { 14816, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4_EXT */
+   { 14841, 0x0000803F }, /* GL_LUMINANCE4_EXT */
+   { 14859, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2 */
+   { 14880, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2_EXT */
+   { 14905, 0x00008040 }, /* GL_LUMINANCE8 */
+   { 14919, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8 */
+   { 14940, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8_EXT */
+   { 14965, 0x00008040 }, /* GL_LUMINANCE8_EXT */
+   { 14983, 0x0000190A }, /* GL_LUMINANCE_ALPHA */
+   { 15002, 0x00000D90 }, /* GL_MAP1_COLOR_4 */
+   { 15018, 0x00000DD0 }, /* GL_MAP1_GRID_DOMAIN */
+   { 15038, 0x00000DD1 }, /* GL_MAP1_GRID_SEGMENTS */
+   { 15060, 0x00000D91 }, /* GL_MAP1_INDEX */
+   { 15074, 0x00000D92 }, /* GL_MAP1_NORMAL */
+   { 15089, 0x00000D93 }, /* GL_MAP1_TEXTURE_COORD_1 */
+   { 15113, 0x00000D94 }, /* GL_MAP1_TEXTURE_COORD_2 */
+   { 15137, 0x00000D95 }, /* GL_MAP1_TEXTURE_COORD_3 */
+   { 15161, 0x00000D96 }, /* GL_MAP1_TEXTURE_COORD_4 */
+   { 15185, 0x00000D97 }, /* GL_MAP1_VERTEX_3 */
+   { 15202, 0x00000D98 }, /* GL_MAP1_VERTEX_4 */
+   { 15219, 0x00008660 }, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */
+   { 15247, 0x0000866A }, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */
+   { 15276, 0x0000866B }, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */
+   { 15305, 0x0000866C }, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */
+   { 15334, 0x0000866D }, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */
+   { 15363, 0x0000866E }, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */
+   { 15392, 0x0000866F }, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */
+   { 15421, 0x00008661 }, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */
+   { 15449, 0x00008662 }, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */
+   { 15477, 0x00008663 }, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */
+   { 15505, 0x00008664 }, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */
+   { 15533, 0x00008665 }, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */
+   { 15561, 0x00008666 }, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */
+   { 15589, 0x00008667 }, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */
+   { 15617, 0x00008668 }, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */
+   { 15645, 0x00008669 }, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */
+   { 15673, 0x00000DB0 }, /* GL_MAP2_COLOR_4 */
+   { 15689, 0x00000DD2 }, /* GL_MAP2_GRID_DOMAIN */
+   { 15709, 0x00000DD3 }, /* GL_MAP2_GRID_SEGMENTS */
+   { 15731, 0x00000DB1 }, /* GL_MAP2_INDEX */
+   { 15745, 0x00000DB2 }, /* GL_MAP2_NORMAL */
+   { 15760, 0x00000DB3 }, /* GL_MAP2_TEXTURE_COORD_1 */
+   { 15784, 0x00000DB4 }, /* GL_MAP2_TEXTURE_COORD_2 */
+   { 15808, 0x00000DB5 }, /* GL_MAP2_TEXTURE_COORD_3 */
+   { 15832, 0x00000DB6 }, /* GL_MAP2_TEXTURE_COORD_4 */
+   { 15856, 0x00000DB7 }, /* GL_MAP2_VERTEX_3 */
+   { 15873, 0x00000DB8 }, /* GL_MAP2_VERTEX_4 */
+   { 15890, 0x00008670 }, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */
+   { 15918, 0x0000867A }, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */
+   { 15947, 0x0000867B }, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */
+   { 15976, 0x0000867C }, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */
+   { 16005, 0x0000867D }, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */
+   { 16034, 0x0000867E }, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */
+   { 16063, 0x0000867F }, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */
+   { 16092, 0x00008671 }, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */
+   { 16120, 0x00008672 }, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */
+   { 16148, 0x00008673 }, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */
+   { 16176, 0x00008674 }, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */
+   { 16204, 0x00008675 }, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */
+   { 16232, 0x00008676 }, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */
+   { 16260, 0x00008677 }, /* GL_MAP2_VERTEX_ATTRIB7_4_NV */
+   { 16288, 0x00008678 }, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */
+   { 16316, 0x00008679 }, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */
+   { 16344, 0x00000D10 }, /* GL_MAP_COLOR */
+   { 16357, 0x00000010 }, /* GL_MAP_FLUSH_EXPLICIT_BIT */
+   { 16383, 0x00000008 }, /* GL_MAP_INVALIDATE_BUFFER_BIT */
+   { 16412, 0x00000004 }, /* GL_MAP_INVALIDATE_RANGE_BIT */
+   { 16440, 0x00000001 }, /* GL_MAP_READ_BIT */
+   { 16456, 0x00000D11 }, /* GL_MAP_STENCIL */
+   { 16471, 0x00000020 }, /* GL_MAP_UNSYNCHRONIZED_BIT */
+   { 16497, 0x00000002 }, /* GL_MAP_WRITE_BIT */
+   { 16514, 0x000088C0 }, /* GL_MATRIX0_ARB */
+   { 16529, 0x00008630 }, /* GL_MATRIX0_NV */
+   { 16543, 0x000088CA }, /* GL_MATRIX10_ARB */
+   { 16559, 0x000088CB }, /* GL_MATRIX11_ARB */
+   { 16575, 0x000088CC }, /* GL_MATRIX12_ARB */
+   { 16591, 0x000088CD }, /* GL_MATRIX13_ARB */
+   { 16607, 0x000088CE }, /* GL_MATRIX14_ARB */
+   { 16623, 0x000088CF }, /* GL_MATRIX15_ARB */
+   { 16639, 0x000088D0 }, /* GL_MATRIX16_ARB */
+   { 16655, 0x000088D1 }, /* GL_MATRIX17_ARB */
+   { 16671, 0x000088D2 }, /* GL_MATRIX18_ARB */
+   { 16687, 0x000088D3 }, /* GL_MATRIX19_ARB */
+   { 16703, 0x000088C1 }, /* GL_MATRIX1_ARB */
+   { 16718, 0x00008631 }, /* GL_MATRIX1_NV */
+   { 16732, 0x000088D4 }, /* GL_MATRIX20_ARB */
+   { 16748, 0x000088D5 }, /* GL_MATRIX21_ARB */
+   { 16764, 0x000088D6 }, /* GL_MATRIX22_ARB */
+   { 16780, 0x000088D7 }, /* GL_MATRIX23_ARB */
+   { 16796, 0x000088D8 }, /* GL_MATRIX24_ARB */
+   { 16812, 0x000088D9 }, /* GL_MATRIX25_ARB */
+   { 16828, 0x000088DA }, /* GL_MATRIX26_ARB */
+   { 16844, 0x000088DB }, /* GL_MATRIX27_ARB */
+   { 16860, 0x000088DC }, /* GL_MATRIX28_ARB */
+   { 16876, 0x000088DD }, /* GL_MATRIX29_ARB */
+   { 16892, 0x000088C2 }, /* GL_MATRIX2_ARB */
+   { 16907, 0x00008632 }, /* GL_MATRIX2_NV */
+   { 16921, 0x000088DE }, /* GL_MATRIX30_ARB */
+   { 16937, 0x000088DF }, /* GL_MATRIX31_ARB */
+   { 16953, 0x000088C3 }, /* GL_MATRIX3_ARB */
+   { 16968, 0x00008633 }, /* GL_MATRIX3_NV */
+   { 16982, 0x000088C4 }, /* GL_MATRIX4_ARB */
+   { 16997, 0x00008634 }, /* GL_MATRIX4_NV */
+   { 17011, 0x000088C5 }, /* GL_MATRIX5_ARB */
+   { 17026, 0x00008635 }, /* GL_MATRIX5_NV */
+   { 17040, 0x000088C6 }, /* GL_MATRIX6_ARB */
+   { 17055, 0x00008636 }, /* GL_MATRIX6_NV */
+   { 17069, 0x000088C7 }, /* GL_MATRIX7_ARB */
+   { 17084, 0x00008637 }, /* GL_MATRIX7_NV */
+   { 17098, 0x000088C8 }, /* GL_MATRIX8_ARB */
+   { 17113, 0x000088C9 }, /* GL_MATRIX9_ARB */
+   { 17128, 0x00008844 }, /* GL_MATRIX_INDEX_ARRAY_ARB */
+   { 17154, 0x00008849 }, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */
+   { 17188, 0x00008846 }, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */
+   { 17219, 0x00008848 }, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */
+   { 17252, 0x00008847 }, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */
+   { 17283, 0x00000BA0 }, /* GL_MATRIX_MODE */
+   { 17298, 0x00008840 }, /* GL_MATRIX_PALETTE_ARB */
+   { 17320, 0x00008008 }, /* GL_MAX */
+   { 17327, 0x00008073 }, /* GL_MAX_3D_TEXTURE_SIZE */
+   { 17350, 0x000088FF }, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */
+   { 17382, 0x00000D35 }, /* GL_MAX_ATTRIB_STACK_DEPTH */
+   { 17408, 0x00000D3B }, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */
+   { 17441, 0x00008177 }, /* GL_MAX_CLIPMAP_DEPTH_SGIX */
+   { 17467, 0x00008178 }, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */
+   { 17501, 0x00000D32 }, /* GL_MAX_CLIP_PLANES */
+   { 17520, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS_EXT */
+   { 17549, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */
+   { 17581, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI */
+   { 17617, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */
+   { 17653, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB */
+   { 17693, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT */
+   { 17719, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT_EXT */
+   { 17749, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH */
+   { 17774, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH_EXT */
+   { 17803, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */
+   { 17832, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB */
+   { 17865, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS */
+   { 17885, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ARB */
+   { 17909, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ATI */
+   { 17933, 0x000080E9 }, /* GL_MAX_ELEMENTS_INDICES */
+   { 17957, 0x000080E8 }, /* GL_MAX_ELEMENTS_VERTICES */
+   { 17982, 0x00000D30 }, /* GL_MAX_EVAL_ORDER */
+   { 18000, 0x00008008 }, /* GL_MAX_EXT */
+   { 18011, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */
+   { 18046, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB */
+   { 18085, 0x00000D31 }, /* GL_MAX_LIGHTS */
+   { 18099, 0x00000B31 }, /* GL_MAX_LIST_NESTING */
+   { 18119, 0x00008841 }, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */
+   { 18157, 0x00000D36 }, /* GL_MAX_MODELVIEW_STACK_DEPTH */
+   { 18186, 0x00000D37 }, /* GL_MAX_NAME_STACK_DEPTH */
+   { 18210, 0x00008842 }, /* GL_MAX_PALETTE_MATRICES_ARB */
+   { 18238, 0x00000D34 }, /* GL_MAX_PIXEL_MAP_TABLE */
+   { 18261, 0x000088B1 }, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */
+   { 18298, 0x0000880B }, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */
+   { 18334, 0x000088AD }, /* GL_MAX_PROGRAM_ATTRIBS_ARB */
+   { 18361, 0x000088F5 }, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */
+   { 18390, 0x000088B5 }, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */
+   { 18424, 0x000088F4 }, /* GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */
+   { 18460, 0x000088F6 }, /* GL_MAX_PROGRAM_IF_DEPTH_NV */
+   { 18487, 0x000088A1 }, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */
+   { 18519, 0x000088B4 }, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */
+   { 18555, 0x000088F8 }, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */
+   { 18584, 0x000088F7 }, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */
+   { 18613, 0x0000862F }, /* GL_MAX_PROGRAM_MATRICES_ARB */
+   { 18641, 0x0000862E }, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */
+   { 18679, 0x000088B3 }, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
+   { 18723, 0x0000880E }, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
+   { 18766, 0x000088AF }, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */
+   { 18800, 0x000088A3 }, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
+   { 18839, 0x000088AB }, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */
+   { 18876, 0x000088A7 }, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */
+   { 18914, 0x00008810 }, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
+   { 18957, 0x0000880F }, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
+   { 19000, 0x000088A9 }, /* GL_MAX_PROGRAM_PARAMETERS_ARB */
+   { 19030, 0x000088A5 }, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */
+   { 19061, 0x0000880D }, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */
+   { 19097, 0x0000880C }, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */
+   { 19133, 0x00000D38 }, /* GL_MAX_PROJECTION_STACK_DEPTH */
+   { 19163, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */
+   { 19197, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_NV */
+   { 19230, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE_EXT */
+   { 19259, 0x00008D57 }, /* GL_MAX_SAMPLES */
+   { 19274, 0x00008504 }, /* GL_MAX_SHININESS_NV */
+   { 19294, 0x00008505 }, /* GL_MAX_SPOT_EXPONENT_NV */
+   { 19318, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS */
+   { 19340, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS_ARB */
+   { 19366, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS */
+   { 19393, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS_ARB */
+   { 19424, 0x000084FD }, /* GL_MAX_TEXTURE_LOD_BIAS */
+   { 19448, 0x000084FF }, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */
+   { 19482, 0x00000D33 }, /* GL_MAX_TEXTURE_SIZE */
+   { 19502, 0x00000D39 }, /* GL_MAX_TEXTURE_STACK_DEPTH */
+   { 19529, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS */
+   { 19550, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS_ARB */
+   { 19575, 0x0000862F }, /* GL_MAX_TRACK_MATRICES_NV */
+   { 19600, 0x0000862E }, /* GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */
+   { 19635, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS */
+   { 19657, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS_ARB */
+   { 19683, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS */
+   { 19705, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS_ARB */
+   { 19731, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */
+   { 19765, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */
+   { 19803, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */
+   { 19836, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB */
+   { 19873, 0x000086A4 }, /* GL_MAX_VERTEX_UNITS_ARB */
+   { 19897, 0x00000D3A }, /* GL_MAX_VIEWPORT_DIMS */
+   { 19918, 0x00008007 }, /* GL_MIN */
+   { 19925, 0x0000802E }, /* GL_MINMAX */
+   { 19935, 0x0000802E }, /* GL_MINMAX_EXT */
+   { 19949, 0x0000802F }, /* GL_MINMAX_FORMAT */
+   { 19966, 0x0000802F }, /* GL_MINMAX_FORMAT_EXT */
+   { 19987, 0x00008030 }, /* GL_MINMAX_SINK */
+   { 20002, 0x00008030 }, /* GL_MINMAX_SINK_EXT */
+   { 20021, 0x00008007 }, /* GL_MIN_EXT */
+   { 20032, 0x00008370 }, /* GL_MIRRORED_REPEAT */
+   { 20051, 0x00008370 }, /* GL_MIRRORED_REPEAT_ARB */
+   { 20074, 0x00008370 }, /* GL_MIRRORED_REPEAT_IBM */
+   { 20097, 0x00008742 }, /* GL_MIRROR_CLAMP_ATI */
+   { 20117, 0x00008742 }, /* GL_MIRROR_CLAMP_EXT */
+   { 20137, 0x00008912 }, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */
+   { 20167, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_ATI */
+   { 20195, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */
+   { 20223, 0x00001700 }, /* GL_MODELVIEW */
+   { 20236, 0x00001700 }, /* GL_MODELVIEW0_ARB */
+   { 20254, 0x0000872A }, /* GL_MODELVIEW10_ARB */
+   { 20273, 0x0000872B }, /* GL_MODELVIEW11_ARB */
+   { 20292, 0x0000872C }, /* GL_MODELVIEW12_ARB */
+   { 20311, 0x0000872D }, /* GL_MODELVIEW13_ARB */
+   { 20330, 0x0000872E }, /* GL_MODELVIEW14_ARB */
+   { 20349, 0x0000872F }, /* GL_MODELVIEW15_ARB */
+   { 20368, 0x00008730 }, /* GL_MODELVIEW16_ARB */
+   { 20387, 0x00008731 }, /* GL_MODELVIEW17_ARB */
+   { 20406, 0x00008732 }, /* GL_MODELVIEW18_ARB */
+   { 20425, 0x00008733 }, /* GL_MODELVIEW19_ARB */
+   { 20444, 0x0000850A }, /* GL_MODELVIEW1_ARB */
+   { 20462, 0x00008734 }, /* GL_MODELVIEW20_ARB */
+   { 20481, 0x00008735 }, /* GL_MODELVIEW21_ARB */
+   { 20500, 0x00008736 }, /* GL_MODELVIEW22_ARB */
+   { 20519, 0x00008737 }, /* GL_MODELVIEW23_ARB */
+   { 20538, 0x00008738 }, /* GL_MODELVIEW24_ARB */
+   { 20557, 0x00008739 }, /* GL_MODELVIEW25_ARB */
+   { 20576, 0x0000873A }, /* GL_MODELVIEW26_ARB */
+   { 20595, 0x0000873B }, /* GL_MODELVIEW27_ARB */
+   { 20614, 0x0000873C }, /* GL_MODELVIEW28_ARB */
+   { 20633, 0x0000873D }, /* GL_MODELVIEW29_ARB */
+   { 20652, 0x00008722 }, /* GL_MODELVIEW2_ARB */
+   { 20670, 0x0000873E }, /* GL_MODELVIEW30_ARB */
+   { 20689, 0x0000873F }, /* GL_MODELVIEW31_ARB */
+   { 20708, 0x00008723 }, /* GL_MODELVIEW3_ARB */
+   { 20726, 0x00008724 }, /* GL_MODELVIEW4_ARB */
+   { 20744, 0x00008725 }, /* GL_MODELVIEW5_ARB */
+   { 20762, 0x00008726 }, /* GL_MODELVIEW6_ARB */
+   { 20780, 0x00008727 }, /* GL_MODELVIEW7_ARB */
+   { 20798, 0x00008728 }, /* GL_MODELVIEW8_ARB */
+   { 20816, 0x00008729 }, /* GL_MODELVIEW9_ARB */
+   { 20834, 0x00000BA6 }, /* GL_MODELVIEW_MATRIX */
+   { 20854, 0x00008629 }, /* GL_MODELVIEW_PROJECTION_NV */
+   { 20881, 0x00000BA3 }, /* GL_MODELVIEW_STACK_DEPTH */
+   { 20906, 0x00002100 }, /* GL_MODULATE */
+   { 20918, 0x00008744 }, /* GL_MODULATE_ADD_ATI */
+   { 20938, 0x00008745 }, /* GL_MODULATE_SIGNED_ADD_ATI */
+   { 20965, 0x00008746 }, /* GL_MODULATE_SUBTRACT_ATI */
+   { 20990, 0x00000103 }, /* GL_MULT */
+   { 20998, 0x0000809D }, /* GL_MULTISAMPLE */
+   { 21013, 0x000086B2 }, /* GL_MULTISAMPLE_3DFX */
+   { 21033, 0x0000809D }, /* GL_MULTISAMPLE_ARB */
+   { 21052, 0x20000000 }, /* GL_MULTISAMPLE_BIT */
+   { 21071, 0x20000000 }, /* GL_MULTISAMPLE_BIT_3DFX */
+   { 21095, 0x20000000 }, /* GL_MULTISAMPLE_BIT_ARB */
+   { 21118, 0x00008534 }, /* GL_MULTISAMPLE_FILTER_HINT_NV */
+   { 21148, 0x00002A25 }, /* GL_N3F_V3F */
+   { 21159, 0x00000D70 }, /* GL_NAME_STACK_DEPTH */
+   { 21179, 0x0000150E }, /* GL_NAND */
+   { 21187, 0x00002600 }, /* GL_NEAREST */
+   { 21198, 0x0000844E }, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */
+   { 21229, 0x0000844D }, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */
+   { 21261, 0x00002702 }, /* GL_NEAREST_MIPMAP_LINEAR */
+   { 21286, 0x00002700 }, /* GL_NEAREST_MIPMAP_NEAREST */
+   { 21312, 0x00000200 }, /* GL_NEVER */
+   { 21321, 0x00001102 }, /* GL_NICEST */
+   { 21331, 0x00000000 }, /* GL_NONE */
+   { 21339, 0x00001505 }, /* GL_NOOP */
+   { 21347, 0x00001508 }, /* GL_NOR */
+   { 21354, 0x00000BA1 }, /* GL_NORMALIZE */
+   { 21367, 0x00008075 }, /* GL_NORMAL_ARRAY */
+   { 21383, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING */
+   { 21414, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING_ARB */
+   { 21449, 0x0000808F }, /* GL_NORMAL_ARRAY_POINTER */
+   { 21473, 0x0000807F }, /* GL_NORMAL_ARRAY_STRIDE */
+   { 21496, 0x0000807E }, /* GL_NORMAL_ARRAY_TYPE */
+   { 21517, 0x00008511 }, /* GL_NORMAL_MAP */
+   { 21531, 0x00008511 }, /* GL_NORMAL_MAP_ARB */
+   { 21549, 0x00008511 }, /* GL_NORMAL_MAP_NV */
+   { 21566, 0x00000205 }, /* GL_NOTEQUAL */
+   { 21578, 0x00000000 }, /* GL_NO_ERROR */
+   { 21590, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */
+   { 21624, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB */
+   { 21662, 0x00008B89 }, /* GL_OBJECT_ACTIVE_ATTRIBUTES_ARB */
+   { 21694, 0x00008B8A }, /* GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB */
+   { 21736, 0x00008B86 }, /* GL_OBJECT_ACTIVE_UNIFORMS_ARB */
+   { 21766, 0x00008B87 }, /* GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB */
+   { 21806, 0x00008B85 }, /* GL_OBJECT_ATTACHED_OBJECTS_ARB */
+   { 21837, 0x00008B81 }, /* GL_OBJECT_COMPILE_STATUS_ARB */
+   { 21866, 0x00008B80 }, /* GL_OBJECT_DELETE_STATUS_ARB */
+   { 21894, 0x00008B84 }, /* GL_OBJECT_INFO_LOG_LENGTH_ARB */
+   { 21924, 0x00002401 }, /* GL_OBJECT_LINEAR */
+   { 21941, 0x00008B82 }, /* GL_OBJECT_LINK_STATUS_ARB */
+   { 21967, 0x00002501 }, /* GL_OBJECT_PLANE */
+   { 21983, 0x00008B88 }, /* GL_OBJECT_SHADER_SOURCE_LENGTH_ARB */
+   { 22018, 0x00008B4F }, /* GL_OBJECT_SUBTYPE_ARB */
+   { 22040, 0x00008B4E }, /* GL_OBJECT_TYPE_ARB */
+   { 22059, 0x00008B83 }, /* GL_OBJECT_VALIDATE_STATUS_ARB */
+   { 22089, 0x00008165 }, /* GL_OCCLUSION_TEST_HP */
+   { 22110, 0x00008166 }, /* GL_OCCLUSION_TEST_RESULT_HP */
+   { 22138, 0x00000001 }, /* GL_ONE */
+   { 22145, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA */
+   { 22173, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA_EXT */
+   { 22205, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR */
+   { 22233, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR_EXT */
+   { 22265, 0x00000305 }, /* GL_ONE_MINUS_DST_ALPHA */
+   { 22288, 0x00000307 }, /* GL_ONE_MINUS_DST_COLOR */
+   { 22311, 0x00000303 }, /* GL_ONE_MINUS_SRC_ALPHA */
+   { 22334, 0x00000301 }, /* GL_ONE_MINUS_SRC_COLOR */
+   { 22357, 0x00008598 }, /* GL_OPERAND0_ALPHA */
+   { 22375, 0x00008598 }, /* GL_OPERAND0_ALPHA_ARB */
+   { 22397, 0x00008598 }, /* GL_OPERAND0_ALPHA_EXT */
+   { 22419, 0x00008590 }, /* GL_OPERAND0_RGB */
+   { 22435, 0x00008590 }, /* GL_OPERAND0_RGB_ARB */
+   { 22455, 0x00008590 }, /* GL_OPERAND0_RGB_EXT */
+   { 22475, 0x00008599 }, /* GL_OPERAND1_ALPHA */
+   { 22493, 0x00008599 }, /* GL_OPERAND1_ALPHA_ARB */
+   { 22515, 0x00008599 }, /* GL_OPERAND1_ALPHA_EXT */
+   { 22537, 0x00008591 }, /* GL_OPERAND1_RGB */
+   { 22553, 0x00008591 }, /* GL_OPERAND1_RGB_ARB */
+   { 22573, 0x00008591 }, /* GL_OPERAND1_RGB_EXT */
+   { 22593, 0x0000859A }, /* GL_OPERAND2_ALPHA */
+   { 22611, 0x0000859A }, /* GL_OPERAND2_ALPHA_ARB */
+   { 22633, 0x0000859A }, /* GL_OPERAND2_ALPHA_EXT */
+   { 22655, 0x00008592 }, /* GL_OPERAND2_RGB */
+   { 22671, 0x00008592 }, /* GL_OPERAND2_RGB_ARB */
+   { 22691, 0x00008592 }, /* GL_OPERAND2_RGB_EXT */
+   { 22711, 0x0000859B }, /* GL_OPERAND3_ALPHA_NV */
+   { 22732, 0x00008593 }, /* GL_OPERAND3_RGB_NV */
+   { 22751, 0x00001507 }, /* GL_OR */
+   { 22757, 0x00000A01 }, /* GL_ORDER */
+   { 22766, 0x0000150D }, /* GL_OR_INVERTED */
+   { 22781, 0x0000150B }, /* GL_OR_REVERSE */
+   { 22795, 0x00000505 }, /* GL_OUT_OF_MEMORY */
+   { 22812, 0x00000D05 }, /* GL_PACK_ALIGNMENT */
+   { 22830, 0x0000806C }, /* GL_PACK_IMAGE_HEIGHT */
+   { 22851, 0x00008758 }, /* GL_PACK_INVERT_MESA */
+   { 22871, 0x00000D01 }, /* GL_PACK_LSB_FIRST */
+   { 22889, 0x00000D02 }, /* GL_PACK_ROW_LENGTH */
+   { 22908, 0x0000806B }, /* GL_PACK_SKIP_IMAGES */
+   { 22928, 0x00000D04 }, /* GL_PACK_SKIP_PIXELS */
+   { 22948, 0x00000D03 }, /* GL_PACK_SKIP_ROWS */
+   { 22966, 0x00000D00 }, /* GL_PACK_SWAP_BYTES */
+   { 22985, 0x00008B92 }, /* GL_PALETTE4_R5_G6_B5_OES */
+   { 23010, 0x00008B94 }, /* GL_PALETTE4_RGB5_A1_OES */
+   { 23034, 0x00008B90 }, /* GL_PALETTE4_RGB8_OES */
+   { 23055, 0x00008B93 }, /* GL_PALETTE4_RGBA4_OES */
+   { 23077, 0x00008B91 }, /* GL_PALETTE4_RGBA8_OES */
+   { 23099, 0x00008B97 }, /* GL_PALETTE8_R5_G6_B5_OES */
+   { 23124, 0x00008B99 }, /* GL_PALETTE8_RGB5_A1_OES */
+   { 23148, 0x00008B95 }, /* GL_PALETTE8_RGB8_OES */
+   { 23169, 0x00008B98 }, /* GL_PALETTE8_RGBA4_OES */
+   { 23191, 0x00008B96 }, /* GL_PALETTE8_RGBA8_OES */
+   { 23213, 0x00000700 }, /* GL_PASS_THROUGH_TOKEN */
+   { 23235, 0x00000C50 }, /* GL_PERSPECTIVE_CORRECTION_HINT */
+   { 23266, 0x00000C79 }, /* GL_PIXEL_MAP_A_TO_A */
+   { 23286, 0x00000CB9 }, /* GL_PIXEL_MAP_A_TO_A_SIZE */
+   { 23311, 0x00000C78 }, /* GL_PIXEL_MAP_B_TO_B */
+   { 23331, 0x00000CB8 }, /* GL_PIXEL_MAP_B_TO_B_SIZE */
+   { 23356, 0x00000C77 }, /* GL_PIXEL_MAP_G_TO_G */
+   { 23376, 0x00000CB7 }, /* GL_PIXEL_MAP_G_TO_G_SIZE */
+   { 23401, 0x00000C75 }, /* GL_PIXEL_MAP_I_TO_A */
+   { 23421, 0x00000CB5 }, /* GL_PIXEL_MAP_I_TO_A_SIZE */
+   { 23446, 0x00000C74 }, /* GL_PIXEL_MAP_I_TO_B */
+   { 23466, 0x00000CB4 }, /* GL_PIXEL_MAP_I_TO_B_SIZE */
+   { 23491, 0x00000C73 }, /* GL_PIXEL_MAP_I_TO_G */
+   { 23511, 0x00000CB3 }, /* GL_PIXEL_MAP_I_TO_G_SIZE */
+   { 23536, 0x00000C70 }, /* GL_PIXEL_MAP_I_TO_I */
+   { 23556, 0x00000CB0 }, /* GL_PIXEL_MAP_I_TO_I_SIZE */
+   { 23581, 0x00000C72 }, /* GL_PIXEL_MAP_I_TO_R */
+   { 23601, 0x00000CB2 }, /* GL_PIXEL_MAP_I_TO_R_SIZE */
+   { 23626, 0x00000C76 }, /* GL_PIXEL_MAP_R_TO_R */
+   { 23646, 0x00000CB6 }, /* GL_PIXEL_MAP_R_TO_R_SIZE */
+   { 23671, 0x00000C71 }, /* GL_PIXEL_MAP_S_TO_S */
+   { 23691, 0x00000CB1 }, /* GL_PIXEL_MAP_S_TO_S_SIZE */
+   { 23716, 0x00000020 }, /* GL_PIXEL_MODE_BIT */
+   { 23734, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER */
+   { 23755, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING */
+   { 23784, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING_EXT */
+   { 23817, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER_EXT */
+   { 23842, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER */
+   { 23865, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING */
+   { 23896, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING_EXT */
+   { 23931, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER_EXT */
+   { 23958, 0x00001B00 }, /* GL_POINT */
+   { 23967, 0x00000000 }, /* GL_POINTS */
+   { 23977, 0x00000002 }, /* GL_POINT_BIT */
+   { 23990, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION */
+   { 24020, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_ARB */
+   { 24054, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_EXT */
+   { 24088, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_SGIS */
+   { 24123, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE */
+   { 24152, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_ARB */
+   { 24185, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_EXT */
+   { 24218, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_SGIS */
+   { 24252, 0x00000B11 }, /* GL_POINT_SIZE */
+   { 24266, 0x00000B13 }, /* GL_POINT_SIZE_GRANULARITY */
+   { 24292, 0x00008127 }, /* GL_POINT_SIZE_MAX */
+   { 24310, 0x00008127 }, /* GL_POINT_SIZE_MAX_ARB */
+   { 24332, 0x00008127 }, /* GL_POINT_SIZE_MAX_EXT */
+   { 24354, 0x00008127 }, /* GL_POINT_SIZE_MAX_SGIS */
+   { 24377, 0x00008126 }, /* GL_POINT_SIZE_MIN */
+   { 24395, 0x00008126 }, /* GL_POINT_SIZE_MIN_ARB */
+   { 24417, 0x00008126 }, /* GL_POINT_SIZE_MIN_EXT */
+   { 24439, 0x00008126 }, /* GL_POINT_SIZE_MIN_SGIS */
+   { 24462, 0x00000B12 }, /* GL_POINT_SIZE_RANGE */
+   { 24482, 0x00000B10 }, /* GL_POINT_SMOOTH */
+   { 24498, 0x00000C51 }, /* GL_POINT_SMOOTH_HINT */
+   { 24519, 0x00008861 }, /* GL_POINT_SPRITE */
+   { 24535, 0x00008861 }, /* GL_POINT_SPRITE_ARB */
+   { 24555, 0x00008CA0 }, /* GL_POINT_SPRITE_COORD_ORIGIN */
+   { 24584, 0x00008861 }, /* GL_POINT_SPRITE_NV */
+   { 24603, 0x00008863 }, /* GL_POINT_SPRITE_R_MODE_NV */
+   { 24629, 0x00000701 }, /* GL_POINT_TOKEN */
+   { 24644, 0x00000009 }, /* GL_POLYGON */
+   { 24655, 0x00000008 }, /* GL_POLYGON_BIT */
+   { 24670, 0x00000B40 }, /* GL_POLYGON_MODE */
+   { 24686, 0x00008039 }, /* GL_POLYGON_OFFSET_BIAS */
+   { 24709, 0x00008038 }, /* GL_POLYGON_OFFSET_FACTOR */
+   { 24734, 0x00008037 }, /* GL_POLYGON_OFFSET_FILL */
+   { 24757, 0x00002A02 }, /* GL_POLYGON_OFFSET_LINE */
+   { 24780, 0x00002A01 }, /* GL_POLYGON_OFFSET_POINT */
+   { 24804, 0x00002A00 }, /* GL_POLYGON_OFFSET_UNITS */
+   { 24828, 0x00000B41 }, /* GL_POLYGON_SMOOTH */
+   { 24846, 0x00000C53 }, /* GL_POLYGON_SMOOTH_HINT */
+   { 24869, 0x00000B42 }, /* GL_POLYGON_STIPPLE */
+   { 24888, 0x00000010 }, /* GL_POLYGON_STIPPLE_BIT */
+   { 24911, 0x00000703 }, /* GL_POLYGON_TOKEN */
+   { 24928, 0x00001203 }, /* GL_POSITION */
+   { 24940, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */
+   { 24972, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI */
+   { 25008, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */
+   { 25041, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI */
+   { 25078, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */
+   { 25109, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI */
+   { 25144, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */
+   { 25176, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI */
+   { 25212, 0x000080D2 }, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */
+   { 25245, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */
+   { 25277, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI */
+   { 25313, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */
+   { 25346, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI */
+   { 25383, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS */
+   { 25413, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS_SGI */
+   { 25447, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE */
+   { 25478, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE_SGI */
+   { 25513, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS */
+   { 25544, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS_EXT */
+   { 25579, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE */
+   { 25611, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE_EXT */
+   { 25647, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS */
+   { 25677, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS_EXT */
+   { 25711, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE */
+   { 25742, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE_EXT */
+   { 25777, 0x000080D1 }, /* GL_POST_CONVOLUTION_COLOR_TABLE */
+   { 25809, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS */
+   { 25840, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS_EXT */
+   { 25875, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE */
+   { 25907, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE_EXT */
+   { 25943, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS */
+   { 25972, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS_EXT */
+   { 26005, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE */
+   { 26035, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE_EXT */
+   { 26069, 0x0000817B }, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */
+   { 26108, 0x00008179 }, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */
+   { 26141, 0x0000817C }, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */
+   { 26181, 0x0000817A }, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */
+   { 26215, 0x00008578 }, /* GL_PREVIOUS */
+   { 26227, 0x00008578 }, /* GL_PREVIOUS_ARB */
+   { 26243, 0x00008578 }, /* GL_PREVIOUS_EXT */
+   { 26259, 0x00008577 }, /* GL_PRIMARY_COLOR */
+   { 26276, 0x00008577 }, /* GL_PRIMARY_COLOR_ARB */
+   { 26297, 0x00008577 }, /* GL_PRIMARY_COLOR_EXT */
+   { 26318, 0x000088B0 }, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */
+   { 26351, 0x00008805 }, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */
+   { 26383, 0x000088AC }, /* GL_PROGRAM_ATTRIBS_ARB */
+   { 26406, 0x00008677 }, /* GL_PROGRAM_BINDING_ARB */
+   { 26429, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_ARB */
+   { 26459, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_NV */
+   { 26488, 0x00008874 }, /* GL_PROGRAM_ERROR_STRING_ARB */
+   { 26516, 0x00008876 }, /* GL_PROGRAM_FORMAT_ARB */
+   { 26538, 0x00008875 }, /* GL_PROGRAM_FORMAT_ASCII_ARB */
+   { 26566, 0x000088A0 }, /* GL_PROGRAM_INSTRUCTIONS_ARB */
+   { 26594, 0x00008627 }, /* GL_PROGRAM_LENGTH_ARB */
+   { 26616, 0x00008627 }, /* GL_PROGRAM_LENGTH_NV */
+   { 26637, 0x000088B2 }, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
+   { 26677, 0x00008808 }, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
+   { 26716, 0x000088AE }, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */
+   { 26746, 0x000088A2 }, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
+   { 26781, 0x000088AA }, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */
+   { 26814, 0x000088A6 }, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */
+   { 26848, 0x0000880A }, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
+   { 26887, 0x00008809 }, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
+   { 26926, 0x00008B40 }, /* GL_PROGRAM_OBJECT_ARB */
+   { 26948, 0x000088A8 }, /* GL_PROGRAM_PARAMETERS_ARB */
+   { 26974, 0x00008644 }, /* GL_PROGRAM_PARAMETER_NV */
+   { 26998, 0x00008647 }, /* GL_PROGRAM_RESIDENT_NV */
+   { 27021, 0x00008628 }, /* GL_PROGRAM_STRING_ARB */
+   { 27043, 0x00008628 }, /* GL_PROGRAM_STRING_NV */
+   { 27064, 0x00008646 }, /* GL_PROGRAM_TARGET_NV */
+   { 27085, 0x000088A4 }, /* GL_PROGRAM_TEMPORARIES_ARB */
+   { 27112, 0x00008807 }, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */
+   { 27144, 0x00008806 }, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */
+   { 27176, 0x000088B6 }, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */
+   { 27211, 0x00001701 }, /* GL_PROJECTION */
+   { 27225, 0x00000BA7 }, /* GL_PROJECTION_MATRIX */
+   { 27246, 0x00000BA4 }, /* GL_PROJECTION_STACK_DEPTH */
+   { 27272, 0x000080D3 }, /* GL_PROXY_COLOR_TABLE */
+   { 27293, 0x00008025 }, /* GL_PROXY_HISTOGRAM */
+   { 27312, 0x00008025 }, /* GL_PROXY_HISTOGRAM_EXT */
+   { 27335, 0x000080D5 }, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */
+   { 27374, 0x000080D4 }, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */
+   { 27412, 0x00008063 }, /* GL_PROXY_TEXTURE_1D */
+   { 27432, 0x00008C19 }, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */
+   { 27462, 0x00008063 }, /* GL_PROXY_TEXTURE_1D_EXT */
+   { 27486, 0x00008064 }, /* GL_PROXY_TEXTURE_2D */
+   { 27506, 0x00008C1B }, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */
+   { 27536, 0x00008064 }, /* GL_PROXY_TEXTURE_2D_EXT */
+   { 27560, 0x00008070 }, /* GL_PROXY_TEXTURE_3D */
+   { 27580, 0x000080BD }, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */
+   { 27613, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP */
+   { 27639, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP_ARB */
+   { 27669, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */
+   { 27700, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_NV */
+   { 27730, 0x00002003 }, /* GL_Q */
+   { 27735, 0x00001209 }, /* GL_QUADRATIC_ATTENUATION */
+   { 27760, 0x00000007 }, /* GL_QUADS */
+   { 27769, 0x00008614 }, /* GL_QUAD_MESH_SUN */
+   { 27786, 0x00000008 }, /* GL_QUAD_STRIP */
+   { 27800, 0x00008864 }, /* GL_QUERY_COUNTER_BITS */
+   { 27822, 0x00008864 }, /* GL_QUERY_COUNTER_BITS_ARB */
+   { 27848, 0x00008866 }, /* GL_QUERY_RESULT */
+   { 27864, 0x00008866 }, /* GL_QUERY_RESULT_ARB */
+   { 27884, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE */
+   { 27910, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE_ARB */
+   { 27940, 0x00002002 }, /* GL_R */
+   { 27945, 0x00002A10 }, /* GL_R3_G3_B2 */
+   { 27957, 0x00019262 }, /* GL_RASTER_POSITION_UNCLIPPED_IBM */
+   { 27990, 0x00000C02 }, /* GL_READ_BUFFER */
+   { 28005, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER */
+   { 28025, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING_EXT */
+   { 28057, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER_EXT */
+   { 28081, 0x000088B8 }, /* GL_READ_ONLY */
+   { 28094, 0x000088B8 }, /* GL_READ_ONLY_ARB */
+   { 28111, 0x000088BA }, /* GL_READ_WRITE */
+   { 28125, 0x000088BA }, /* GL_READ_WRITE_ARB */
+   { 28143, 0x00001903 }, /* GL_RED */
+   { 28150, 0x00008016 }, /* GL_REDUCE */
+   { 28160, 0x00008016 }, /* GL_REDUCE_EXT */
+   { 28174, 0x00000D15 }, /* GL_RED_BIAS */
+   { 28186, 0x00000D52 }, /* GL_RED_BITS */
+   { 28198, 0x00000D14 }, /* GL_RED_SCALE */
+   { 28211, 0x00008512 }, /* GL_REFLECTION_MAP */
+   { 28229, 0x00008512 }, /* GL_REFLECTION_MAP_ARB */
+   { 28251, 0x00008512 }, /* GL_REFLECTION_MAP_NV */
+   { 28272, 0x00001C00 }, /* GL_RENDER */
+   { 28282, 0x00008D41 }, /* GL_RENDERBUFFER */
+   { 28298, 0x00008D53 }, /* GL_RENDERBUFFER_ALPHA_SIZE */
+   { 28325, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING_EXT */
+   { 28353, 0x00008D52 }, /* GL_RENDERBUFFER_BLUE_SIZE */
+   { 28379, 0x00008D54 }, /* GL_RENDERBUFFER_DEPTH_SIZE */
+   { 28406, 0x00008D41 }, /* GL_RENDERBUFFER_EXT */
+   { 28426, 0x00008D51 }, /* GL_RENDERBUFFER_GREEN_SIZE */
+   { 28453, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT */
+   { 28476, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT_EXT */
+   { 28503, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT */
+   { 28535, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT_EXT */
+   { 28571, 0x00008D50 }, /* GL_RENDERBUFFER_RED_SIZE */
+   { 28596, 0x00008CAB }, /* GL_RENDERBUFFER_SAMPLES */
+   { 28620, 0x00008D55 }, /* GL_RENDERBUFFER_STENCIL_SIZE */
+   { 28649, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH */
+   { 28671, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH_EXT */
+   { 28697, 0x00001F01 }, /* GL_RENDERER */
+   { 28709, 0x00000C40 }, /* GL_RENDER_MODE */
+   { 28724, 0x00002901 }, /* GL_REPEAT */
+   { 28734, 0x00001E01 }, /* GL_REPLACE */
+   { 28745, 0x00008062 }, /* GL_REPLACE_EXT */
+   { 28760, 0x00008153 }, /* GL_REPLICATE_BORDER_HP */
+   { 28783, 0x0000803A }, /* GL_RESCALE_NORMAL */
+   { 28801, 0x0000803A }, /* GL_RESCALE_NORMAL_EXT */
+   { 28823, 0x00000102 }, /* GL_RETURN */
+   { 28833, 0x00001907 }, /* GL_RGB */
+   { 28840, 0x00008052 }, /* GL_RGB10 */
+   { 28849, 0x00008059 }, /* GL_RGB10_A2 */
+   { 28861, 0x00008059 }, /* GL_RGB10_A2_EXT */
+   { 28877, 0x00008052 }, /* GL_RGB10_EXT */
+   { 28890, 0x00008053 }, /* GL_RGB12 */
+   { 28899, 0x00008053 }, /* GL_RGB12_EXT */
+   { 28912, 0x00008054 }, /* GL_RGB16 */
+   { 28921, 0x00008054 }, /* GL_RGB16_EXT */
+   { 28934, 0x0000804E }, /* GL_RGB2_EXT */
+   { 28946, 0x0000804F }, /* GL_RGB4 */
+   { 28954, 0x0000804F }, /* GL_RGB4_EXT */
+   { 28966, 0x000083A1 }, /* GL_RGB4_S3TC */
+   { 28979, 0x00008050 }, /* GL_RGB5 */
+   { 28987, 0x00008057 }, /* GL_RGB5_A1 */
+   { 28998, 0x00008057 }, /* GL_RGB5_A1_EXT */
+   { 29013, 0x00008050 }, /* GL_RGB5_EXT */
+   { 29025, 0x00008051 }, /* GL_RGB8 */
+   { 29033, 0x00008051 }, /* GL_RGB8_EXT */
+   { 29045, 0x00001908 }, /* GL_RGBA */
+   { 29053, 0x0000805A }, /* GL_RGBA12 */
+   { 29063, 0x0000805A }, /* GL_RGBA12_EXT */
+   { 29077, 0x0000805B }, /* GL_RGBA16 */
+   { 29087, 0x0000805B }, /* GL_RGBA16_EXT */
+   { 29101, 0x00008055 }, /* GL_RGBA2 */
+   { 29110, 0x00008055 }, /* GL_RGBA2_EXT */
+   { 29123, 0x00008056 }, /* GL_RGBA4 */
+   { 29132, 0x000083A5 }, /* GL_RGBA4_DXT5_S3TC */
+   { 29151, 0x00008056 }, /* GL_RGBA4_EXT */
+   { 29164, 0x000083A3 }, /* GL_RGBA4_S3TC */
+   { 29178, 0x00008058 }, /* GL_RGBA8 */
+   { 29187, 0x00008058 }, /* GL_RGBA8_EXT */
+   { 29200, 0x00008F97 }, /* GL_RGBA8_SNORM */
+   { 29215, 0x000083A4 }, /* GL_RGBA_DXT5_S3TC */
+   { 29233, 0x00000C31 }, /* GL_RGBA_MODE */
+   { 29246, 0x000083A2 }, /* GL_RGBA_S3TC */
+   { 29259, 0x00008F93 }, /* GL_RGBA_SNORM */
+   { 29273, 0x000083A0 }, /* GL_RGB_S3TC */
+   { 29285, 0x00008573 }, /* GL_RGB_SCALE */
+   { 29298, 0x00008573 }, /* GL_RGB_SCALE_ARB */
+   { 29315, 0x00008573 }, /* GL_RGB_SCALE_EXT */
+   { 29332, 0x00000407 }, /* GL_RIGHT */
+   { 29341, 0x00002000 }, /* GL_S */
+   { 29346, 0x00008B5D }, /* GL_SAMPLER_1D */
+   { 29360, 0x00008B61 }, /* GL_SAMPLER_1D_SHADOW */
+   { 29381, 0x00008B5E }, /* GL_SAMPLER_2D */
+   { 29395, 0x00008B62 }, /* GL_SAMPLER_2D_SHADOW */
+   { 29416, 0x00008B5F }, /* GL_SAMPLER_3D */
+   { 29430, 0x00008B60 }, /* GL_SAMPLER_CUBE */
+   { 29446, 0x000080A9 }, /* GL_SAMPLES */
+   { 29457, 0x000086B4 }, /* GL_SAMPLES_3DFX */
+   { 29473, 0x000080A9 }, /* GL_SAMPLES_ARB */
+   { 29488, 0x00008914 }, /* GL_SAMPLES_PASSED */
+   { 29506, 0x00008914 }, /* GL_SAMPLES_PASSED_ARB */
+   { 29528, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE */
+   { 29556, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE_ARB */
+   { 29588, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE */
+   { 29611, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE_ARB */
+   { 29638, 0x000080A8 }, /* GL_SAMPLE_BUFFERS */
+   { 29656, 0x000086B3 }, /* GL_SAMPLE_BUFFERS_3DFX */
+   { 29679, 0x000080A8 }, /* GL_SAMPLE_BUFFERS_ARB */
+   { 29701, 0x000080A0 }, /* GL_SAMPLE_COVERAGE */
+   { 29720, 0x000080A0 }, /* GL_SAMPLE_COVERAGE_ARB */
+   { 29743, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT */
+   { 29769, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT_ARB */
+   { 29799, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE */
+   { 29824, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE_ARB */
+   { 29853, 0x00080000 }, /* GL_SCISSOR_BIT */
+   { 29868, 0x00000C10 }, /* GL_SCISSOR_BOX */
+   { 29883, 0x00000C11 }, /* GL_SCISSOR_TEST */
+   { 29899, 0x0000845E }, /* GL_SECONDARY_COLOR_ARRAY */
+   { 29924, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */
+   { 29964, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB */
+   { 30008, 0x0000845D }, /* GL_SECONDARY_COLOR_ARRAY_POINTER */
+   { 30041, 0x0000845A }, /* GL_SECONDARY_COLOR_ARRAY_SIZE */
+   { 30071, 0x0000845C }, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */
+   { 30103, 0x0000845B }, /* GL_SECONDARY_COLOR_ARRAY_TYPE */
+   { 30133, 0x00001C02 }, /* GL_SELECT */
+   { 30143, 0x00000DF3 }, /* GL_SELECTION_BUFFER_POINTER */
+   { 30171, 0x00000DF4 }, /* GL_SELECTION_BUFFER_SIZE */
+   { 30196, 0x00008012 }, /* GL_SEPARABLE_2D */
+   { 30212, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR */
+   { 30239, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR_EXT */
+   { 30270, 0x0000150F }, /* GL_SET */
+   { 30277, 0x00008B48 }, /* GL_SHADER_OBJECT_ARB */
+   { 30298, 0x00008B88 }, /* GL_SHADER_SOURCE_LENGTH */
+   { 30322, 0x00008B4F }, /* GL_SHADER_TYPE */
+   { 30337, 0x00000B54 }, /* GL_SHADE_MODEL */
+   { 30352, 0x00008B8C }, /* GL_SHADING_LANGUAGE_VERSION */
+   { 30380, 0x000080BF }, /* GL_SHADOW_AMBIENT_SGIX */
+   { 30403, 0x000081FB }, /* GL_SHARED_TEXTURE_PALETTE_EXT */
+   { 30433, 0x00001601 }, /* GL_SHININESS */
+   { 30446, 0x00001402 }, /* GL_SHORT */
+   { 30455, 0x00008F9C }, /* GL_SIGNED_NORMALIZED */
+   { 30476, 0x000081F9 }, /* GL_SINGLE_COLOR */
+   { 30492, 0x000081F9 }, /* GL_SINGLE_COLOR_EXT */
+   { 30512, 0x000085CC }, /* GL_SLICE_ACCUM_SUN */
+   { 30531, 0x00008C46 }, /* GL_SLUMINANCE */
+   { 30545, 0x00008C47 }, /* GL_SLUMINANCE8 */
+   { 30560, 0x00008C45 }, /* GL_SLUMINANCE8_ALPHA8 */
+   { 30582, 0x00008C44 }, /* GL_SLUMINANCE_ALPHA */
+   { 30602, 0x00001D01 }, /* GL_SMOOTH */
+   { 30612, 0x00000B23 }, /* GL_SMOOTH_LINE_WIDTH_GRANULARITY */
+   { 30645, 0x00000B22 }, /* GL_SMOOTH_LINE_WIDTH_RANGE */
+   { 30672, 0x00000B13 }, /* GL_SMOOTH_POINT_SIZE_GRANULARITY */
+   { 30705, 0x00000B12 }, /* GL_SMOOTH_POINT_SIZE_RANGE */
+   { 30732, 0x00008588 }, /* GL_SOURCE0_ALPHA */
+   { 30749, 0x00008588 }, /* GL_SOURCE0_ALPHA_ARB */
+   { 30770, 0x00008588 }, /* GL_SOURCE0_ALPHA_EXT */
+   { 30791, 0x00008580 }, /* GL_SOURCE0_RGB */
+   { 30806, 0x00008580 }, /* GL_SOURCE0_RGB_ARB */
+   { 30825, 0x00008580 }, /* GL_SOURCE0_RGB_EXT */
+   { 30844, 0x00008589 }, /* GL_SOURCE1_ALPHA */
+   { 30861, 0x00008589 }, /* GL_SOURCE1_ALPHA_ARB */
+   { 30882, 0x00008589 }, /* GL_SOURCE1_ALPHA_EXT */
+   { 30903, 0x00008581 }, /* GL_SOURCE1_RGB */
+   { 30918, 0x00008581 }, /* GL_SOURCE1_RGB_ARB */
+   { 30937, 0x00008581 }, /* GL_SOURCE1_RGB_EXT */
+   { 30956, 0x0000858A }, /* GL_SOURCE2_ALPHA */
+   { 30973, 0x0000858A }, /* GL_SOURCE2_ALPHA_ARB */
+   { 30994, 0x0000858A }, /* GL_SOURCE2_ALPHA_EXT */
+   { 31015, 0x00008582 }, /* GL_SOURCE2_RGB */
+   { 31030, 0x00008582 }, /* GL_SOURCE2_RGB_ARB */
+   { 31049, 0x00008582 }, /* GL_SOURCE2_RGB_EXT */
+   { 31068, 0x0000858B }, /* GL_SOURCE3_ALPHA_NV */
+   { 31088, 0x00008583 }, /* GL_SOURCE3_RGB_NV */
+   { 31106, 0x00001202 }, /* GL_SPECULAR */
+   { 31118, 0x00002402 }, /* GL_SPHERE_MAP */
+   { 31132, 0x00001206 }, /* GL_SPOT_CUTOFF */
+   { 31147, 0x00001204 }, /* GL_SPOT_DIRECTION */
+   { 31165, 0x00001205 }, /* GL_SPOT_EXPONENT */
+   { 31182, 0x00008588 }, /* GL_SRC0_ALPHA */
+   { 31196, 0x00008580 }, /* GL_SRC0_RGB */
+   { 31208, 0x00008589 }, /* GL_SRC1_ALPHA */
+   { 31222, 0x00008581 }, /* GL_SRC1_RGB */
+   { 31234, 0x0000858A }, /* GL_SRC2_ALPHA */
+   { 31248, 0x00008582 }, /* GL_SRC2_RGB */
+   { 31260, 0x00000302 }, /* GL_SRC_ALPHA */
+   { 31273, 0x00000308 }, /* GL_SRC_ALPHA_SATURATE */
+   { 31295, 0x00000300 }, /* GL_SRC_COLOR */
+   { 31308, 0x00008C40 }, /* GL_SRGB */
+   { 31316, 0x00008C41 }, /* GL_SRGB8 */
+   { 31325, 0x00008C43 }, /* GL_SRGB8_ALPHA8 */
+   { 31341, 0x00008C42 }, /* GL_SRGB_ALPHA */
+   { 31355, 0x00000503 }, /* GL_STACK_OVERFLOW */
+   { 31373, 0x00000504 }, /* GL_STACK_UNDERFLOW */
+   { 31392, 0x000088E6 }, /* GL_STATIC_COPY */
+   { 31407, 0x000088E6 }, /* GL_STATIC_COPY_ARB */
+   { 31426, 0x000088E4 }, /* GL_STATIC_DRAW */
+   { 31441, 0x000088E4 }, /* GL_STATIC_DRAW_ARB */
+   { 31460, 0x000088E5 }, /* GL_STATIC_READ */
+   { 31475, 0x000088E5 }, /* GL_STATIC_READ_ARB */
+   { 31494, 0x00001802 }, /* GL_STENCIL */
+   { 31505, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT */
+   { 31527, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT_EXT */
+   { 31553, 0x00008801 }, /* GL_STENCIL_BACK_FAIL */
+   { 31574, 0x00008801 }, /* GL_STENCIL_BACK_FAIL_ATI */
+   { 31599, 0x00008800 }, /* GL_STENCIL_BACK_FUNC */
+   { 31620, 0x00008800 }, /* GL_STENCIL_BACK_FUNC_ATI */
+   { 31645, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */
+   { 31677, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI */
+   { 31713, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */
+   { 31745, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI */
+   { 31781, 0x00008CA3 }, /* GL_STENCIL_BACK_REF */
+   { 31801, 0x00008CA4 }, /* GL_STENCIL_BACK_VALUE_MASK */
+   { 31828, 0x00008CA5 }, /* GL_STENCIL_BACK_WRITEMASK */
+   { 31854, 0x00000D57 }, /* GL_STENCIL_BITS */
+   { 31870, 0x00000400 }, /* GL_STENCIL_BUFFER_BIT */
+   { 31892, 0x00000B91 }, /* GL_STENCIL_CLEAR_VALUE */
+   { 31915, 0x00000B94 }, /* GL_STENCIL_FAIL */
+   { 31931, 0x00000B92 }, /* GL_STENCIL_FUNC */
+   { 31947, 0x00001901 }, /* GL_STENCIL_INDEX */
+   { 31964, 0x00008D49 }, /* GL_STENCIL_INDEX16_EXT */
+   { 31987, 0x00008D46 }, /* GL_STENCIL_INDEX1_EXT */
+   { 32009, 0x00008D47 }, /* GL_STENCIL_INDEX4_EXT */
+   { 32031, 0x00008D48 }, /* GL_STENCIL_INDEX8_EXT */
+   { 32053, 0x00008D45 }, /* GL_STENCIL_INDEX_EXT */
+   { 32074, 0x00000B95 }, /* GL_STENCIL_PASS_DEPTH_FAIL */
+   { 32101, 0x00000B96 }, /* GL_STENCIL_PASS_DEPTH_PASS */
+   { 32128, 0x00000B97 }, /* GL_STENCIL_REF */
+   { 32143, 0x00000B90 }, /* GL_STENCIL_TEST */
+   { 32159, 0x00008910 }, /* GL_STENCIL_TEST_TWO_SIDE_EXT */
+   { 32188, 0x00000B93 }, /* GL_STENCIL_VALUE_MASK */
+   { 32210, 0x00000B98 }, /* GL_STENCIL_WRITEMASK */
+   { 32231, 0x00000C33 }, /* GL_STEREO */
+   { 32241, 0x000088E2 }, /* GL_STREAM_COPY */
+   { 32256, 0x000088E2 }, /* GL_STREAM_COPY_ARB */
+   { 32275, 0x000088E0 }, /* GL_STREAM_DRAW */
+   { 32290, 0x000088E0 }, /* GL_STREAM_DRAW_ARB */
+   { 32309, 0x000088E1 }, /* GL_STREAM_READ */
+   { 32324, 0x000088E1 }, /* GL_STREAM_READ_ARB */
+   { 32343, 0x00000D50 }, /* GL_SUBPIXEL_BITS */
+   { 32360, 0x000084E7 }, /* GL_SUBTRACT */
+   { 32372, 0x000084E7 }, /* GL_SUBTRACT_ARB */
+   { 32388, 0x00002001 }, /* GL_T */
+   { 32393, 0x00002A2A }, /* GL_T2F_C3F_V3F */
+   { 32408, 0x00002A2C }, /* GL_T2F_C4F_N3F_V3F */
+   { 32427, 0x00002A29 }, /* GL_T2F_C4UB_V3F */
+   { 32443, 0x00002A2B }, /* GL_T2F_N3F_V3F */
+   { 32458, 0x00002A27 }, /* GL_T2F_V3F */
+   { 32469, 0x00002A2D }, /* GL_T4F_C4F_N3F_V4F */
+   { 32488, 0x00002A28 }, /* GL_T4F_V4F */
+   { 32499, 0x00008031 }, /* GL_TABLE_TOO_LARGE_EXT */
+   { 32522, 0x00001702 }, /* GL_TEXTURE */
+   { 32533, 0x000084C0 }, /* GL_TEXTURE0 */
+   { 32545, 0x000084C0 }, /* GL_TEXTURE0_ARB */
+   { 32561, 0x000084C1 }, /* GL_TEXTURE1 */
+   { 32573, 0x000084CA }, /* GL_TEXTURE10 */
+   { 32586, 0x000084CA }, /* GL_TEXTURE10_ARB */
+   { 32603, 0x000084CB }, /* GL_TEXTURE11 */
+   { 32616, 0x000084CB }, /* GL_TEXTURE11_ARB */
+   { 32633, 0x000084CC }, /* GL_TEXTURE12 */
+   { 32646, 0x000084CC }, /* GL_TEXTURE12_ARB */
+   { 32663, 0x000084CD }, /* GL_TEXTURE13 */
+   { 32676, 0x000084CD }, /* GL_TEXTURE13_ARB */
+   { 32693, 0x000084CE }, /* GL_TEXTURE14 */
+   { 32706, 0x000084CE }, /* GL_TEXTURE14_ARB */
+   { 32723, 0x000084CF }, /* GL_TEXTURE15 */
+   { 32736, 0x000084CF }, /* GL_TEXTURE15_ARB */
+   { 32753, 0x000084D0 }, /* GL_TEXTURE16 */
+   { 32766, 0x000084D0 }, /* GL_TEXTURE16_ARB */
+   { 32783, 0x000084D1 }, /* GL_TEXTURE17 */
+   { 32796, 0x000084D1 }, /* GL_TEXTURE17_ARB */
+   { 32813, 0x000084D2 }, /* GL_TEXTURE18 */
+   { 32826, 0x000084D2 }, /* GL_TEXTURE18_ARB */
+   { 32843, 0x000084D3 }, /* GL_TEXTURE19 */
+   { 32856, 0x000084D3 }, /* GL_TEXTURE19_ARB */
+   { 32873, 0x000084C1 }, /* GL_TEXTURE1_ARB */
+   { 32889, 0x000084C2 }, /* GL_TEXTURE2 */
+   { 32901, 0x000084D4 }, /* GL_TEXTURE20 */
+   { 32914, 0x000084D4 }, /* GL_TEXTURE20_ARB */
+   { 32931, 0x000084D5 }, /* GL_TEXTURE21 */
+   { 32944, 0x000084D5 }, /* GL_TEXTURE21_ARB */
+   { 32961, 0x000084D6 }, /* GL_TEXTURE22 */
+   { 32974, 0x000084D6 }, /* GL_TEXTURE22_ARB */
+   { 32991, 0x000084D7 }, /* GL_TEXTURE23 */
+   { 33004, 0x000084D7 }, /* GL_TEXTURE23_ARB */
+   { 33021, 0x000084D8 }, /* GL_TEXTURE24 */
+   { 33034, 0x000084D8 }, /* GL_TEXTURE24_ARB */
+   { 33051, 0x000084D9 }, /* GL_TEXTURE25 */
+   { 33064, 0x000084D9 }, /* GL_TEXTURE25_ARB */
+   { 33081, 0x000084DA }, /* GL_TEXTURE26 */
+   { 33094, 0x000084DA }, /* GL_TEXTURE26_ARB */
+   { 33111, 0x000084DB }, /* GL_TEXTURE27 */
+   { 33124, 0x000084DB }, /* GL_TEXTURE27_ARB */
+   { 33141, 0x000084DC }, /* GL_TEXTURE28 */
+   { 33154, 0x000084DC }, /* GL_TEXTURE28_ARB */
+   { 33171, 0x000084DD }, /* GL_TEXTURE29 */
+   { 33184, 0x000084DD }, /* GL_TEXTURE29_ARB */
+   { 33201, 0x000084C2 }, /* GL_TEXTURE2_ARB */
+   { 33217, 0x000084C3 }, /* GL_TEXTURE3 */
+   { 33229, 0x000084DE }, /* GL_TEXTURE30 */
+   { 33242, 0x000084DE }, /* GL_TEXTURE30_ARB */
+   { 33259, 0x000084DF }, /* GL_TEXTURE31 */
+   { 33272, 0x000084DF }, /* GL_TEXTURE31_ARB */
+   { 33289, 0x000084C3 }, /* GL_TEXTURE3_ARB */
+   { 33305, 0x000084C4 }, /* GL_TEXTURE4 */
+   { 33317, 0x000084C4 }, /* GL_TEXTURE4_ARB */
+   { 33333, 0x000084C5 }, /* GL_TEXTURE5 */
+   { 33345, 0x000084C5 }, /* GL_TEXTURE5_ARB */
+   { 33361, 0x000084C6 }, /* GL_TEXTURE6 */
+   { 33373, 0x000084C6 }, /* GL_TEXTURE6_ARB */
+   { 33389, 0x000084C7 }, /* GL_TEXTURE7 */
+   { 33401, 0x000084C7 }, /* GL_TEXTURE7_ARB */
+   { 33417, 0x000084C8 }, /* GL_TEXTURE8 */
+   { 33429, 0x000084C8 }, /* GL_TEXTURE8_ARB */
+   { 33445, 0x000084C9 }, /* GL_TEXTURE9 */
+   { 33457, 0x000084C9 }, /* GL_TEXTURE9_ARB */
+   { 33473, 0x00000DE0 }, /* GL_TEXTURE_1D */
+   { 33487, 0x00008C18 }, /* GL_TEXTURE_1D_ARRAY_EXT */
+   { 33511, 0x00000DE1 }, /* GL_TEXTURE_2D */
+   { 33525, 0x00008C1A }, /* GL_TEXTURE_2D_ARRAY_EXT */
+   { 33549, 0x0000806F }, /* GL_TEXTURE_3D */
+   { 33563, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE */
+   { 33585, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE_EXT */
+   { 33611, 0x0000813C }, /* GL_TEXTURE_BASE_LEVEL */
+   { 33633, 0x00008068 }, /* GL_TEXTURE_BINDING_1D */
+   { 33655, 0x00008C1C }, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */
+   { 33687, 0x00008069 }, /* GL_TEXTURE_BINDING_2D */
+   { 33709, 0x00008C1D }, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */
+   { 33741, 0x0000806A }, /* GL_TEXTURE_BINDING_3D */
+   { 33763, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP */
+   { 33791, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP_ARB */
+   { 33823, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */
+   { 33856, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_NV */
+   { 33888, 0x00040000 }, /* GL_TEXTURE_BIT */
+   { 33903, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE */
+   { 33924, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE_EXT */
+   { 33949, 0x00001005 }, /* GL_TEXTURE_BORDER */
+   { 33967, 0x00001004 }, /* GL_TEXTURE_BORDER_COLOR */
+   { 33991, 0x00008171 }, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */
+   { 34022, 0x00008176 }, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */
+   { 34052, 0x00008172 }, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */
+   { 34082, 0x00008175 }, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */
+   { 34117, 0x00008173 }, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */
+   { 34148, 0x00008174 }, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */
+   { 34186, 0x000080BC }, /* GL_TEXTURE_COLOR_TABLE_SGI */
+   { 34213, 0x000081EF }, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */
+   { 34245, 0x000080BF }, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
+   { 34279, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC */
+   { 34303, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC_ARB */
+   { 34331, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE */
+   { 34355, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE_ARB */
+   { 34383, 0x0000819B }, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */
+   { 34416, 0x0000819A }, /* GL_TEXTURE_COMPARE_SGIX */
+   { 34440, 0x00001003 }, /* GL_TEXTURE_COMPONENTS */
+   { 34462, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED */
+   { 34484, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED_ARB */
+   { 34510, 0x000086A3 }, /* GL_TEXTURE_COMPRESSED_FORMATS_ARB */
+   { 34544, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */
+   { 34577, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB */
+   { 34614, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT */
+   { 34642, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT_ARB */
+   { 34674, 0x00008078 }, /* GL_TEXTURE_COORD_ARRAY */
+   { 34697, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */
+   { 34735, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB */
+   { 34777, 0x00008092 }, /* GL_TEXTURE_COORD_ARRAY_POINTER */
+   { 34808, 0x00008088 }, /* GL_TEXTURE_COORD_ARRAY_SIZE */
+   { 34836, 0x0000808A }, /* GL_TEXTURE_COORD_ARRAY_STRIDE */
+   { 34866, 0x00008089 }, /* GL_TEXTURE_COORD_ARRAY_TYPE */
+   { 34894, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP */
+   { 34914, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP_ARB */
+   { 34938, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */
+   { 34969, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB */
+   { 35004, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */
+   { 35035, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB */
+   { 35070, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */
+   { 35101, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB */
+   { 35136, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */
+   { 35167, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB */
+   { 35202, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */
+   { 35233, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB */
+   { 35268, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */
+   { 35299, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB */
+   { 35334, 0x00008071 }, /* GL_TEXTURE_DEPTH */
+   { 35351, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE */
+   { 35373, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE_ARB */
+   { 35399, 0x00002300 }, /* GL_TEXTURE_ENV */
+   { 35414, 0x00002201 }, /* GL_TEXTURE_ENV_COLOR */
+   { 35435, 0x00002200 }, /* GL_TEXTURE_ENV_MODE */
+   { 35455, 0x00008500 }, /* GL_TEXTURE_FILTER_CONTROL */
+   { 35481, 0x00002500 }, /* GL_TEXTURE_GEN_MODE */
+   { 35501, 0x00000C63 }, /* GL_TEXTURE_GEN_Q */
+   { 35518, 0x00000C62 }, /* GL_TEXTURE_GEN_R */
+   { 35535, 0x00000C60 }, /* GL_TEXTURE_GEN_S */
+   { 35552, 0x00000C61 }, /* GL_TEXTURE_GEN_T */
+   { 35569, 0x0000819D }, /* GL_TEXTURE_GEQUAL_R_SGIX */
+   { 35594, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE */
+   { 35616, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE_EXT */
+   { 35642, 0x00001001 }, /* GL_TEXTURE_HEIGHT */
+   { 35660, 0x000080ED }, /* GL_TEXTURE_INDEX_SIZE_EXT */
+   { 35686, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE */
+   { 35712, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE_EXT */
+   { 35742, 0x00001003 }, /* GL_TEXTURE_INTERNAL_FORMAT */
+   { 35769, 0x0000819C }, /* GL_TEXTURE_LEQUAL_R_SGIX */
+   { 35794, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS */
+   { 35814, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS_EXT */
+   { 35838, 0x00008190 }, /* GL_TEXTURE_LOD_BIAS_R_SGIX */
+   { 35865, 0x0000818E }, /* GL_TEXTURE_LOD_BIAS_S_SGIX */
+   { 35892, 0x0000818F }, /* GL_TEXTURE_LOD_BIAS_T_SGIX */
+   { 35919, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE */
+   { 35945, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE_EXT */
+   { 35975, 0x00002800 }, /* GL_TEXTURE_MAG_FILTER */
+   { 35997, 0x00000BA8 }, /* GL_TEXTURE_MATRIX */
+   { 36015, 0x000084FE }, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */
+   { 36045, 0x0000836B }, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */
+   { 36073, 0x00008369 }, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */
+   { 36101, 0x0000836A }, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */
+   { 36129, 0x0000813D }, /* GL_TEXTURE_MAX_LEVEL */
+   { 36150, 0x0000813B }, /* GL_TEXTURE_MAX_LOD */
+   { 36169, 0x00002801 }, /* GL_TEXTURE_MIN_FILTER */
+   { 36191, 0x0000813A }, /* GL_TEXTURE_MIN_LOD */
+   { 36210, 0x00008066 }, /* GL_TEXTURE_PRIORITY */
+   { 36230, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_ARB */
+   { 36255, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_NV */
+   { 36279, 0x0000805C }, /* GL_TEXTURE_RED_SIZE */
+   { 36299, 0x0000805C }, /* GL_TEXTURE_RED_SIZE_EXT */
+   { 36323, 0x00008067 }, /* GL_TEXTURE_RESIDENT */
+   { 36343, 0x00000BA5 }, /* GL_TEXTURE_STACK_DEPTH */
+   { 36366, 0x000088F1 }, /* GL_TEXTURE_STENCIL_SIZE */
+   { 36390, 0x00008065 }, /* GL_TEXTURE_TOO_LARGE_EXT */
+   { 36415, 0x0000888F }, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */
+   { 36449, 0x00001000 }, /* GL_TEXTURE_WIDTH */
+   { 36466, 0x00008072 }, /* GL_TEXTURE_WRAP_R */
+   { 36484, 0x00002802 }, /* GL_TEXTURE_WRAP_S */
+   { 36502, 0x00002803 }, /* GL_TEXTURE_WRAP_T */
+   { 36520, 0x000088BF }, /* GL_TIME_ELAPSED_EXT */
+   { 36540, 0x00008648 }, /* GL_TRACK_MATRIX_NV */
+   { 36559, 0x00008649 }, /* GL_TRACK_MATRIX_TRANSFORM_NV */
+   { 36588, 0x00001000 }, /* GL_TRANSFORM_BIT */
+   { 36605, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX */
+   { 36631, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX_ARB */
+   { 36661, 0x000088B7 }, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */
+   { 36693, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX */
+   { 36723, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX_ARB */
+   { 36757, 0x0000862C }, /* GL_TRANSPOSE_NV */
+   { 36773, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX */
+   { 36804, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX_ARB */
+   { 36839, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX */
+   { 36867, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX_ARB */
+   { 36899, 0x00000004 }, /* GL_TRIANGLES */
+   { 36912, 0x00000006 }, /* GL_TRIANGLE_FAN */
+   { 36928, 0x00008615 }, /* GL_TRIANGLE_MESH_SUN */
+   { 36949, 0x00000005 }, /* GL_TRIANGLE_STRIP */
+   { 36967, 0x00000001 }, /* GL_TRUE */
+   { 36975, 0x00000CF5 }, /* GL_UNPACK_ALIGNMENT */
+   { 36995, 0x0000806E }, /* GL_UNPACK_IMAGE_HEIGHT */
+   { 37018, 0x00000CF1 }, /* GL_UNPACK_LSB_FIRST */
+   { 37038, 0x00000CF2 }, /* GL_UNPACK_ROW_LENGTH */
+   { 37059, 0x0000806D }, /* GL_UNPACK_SKIP_IMAGES */
+   { 37081, 0x00000CF4 }, /* GL_UNPACK_SKIP_PIXELS */
+   { 37103, 0x00000CF3 }, /* GL_UNPACK_SKIP_ROWS */
+   { 37123, 0x00000CF0 }, /* GL_UNPACK_SWAP_BYTES */
+   { 37144, 0x00001401 }, /* GL_UNSIGNED_BYTE */
+   { 37161, 0x00008362 }, /* GL_UNSIGNED_BYTE_2_3_3_REV */
+   { 37188, 0x00008032 }, /* GL_UNSIGNED_BYTE_3_3_2 */
+   { 37211, 0x00001405 }, /* GL_UNSIGNED_INT */
+   { 37227, 0x00008036 }, /* GL_UNSIGNED_INT_10_10_10_2 */
+   { 37254, 0x000084FA }, /* GL_UNSIGNED_INT_24_8 */
+   { 37275, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_NV */
+   { 37299, 0x00008368 }, /* GL_UNSIGNED_INT_2_10_10_10_REV */
+   { 37330, 0x00008035 }, /* GL_UNSIGNED_INT_8_8_8_8 */
+   { 37354, 0x00008367 }, /* GL_UNSIGNED_INT_8_8_8_8_REV */
+   { 37382, 0x00008C17 }, /* GL_UNSIGNED_NORMALIZED */
+   { 37405, 0x00001403 }, /* GL_UNSIGNED_SHORT */
+   { 37423, 0x00008366 }, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */
+   { 37453, 0x00008033 }, /* GL_UNSIGNED_SHORT_4_4_4_4 */
+   { 37479, 0x00008365 }, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */
+   { 37509, 0x00008034 }, /* GL_UNSIGNED_SHORT_5_5_5_1 */
+   { 37535, 0x00008363 }, /* GL_UNSIGNED_SHORT_5_6_5 */
+   { 37559, 0x00008364 }, /* GL_UNSIGNED_SHORT_5_6_5_REV */
+   { 37587, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_APPLE */
+   { 37615, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_MESA */
+   { 37642, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */
+   { 37674, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_MESA */
+   { 37705, 0x00008CA2 }, /* GL_UPPER_LEFT */
+   { 37719, 0x00002A20 }, /* GL_V2F */
+   { 37726, 0x00002A21 }, /* GL_V3F */
+   { 37733, 0x00008B83 }, /* GL_VALIDATE_STATUS */
+   { 37752, 0x00001F00 }, /* GL_VENDOR */
+   { 37762, 0x00001F02 }, /* GL_VERSION */
+   { 37773, 0x00008074 }, /* GL_VERTEX_ARRAY */
+   { 37789, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING_APPLE */
+   { 37819, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING */
+   { 37850, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING_ARB */
+   { 37885, 0x0000808E }, /* GL_VERTEX_ARRAY_POINTER */
+   { 37909, 0x0000807A }, /* GL_VERTEX_ARRAY_SIZE */
+   { 37930, 0x0000807C }, /* GL_VERTEX_ARRAY_STRIDE */
+   { 37953, 0x0000807B }, /* GL_VERTEX_ARRAY_TYPE */
+   { 37974, 0x00008650 }, /* GL_VERTEX_ATTRIB_ARRAY0_NV */
+   { 38001, 0x0000865A }, /* GL_VERTEX_ATTRIB_ARRAY10_NV */
+   { 38029, 0x0000865B }, /* GL_VERTEX_ATTRIB_ARRAY11_NV */
+   { 38057, 0x0000865C }, /* GL_VERTEX_ATTRIB_ARRAY12_NV */
+   { 38085, 0x0000865D }, /* GL_VERTEX_ATTRIB_ARRAY13_NV */
+   { 38113, 0x0000865E }, /* GL_VERTEX_ATTRIB_ARRAY14_NV */
+   { 38141, 0x0000865F }, /* GL_VERTEX_ATTRIB_ARRAY15_NV */
+   { 38169, 0x00008651 }, /* GL_VERTEX_ATTRIB_ARRAY1_NV */
+   { 38196, 0x00008652 }, /* GL_VERTEX_ATTRIB_ARRAY2_NV */
+   { 38223, 0x00008653 }, /* GL_VERTEX_ATTRIB_ARRAY3_NV */
+   { 38250, 0x00008654 }, /* GL_VERTEX_ATTRIB_ARRAY4_NV */
+   { 38277, 0x00008655 }, /* GL_VERTEX_ATTRIB_ARRAY5_NV */
+   { 38304, 0x00008656 }, /* GL_VERTEX_ATTRIB_ARRAY6_NV */
+   { 38331, 0x00008657 }, /* GL_VERTEX_ATTRIB_ARRAY7_NV */
+   { 38358, 0x00008658 }, /* GL_VERTEX_ATTRIB_ARRAY8_NV */
+   { 38385, 0x00008659 }, /* GL_VERTEX_ATTRIB_ARRAY9_NV */
+   { 38412, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */
+   { 38450, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB */
+   { 38492, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */
+   { 38523, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB */
+   { 38558, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */
+   { 38592, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB */
+   { 38630, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */
+   { 38661, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB */
+   { 38696, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */
+   { 38724, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB */
+   { 38756, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */
+   { 38786, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB */
+   { 38820, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */
+   { 38848, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB */
+   { 38880, 0x000086A7 }, /* GL_VERTEX_BLEND_ARB */
+   { 38900, 0x00008620 }, /* GL_VERTEX_PROGRAM_ARB */
+   { 38922, 0x0000864A }, /* GL_VERTEX_PROGRAM_BINDING_NV */
+   { 38951, 0x00008620 }, /* GL_VERTEX_PROGRAM_NV */
+   { 38972, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE */
+   { 39001, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_ARB */
+   { 39034, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_NV */
+   { 39066, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE */
+   { 39093, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_ARB */
+   { 39124, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_NV */
+   { 39154, 0x00008B31 }, /* GL_VERTEX_SHADER */
+   { 39171, 0x00008B31 }, /* GL_VERTEX_SHADER_ARB */
+   { 39192, 0x00008621 }, /* GL_VERTEX_STATE_PROGRAM_NV */
+   { 39219, 0x00000BA2 }, /* GL_VIEWPORT */
+   { 39231, 0x00000800 }, /* GL_VIEWPORT_BIT */
+   { 39247, 0x000086AD }, /* GL_WEIGHT_ARRAY_ARB */
+   { 39267, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */
+   { 39298, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB */
+   { 39333, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_ARB */
+   { 39361, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_ARB */
+   { 39386, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_ARB */
+   { 39413, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_ARB */
+   { 39438, 0x000086A6 }, /* GL_WEIGHT_SUM_UNITY_ARB */
+   { 39462, 0x000081D4 }, /* GL_WRAP_BORDER_SUN */
+   { 39481, 0x000088B9 }, /* GL_WRITE_ONLY */
+   { 39495, 0x000088B9 }, /* GL_WRITE_ONLY_ARB */
+   { 39513, 0x00001506 }, /* GL_XOR */
+   { 39520, 0x000085B9 }, /* GL_YCBCR_422_APPLE */
+   { 39539, 0x00008757 }, /* GL_YCBCR_MESA */
+   { 39553, 0x00000000 }, /* GL_ZERO */
+   { 39561, 0x00000D16 }, /* GL_ZOOM_X */
+   { 39571, 0x00000D17 }, /* GL_ZOOM_Y */
 };
 
-static const unsigned reduced_enums[1319] =
+static const unsigned reduced_enums[1321] =
 {
-       469, /* GL_FALSE */
-       683, /* GL_LINES */
-       685, /* GL_LINE_LOOP */
-       692, /* GL_LINE_STRIP */
-      1709, /* GL_TRIANGLES */
-      1712, /* GL_TRIANGLE_STRIP */
-      1710, /* GL_TRIANGLE_FAN */
-      1254, /* GL_QUADS */
-      1256, /* GL_QUAD_STRIP */
-      1142, /* GL_POLYGON */
-      1154, /* GL_POLYGON_STIPPLE_BIT */
-      1103, /* GL_PIXEL_MODE_BIT */
-       670, /* GL_LIGHTING_BIT */
-       497, /* GL_FOG_BIT */
+       471, /* GL_FALSE */
+       685, /* GL_LINES */
+       687, /* GL_LINE_LOOP */
+       694, /* GL_LINE_STRIP */
+      1717, /* GL_TRIANGLES */
+      1720, /* GL_TRIANGLE_STRIP */
+      1718, /* GL_TRIANGLE_FAN */
+      1262, /* GL_QUADS */
+      1264, /* GL_QUAD_STRIP */
+      1150, /* GL_POLYGON */
+      1162, /* GL_POLYGON_STIPPLE_BIT */
+      1111, /* GL_PIXEL_MODE_BIT */
+       672, /* GL_LIGHTING_BIT */
+       499, /* GL_FOG_BIT */
          8, /* GL_ACCUM */
-       702, /* GL_LOAD */
-      1308, /* GL_RETURN */
-       976, /* GL_MULT */
+       704, /* GL_LOAD */
+      1316, /* GL_RETURN */
+       984, /* GL_MULT */
         23, /* GL_ADD */
-       992, /* GL_NEVER */
-       660, /* GL_LESS */
-       459, /* GL_EQUAL */
-       659, /* GL_LEQUAL */
-       583, /* GL_GREATER */
-      1007, /* GL_NOTEQUAL */
-       582, /* GL_GEQUAL */
+      1000, /* GL_NEVER */
+       662, /* GL_LESS */
+       461, /* GL_EQUAL */
+       661, /* GL_LEQUAL */
+       585, /* GL_GREATER */
+      1015, /* GL_NOTEQUAL */
+       584, /* GL_GEQUAL */
         46, /* GL_ALWAYS */
-      1448, /* GL_SRC_COLOR */
-      1036, /* GL_ONE_MINUS_SRC_COLOR */
-      1446, /* GL_SRC_ALPHA */
-      1035, /* GL_ONE_MINUS_SRC_ALPHA */
-       438, /* GL_DST_ALPHA */
-      1033, /* GL_ONE_MINUS_DST_ALPHA */
-       439, /* GL_DST_COLOR */
-      1034, /* GL_ONE_MINUS_DST_COLOR */
-      1447, /* GL_SRC_ALPHA_SATURATE */
-       570, /* GL_FRONT_LEFT */
-       571, /* GL_FRONT_RIGHT */
+      1456, /* GL_SRC_COLOR */
+      1044, /* GL_ONE_MINUS_SRC_COLOR */
+      1454, /* GL_SRC_ALPHA */
+      1043, /* GL_ONE_MINUS_SRC_ALPHA */
+       440, /* GL_DST_ALPHA */
+      1041, /* GL_ONE_MINUS_DST_ALPHA */
+       441, /* GL_DST_COLOR */
+      1042, /* GL_ONE_MINUS_DST_COLOR */
+      1455, /* GL_SRC_ALPHA_SATURATE */
+       572, /* GL_FRONT_LEFT */
+       573, /* GL_FRONT_RIGHT */
         68, /* GL_BACK_LEFT */
         69, /* GL_BACK_RIGHT */
-       567, /* GL_FRONT */
+       569, /* GL_FRONT */
         67, /* GL_BACK */
-       658, /* GL_LEFT */
-      1350, /* GL_RIGHT */
-       568, /* GL_FRONT_AND_BACK */
+       660, /* GL_LEFT */
+      1358, /* GL_RIGHT */
+       570, /* GL_FRONT_AND_BACK */
         62, /* GL_AUX0 */
         63, /* GL_AUX1 */
         64, /* GL_AUX2 */
         65, /* GL_AUX3 */
-       649, /* GL_INVALID_ENUM */
-       653, /* GL_INVALID_VALUE */
-       652, /* GL_INVALID_OPERATION */
-      1453, /* GL_STACK_OVERFLOW */
-      1454, /* GL_STACK_UNDERFLOW */
-      1061, /* GL_OUT_OF_MEMORY */
-       650, /* GL_INVALID_FRAMEBUFFER_OPERATION */
+       651, /* GL_INVALID_ENUM */
+       655, /* GL_INVALID_VALUE */
+       654, /* GL_INVALID_OPERATION */
+      1461, /* GL_STACK_OVERFLOW */
+      1462, /* GL_STACK_UNDERFLOW */
+      1069, /* GL_OUT_OF_MEMORY */
+       652, /* GL_INVALID_FRAMEBUFFER_OPERATION */
          0, /* GL_2D */
          2, /* GL_3D */
          3, /* GL_3D_COLOR */
          4, /* GL_3D_COLOR_TEXTURE */
          6, /* GL_4D_COLOR_TEXTURE */
-      1081, /* GL_PASS_THROUGH_TOKEN */
-      1141, /* GL_POINT_TOKEN */
-       693, /* GL_LINE_TOKEN */
-      1155, /* GL_POLYGON_TOKEN */
+      1089, /* GL_PASS_THROUGH_TOKEN */
+      1149, /* GL_POINT_TOKEN */
+       695, /* GL_LINE_TOKEN */
+      1163, /* GL_POLYGON_TOKEN */
         73, /* GL_BITMAP_TOKEN */
-       437, /* GL_DRAW_PIXEL_TOKEN */
+       439, /* GL_DRAW_PIXEL_TOKEN */
        297, /* GL_COPY_PIXEL_TOKEN */
-       686, /* GL_LINE_RESET_TOKEN */
-       462, /* GL_EXP */
-       463, /* GL_EXP2 */
-       331, /* GL_CW */
+       688, /* GL_LINE_RESET_TOKEN */
+       464, /* GL_EXP */
+       465, /* GL_EXP2 */
+       333, /* GL_CW */
        122, /* GL_CCW */
        143, /* GL_COEFF */
-      1058, /* GL_ORDER */
-       375, /* GL_DOMAIN */
-       305, /* GL_CURRENT_COLOR */
-       308, /* GL_CURRENT_INDEX */
-       314, /* GL_CURRENT_NORMAL */
-       327, /* GL_CURRENT_TEXTURE_COORDS */
-       319, /* GL_CURRENT_RASTER_COLOR */
-       321, /* GL_CURRENT_RASTER_INDEX */
-       325, /* GL_CURRENT_RASTER_TEXTURE_COORDS */
-       322, /* GL_CURRENT_RASTER_POSITION */
-       323, /* GL_CURRENT_RASTER_POSITION_VALID */
-       320, /* GL_CURRENT_RASTER_DISTANCE */
-      1134, /* GL_POINT_SMOOTH */
-      1123, /* GL_POINT_SIZE */
-      1133, /* GL_POINT_SIZE_RANGE */
-      1124, /* GL_POINT_SIZE_GRANULARITY */
-       687, /* GL_LINE_SMOOTH */
-       694, /* GL_LINE_WIDTH */
-       696, /* GL_LINE_WIDTH_RANGE */
-       695, /* GL_LINE_WIDTH_GRANULARITY */
-       689, /* GL_LINE_STIPPLE */
-       690, /* GL_LINE_STIPPLE_PATTERN */
-       691, /* GL_LINE_STIPPLE_REPEAT */
-       701, /* GL_LIST_MODE */
-       860, /* GL_MAX_LIST_NESTING */
-       698, /* GL_LIST_BASE */
-       700, /* GL_LIST_INDEX */
-      1144, /* GL_POLYGON_MODE */
-      1151, /* GL_POLYGON_SMOOTH */
-      1153, /* GL_POLYGON_STIPPLE */
-       448, /* GL_EDGE_FLAG */
-       298, /* GL_CULL_FACE */
-       299, /* GL_CULL_FACE_MODE */
-       569, /* GL_FRONT_FACE */
-       669, /* GL_LIGHTING */
-       674, /* GL_LIGHT_MODEL_LOCAL_VIEWER */
-       675, /* GL_LIGHT_MODEL_TWO_SIDE */
-       671, /* GL_LIGHT_MODEL_AMBIENT */
-      1396, /* GL_SHADE_MODEL */
+      1066, /* GL_ORDER */
+       377, /* GL_DOMAIN */
+       307, /* GL_CURRENT_COLOR */
+       310, /* GL_CURRENT_INDEX */
+       316, /* GL_CURRENT_NORMAL */
+       329, /* GL_CURRENT_TEXTURE_COORDS */
+       321, /* GL_CURRENT_RASTER_COLOR */
+       323, /* GL_CURRENT_RASTER_INDEX */
+       327, /* GL_CURRENT_RASTER_TEXTURE_COORDS */
+       324, /* GL_CURRENT_RASTER_POSITION */
+       325, /* GL_CURRENT_RASTER_POSITION_VALID */
+       322, /* GL_CURRENT_RASTER_DISTANCE */
+      1142, /* GL_POINT_SMOOTH */
+      1131, /* GL_POINT_SIZE */
+      1141, /* GL_POINT_SIZE_RANGE */
+      1132, /* GL_POINT_SIZE_GRANULARITY */
+       689, /* GL_LINE_SMOOTH */
+       696, /* GL_LINE_WIDTH */
+       698, /* GL_LINE_WIDTH_RANGE */
+       697, /* GL_LINE_WIDTH_GRANULARITY */
+       691, /* GL_LINE_STIPPLE */
+       692, /* GL_LINE_STIPPLE_PATTERN */
+       693, /* GL_LINE_STIPPLE_REPEAT */
+       703, /* GL_LIST_MODE */
+       868, /* GL_MAX_LIST_NESTING */
+       700, /* GL_LIST_BASE */
+       702, /* GL_LIST_INDEX */
+      1152, /* GL_POLYGON_MODE */
+      1159, /* GL_POLYGON_SMOOTH */
+      1161, /* GL_POLYGON_STIPPLE */
+       450, /* GL_EDGE_FLAG */
+       300, /* GL_CULL_FACE */
+       301, /* GL_CULL_FACE_MODE */
+       571, /* GL_FRONT_FACE */
+       671, /* GL_LIGHTING */
+       676, /* GL_LIGHT_MODEL_LOCAL_VIEWER */
+       677, /* GL_LIGHT_MODEL_TWO_SIDE */
+       673, /* GL_LIGHT_MODEL_AMBIENT */
+      1404, /* GL_SHADE_MODEL */
        190, /* GL_COLOR_MATERIAL_FACE */
        191, /* GL_COLOR_MATERIAL_PARAMETER */
        189, /* GL_COLOR_MATERIAL */
-       496, /* GL_FOG */
-       518, /* GL_FOG_INDEX */
-       514, /* GL_FOG_DENSITY */
-       522, /* GL_FOG_START */
-       516, /* GL_FOG_END */
-       519, /* GL_FOG_MODE */
-       498, /* GL_FOG_COLOR */
-       362, /* GL_DEPTH_RANGE */
-       369, /* GL_DEPTH_TEST */
-       372, /* GL_DEPTH_WRITEMASK */
-       350, /* GL_DEPTH_CLEAR_VALUE */
-       361, /* GL_DEPTH_FUNC */
+       498, /* GL_FOG */
+       520, /* GL_FOG_INDEX */
+       516, /* GL_FOG_DENSITY */
+       524, /* GL_FOG_START */
+       518, /* GL_FOG_END */
+       521, /* GL_FOG_MODE */
+       500, /* GL_FOG_COLOR */
+       364, /* GL_DEPTH_RANGE */
+       371, /* GL_DEPTH_TEST */
+       374, /* GL_DEPTH_WRITEMASK */
+       352, /* GL_DEPTH_CLEAR_VALUE */
+       363, /* GL_DEPTH_FUNC */
         12, /* GL_ACCUM_CLEAR_VALUE */
-      1489, /* GL_STENCIL_TEST */
-      1477, /* GL_STENCIL_CLEAR_VALUE */
-      1479, /* GL_STENCIL_FUNC */
-      1491, /* GL_STENCIL_VALUE_MASK */
-      1478, /* GL_STENCIL_FAIL */
-      1486, /* GL_STENCIL_PASS_DEPTH_FAIL */
-      1487, /* GL_STENCIL_PASS_DEPTH_PASS */
-      1488, /* GL_STENCIL_REF */
-      1492, /* GL_STENCIL_WRITEMASK */
-       829, /* GL_MATRIX_MODE */
-       997, /* GL_NORMALIZE */
-      1801, /* GL_VIEWPORT */
-       971, /* GL_MODELVIEW_STACK_DEPTH */
-      1234, /* GL_PROJECTION_STACK_DEPTH */
-      1687, /* GL_TEXTURE_STACK_DEPTH */
-       969, /* GL_MODELVIEW_MATRIX */
-      1233, /* GL_PROJECTION_MATRIX */
-      1672, /* GL_TEXTURE_MATRIX */
+      1497, /* GL_STENCIL_TEST */
+      1485, /* GL_STENCIL_CLEAR_VALUE */
+      1487, /* GL_STENCIL_FUNC */
+      1499, /* GL_STENCIL_VALUE_MASK */
+      1486, /* GL_STENCIL_FAIL */
+      1494, /* GL_STENCIL_PASS_DEPTH_FAIL */
+      1495, /* GL_STENCIL_PASS_DEPTH_PASS */
+      1496, /* GL_STENCIL_REF */
+      1500, /* GL_STENCIL_WRITEMASK */
+       837, /* GL_MATRIX_MODE */
+      1005, /* GL_NORMALIZE */
+      1809, /* GL_VIEWPORT */
+       979, /* GL_MODELVIEW_STACK_DEPTH */
+      1242, /* GL_PROJECTION_STACK_DEPTH */
+      1695, /* GL_TEXTURE_STACK_DEPTH */
+       977, /* GL_MODELVIEW_MATRIX */
+      1241, /* GL_PROJECTION_MATRIX */
+      1680, /* GL_TEXTURE_MATRIX */
         60, /* GL_ATTRIB_STACK_DEPTH */
        133, /* GL_CLIENT_ATTRIB_STACK_DEPTH */
         43, /* GL_ALPHA_TEST */
         44, /* GL_ALPHA_TEST_FUNC */
         45, /* GL_ALPHA_TEST_REF */
-       374, /* GL_DITHER */
+       376, /* GL_DITHER */
         77, /* GL_BLEND_DST */
         86, /* GL_BLEND_SRC */
         74, /* GL_BLEND */
-       704, /* GL_LOGIC_OP_MODE */
-       623, /* GL_INDEX_LOGIC_OP */
+       706, /* GL_LOGIC_OP_MODE */
+       625, /* GL_INDEX_LOGIC_OP */
        188, /* GL_COLOR_LOGIC_OP */
         66, /* GL_AUX_BUFFERS */
-       385, /* GL_DRAW_BUFFER */
-      1266, /* GL_READ_BUFFER */
-      1377, /* GL_SCISSOR_BOX */
-      1378, /* GL_SCISSOR_TEST */
-       622, /* GL_INDEX_CLEAR_VALUE */
-       627, /* GL_INDEX_WRITEMASK */
+       387, /* GL_DRAW_BUFFER */
+      1274, /* GL_READ_BUFFER */
+      1385, /* GL_SCISSOR_BOX */
+      1386, /* GL_SCISSOR_TEST */
+       624, /* GL_INDEX_CLEAR_VALUE */
+       629, /* GL_INDEX_WRITEMASK */
        185, /* GL_COLOR_CLEAR_VALUE */
        227, /* GL_COLOR_WRITEMASK */
-       624, /* GL_INDEX_MODE */
-      1343, /* GL_RGBA_MODE */
-       384, /* GL_DOUBLEBUFFER */
-      1493, /* GL_STEREO */
-      1301, /* GL_RENDER_MODE */
-      1082, /* GL_PERSPECTIVE_CORRECTION_HINT */
-      1135, /* GL_POINT_SMOOTH_HINT */
-       688, /* GL_LINE_SMOOTH_HINT */
-      1152, /* GL_POLYGON_SMOOTH_HINT */
-       517, /* GL_FOG_HINT */
-      1653, /* GL_TEXTURE_GEN_S */
-      1654, /* GL_TEXTURE_GEN_T */
-      1652, /* GL_TEXTURE_GEN_R */
-      1651, /* GL_TEXTURE_GEN_Q */
-      1095, /* GL_PIXEL_MAP_I_TO_I */
-      1101, /* GL_PIXEL_MAP_S_TO_S */
-      1097, /* GL_PIXEL_MAP_I_TO_R */
-      1093, /* GL_PIXEL_MAP_I_TO_G */
-      1091, /* GL_PIXEL_MAP_I_TO_B */
-      1089, /* GL_PIXEL_MAP_I_TO_A */
-      1099, /* GL_PIXEL_MAP_R_TO_R */
-      1087, /* GL_PIXEL_MAP_G_TO_G */
-      1085, /* GL_PIXEL_MAP_B_TO_B */
-      1083, /* GL_PIXEL_MAP_A_TO_A */
-      1096, /* GL_PIXEL_MAP_I_TO_I_SIZE */
-      1102, /* GL_PIXEL_MAP_S_TO_S_SIZE */
-      1098, /* GL_PIXEL_MAP_I_TO_R_SIZE */
-      1094, /* GL_PIXEL_MAP_I_TO_G_SIZE */
-      1092, /* GL_PIXEL_MAP_I_TO_B_SIZE */
-      1090, /* GL_PIXEL_MAP_I_TO_A_SIZE */
-      1100, /* GL_PIXEL_MAP_R_TO_R_SIZE */
-      1088, /* GL_PIXEL_MAP_G_TO_G_SIZE */
-      1086, /* GL_PIXEL_MAP_B_TO_B_SIZE */
-      1084, /* GL_PIXEL_MAP_A_TO_A_SIZE */
-      1721, /* GL_UNPACK_SWAP_BYTES */
-      1716, /* GL_UNPACK_LSB_FIRST */
-      1717, /* GL_UNPACK_ROW_LENGTH */
-      1720, /* GL_UNPACK_SKIP_ROWS */
-      1719, /* GL_UNPACK_SKIP_PIXELS */
-      1714, /* GL_UNPACK_ALIGNMENT */
-      1070, /* GL_PACK_SWAP_BYTES */
-      1065, /* GL_PACK_LSB_FIRST */
-      1066, /* GL_PACK_ROW_LENGTH */
-      1069, /* GL_PACK_SKIP_ROWS */
-      1068, /* GL_PACK_SKIP_PIXELS */
-      1062, /* GL_PACK_ALIGNMENT */
-       782, /* GL_MAP_COLOR */
-       783, /* GL_MAP_STENCIL */
-       626, /* GL_INDEX_SHIFT */
-       625, /* GL_INDEX_OFFSET */
-      1279, /* GL_RED_SCALE */
-      1277, /* GL_RED_BIAS */
-      1818, /* GL_ZOOM_X */
-      1819, /* GL_ZOOM_Y */
-       587, /* GL_GREEN_SCALE */
-       585, /* GL_GREEN_BIAS */
+       626, /* GL_INDEX_MODE */
+      1351, /* GL_RGBA_MODE */
+       386, /* GL_DOUBLEBUFFER */
+      1501, /* GL_STEREO */
+      1309, /* GL_RENDER_MODE */
+      1090, /* GL_PERSPECTIVE_CORRECTION_HINT */
+      1143, /* GL_POINT_SMOOTH_HINT */
+       690, /* GL_LINE_SMOOTH_HINT */
+      1160, /* GL_POLYGON_SMOOTH_HINT */
+       519, /* GL_FOG_HINT */
+      1661, /* GL_TEXTURE_GEN_S */
+      1662, /* GL_TEXTURE_GEN_T */
+      1660, /* GL_TEXTURE_GEN_R */
+      1659, /* GL_TEXTURE_GEN_Q */
+      1103, /* GL_PIXEL_MAP_I_TO_I */
+      1109, /* GL_PIXEL_MAP_S_TO_S */
+      1105, /* GL_PIXEL_MAP_I_TO_R */
+      1101, /* GL_PIXEL_MAP_I_TO_G */
+      1099, /* GL_PIXEL_MAP_I_TO_B */
+      1097, /* GL_PIXEL_MAP_I_TO_A */
+      1107, /* GL_PIXEL_MAP_R_TO_R */
+      1095, /* GL_PIXEL_MAP_G_TO_G */
+      1093, /* GL_PIXEL_MAP_B_TO_B */
+      1091, /* GL_PIXEL_MAP_A_TO_A */
+      1104, /* GL_PIXEL_MAP_I_TO_I_SIZE */
+      1110, /* GL_PIXEL_MAP_S_TO_S_SIZE */
+      1106, /* GL_PIXEL_MAP_I_TO_R_SIZE */
+      1102, /* GL_PIXEL_MAP_I_TO_G_SIZE */
+      1100, /* GL_PIXEL_MAP_I_TO_B_SIZE */
+      1098, /* GL_PIXEL_MAP_I_TO_A_SIZE */
+      1108, /* GL_PIXEL_MAP_R_TO_R_SIZE */
+      1096, /* GL_PIXEL_MAP_G_TO_G_SIZE */
+      1094, /* GL_PIXEL_MAP_B_TO_B_SIZE */
+      1092, /* GL_PIXEL_MAP_A_TO_A_SIZE */
+      1729, /* GL_UNPACK_SWAP_BYTES */
+      1724, /* GL_UNPACK_LSB_FIRST */
+      1725, /* GL_UNPACK_ROW_LENGTH */
+      1728, /* GL_UNPACK_SKIP_ROWS */
+      1727, /* GL_UNPACK_SKIP_PIXELS */
+      1722, /* GL_UNPACK_ALIGNMENT */
+      1078, /* GL_PACK_SWAP_BYTES */
+      1073, /* GL_PACK_LSB_FIRST */
+      1074, /* GL_PACK_ROW_LENGTH */
+      1077, /* GL_PACK_SKIP_ROWS */
+      1076, /* GL_PACK_SKIP_PIXELS */
+      1070, /* GL_PACK_ALIGNMENT */
+       784, /* GL_MAP_COLOR */
+       789, /* GL_MAP_STENCIL */
+       628, /* GL_INDEX_SHIFT */
+       627, /* GL_INDEX_OFFSET */
+      1287, /* GL_RED_SCALE */
+      1285, /* GL_RED_BIAS */
+      1826, /* GL_ZOOM_X */
+      1827, /* GL_ZOOM_Y */
+       589, /* GL_GREEN_SCALE */
+       587, /* GL_GREEN_BIAS */
         92, /* GL_BLUE_SCALE */
         90, /* GL_BLUE_BIAS */
         42, /* GL_ALPHA_SCALE */
         40, /* GL_ALPHA_BIAS */
-       363, /* GL_DEPTH_SCALE */
-       344, /* GL_DEPTH_BIAS */
-       855, /* GL_MAX_EVAL_ORDER */
-       859, /* GL_MAX_LIGHTS */
-       838, /* GL_MAX_CLIP_PLANES */
-       904, /* GL_MAX_TEXTURE_SIZE */
-       865, /* GL_MAX_PIXEL_MAP_TABLE */
-       834, /* GL_MAX_ATTRIB_STACK_DEPTH */
-       862, /* GL_MAX_MODELVIEW_STACK_DEPTH */
-       863, /* GL_MAX_NAME_STACK_DEPTH */
-       891, /* GL_MAX_PROJECTION_STACK_DEPTH */
-       905, /* GL_MAX_TEXTURE_STACK_DEPTH */
-       919, /* GL_MAX_VIEWPORT_DIMS */
-       835, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */
-      1500, /* GL_SUBPIXEL_BITS */
-       621, /* GL_INDEX_BITS */
-      1278, /* GL_RED_BITS */
-       586, /* GL_GREEN_BITS */
+       365, /* GL_DEPTH_SCALE */
+       346, /* GL_DEPTH_BIAS */
+       863, /* GL_MAX_EVAL_ORDER */
+       867, /* GL_MAX_LIGHTS */
+       846, /* GL_MAX_CLIP_PLANES */
+       912, /* GL_MAX_TEXTURE_SIZE */
+       873, /* GL_MAX_PIXEL_MAP_TABLE */
+       842, /* GL_MAX_ATTRIB_STACK_DEPTH */
+       870, /* GL_MAX_MODELVIEW_STACK_DEPTH */
+       871, /* GL_MAX_NAME_STACK_DEPTH */
+       899, /* GL_MAX_PROJECTION_STACK_DEPTH */
+       913, /* GL_MAX_TEXTURE_STACK_DEPTH */
+       927, /* GL_MAX_VIEWPORT_DIMS */
+       843, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */
+      1508, /* GL_SUBPIXEL_BITS */
+       623, /* GL_INDEX_BITS */
+      1286, /* GL_RED_BITS */
+       588, /* GL_GREEN_BITS */
         91, /* GL_BLUE_BITS */
         41, /* GL_ALPHA_BITS */
-       345, /* GL_DEPTH_BITS */
-      1475, /* GL_STENCIL_BITS */
+       347, /* GL_DEPTH_BITS */
+      1483, /* GL_STENCIL_BITS */
         14, /* GL_ACCUM_RED_BITS */
         13, /* GL_ACCUM_GREEN_BITS */
         10, /* GL_ACCUM_BLUE_BITS */
          9, /* GL_ACCUM_ALPHA_BITS */
-       985, /* GL_NAME_STACK_DEPTH */
+       993, /* GL_NAME_STACK_DEPTH */
         61, /* GL_AUTO_NORMAL */
-       728, /* GL_MAP1_COLOR_4 */
-       731, /* GL_MAP1_INDEX */
-       732, /* GL_MAP1_NORMAL */
-       733, /* GL_MAP1_TEXTURE_COORD_1 */
-       734, /* GL_MAP1_TEXTURE_COORD_2 */
-       735, /* GL_MAP1_TEXTURE_COORD_3 */
-       736, /* GL_MAP1_TEXTURE_COORD_4 */
-       737, /* GL_MAP1_VERTEX_3 */
-       738, /* GL_MAP1_VERTEX_4 */
-       755, /* GL_MAP2_COLOR_4 */
-       758, /* GL_MAP2_INDEX */
-       759, /* GL_MAP2_NORMAL */
-       760, /* GL_MAP2_TEXTURE_COORD_1 */
-       761, /* GL_MAP2_TEXTURE_COORD_2 */
-       762, /* GL_MAP2_TEXTURE_COORD_3 */
-       763, /* GL_MAP2_TEXTURE_COORD_4 */
-       764, /* GL_MAP2_VERTEX_3 */
-       765, /* GL_MAP2_VERTEX_4 */
-       729, /* GL_MAP1_GRID_DOMAIN */
-       730, /* GL_MAP1_GRID_SEGMENTS */
-       756, /* GL_MAP2_GRID_DOMAIN */
-       757, /* GL_MAP2_GRID_SEGMENTS */
-      1577, /* GL_TEXTURE_1D */
-      1579, /* GL_TEXTURE_2D */
-       472, /* GL_FEEDBACK_BUFFER_POINTER */
-       473, /* GL_FEEDBACK_BUFFER_SIZE */
-       474, /* GL_FEEDBACK_BUFFER_TYPE */
-      1387, /* GL_SELECTION_BUFFER_POINTER */
-      1388, /* GL_SELECTION_BUFFER_SIZE */
-      1691, /* GL_TEXTURE_WIDTH */
-      1658, /* GL_TEXTURE_HEIGHT */
-      1614, /* GL_TEXTURE_COMPONENTS */
-      1598, /* GL_TEXTURE_BORDER_COLOR */
-      1597, /* GL_TEXTURE_BORDER */
-       376, /* GL_DONT_CARE */
-       470, /* GL_FASTEST */
-       993, /* GL_NICEST */
+       730, /* GL_MAP1_COLOR_4 */
+       733, /* GL_MAP1_INDEX */
+       734, /* GL_MAP1_NORMAL */
+       735, /* GL_MAP1_TEXTURE_COORD_1 */
+       736, /* GL_MAP1_TEXTURE_COORD_2 */
+       737, /* GL_MAP1_TEXTURE_COORD_3 */
+       738, /* GL_MAP1_TEXTURE_COORD_4 */
+       739, /* GL_MAP1_VERTEX_3 */
+       740, /* GL_MAP1_VERTEX_4 */
+       757, /* GL_MAP2_COLOR_4 */
+       760, /* GL_MAP2_INDEX */
+       761, /* GL_MAP2_NORMAL */
+       762, /* GL_MAP2_TEXTURE_COORD_1 */
+       763, /* GL_MAP2_TEXTURE_COORD_2 */
+       764, /* GL_MAP2_TEXTURE_COORD_3 */
+       765, /* GL_MAP2_TEXTURE_COORD_4 */
+       766, /* GL_MAP2_VERTEX_3 */
+       767, /* GL_MAP2_VERTEX_4 */
+       731, /* GL_MAP1_GRID_DOMAIN */
+       732, /* GL_MAP1_GRID_SEGMENTS */
+       758, /* GL_MAP2_GRID_DOMAIN */
+       759, /* GL_MAP2_GRID_SEGMENTS */
+      1585, /* GL_TEXTURE_1D */
+      1587, /* GL_TEXTURE_2D */
+       474, /* GL_FEEDBACK_BUFFER_POINTER */
+       475, /* GL_FEEDBACK_BUFFER_SIZE */
+       476, /* GL_FEEDBACK_BUFFER_TYPE */
+      1395, /* GL_SELECTION_BUFFER_POINTER */
+      1396, /* GL_SELECTION_BUFFER_SIZE */
+      1699, /* GL_TEXTURE_WIDTH */
+      1666, /* GL_TEXTURE_HEIGHT */
+      1622, /* GL_TEXTURE_COMPONENTS */
+      1606, /* GL_TEXTURE_BORDER_COLOR */
+      1605, /* GL_TEXTURE_BORDER */
+       378, /* GL_DONT_CARE */
+       472, /* GL_FASTEST */
+      1001, /* GL_NICEST */
         47, /* GL_AMBIENT */
-       373, /* GL_DIFFUSE */
-      1435, /* GL_SPECULAR */
-      1156, /* GL_POSITION */
-      1438, /* GL_SPOT_DIRECTION */
-      1439, /* GL_SPOT_EXPONENT */
-      1437, /* GL_SPOT_CUTOFF */
+       375, /* GL_DIFFUSE */
+      1443, /* GL_SPECULAR */
+      1164, /* GL_POSITION */
+      1446, /* GL_SPOT_DIRECTION */
+      1447, /* GL_SPOT_EXPONENT */
+      1445, /* GL_SPOT_CUTOFF */
        271, /* GL_CONSTANT_ATTENUATION */
-       678, /* GL_LINEAR_ATTENUATION */
-      1253, /* GL_QUADRATIC_ATTENUATION */
+       680, /* GL_LINEAR_ATTENUATION */
+      1261, /* GL_QUADRATIC_ATTENUATION */
        241, /* GL_COMPILE */
        242, /* GL_COMPILE_AND_EXECUTE */
        117, /* GL_BYTE */
-      1722, /* GL_UNSIGNED_BYTE */
-      1401, /* GL_SHORT */
-      1733, /* GL_UNSIGNED_SHORT */
-       629, /* GL_INT */
-      1725, /* GL_UNSIGNED_INT */
-       477, /* GL_FLOAT */
+      1730, /* GL_UNSIGNED_BYTE */
+      1409, /* GL_SHORT */
+      1741, /* GL_UNSIGNED_SHORT */
+       631, /* GL_INT */
+      1733, /* GL_UNSIGNED_INT */
+       479, /* GL_FLOAT */
          1, /* GL_2_BYTES */
          5, /* GL_3_BYTES */
          7, /* GL_4_BYTES */
-       383, /* GL_DOUBLE */
+       385, /* GL_DOUBLE */
        129, /* GL_CLEAR */
         49, /* GL_AND */
         51, /* GL_AND_REVERSE */
        295, /* GL_COPY */
         50, /* GL_AND_INVERTED */
-       995, /* GL_NOOP */
-      1814, /* GL_XOR */
-      1057, /* GL_OR */
-       996, /* GL_NOR */
-       460, /* GL_EQUIV */
-       656, /* GL_INVERT */
-      1060, /* GL_OR_REVERSE */
+      1003, /* GL_NOOP */
+      1822, /* GL_XOR */
+      1065, /* GL_OR */
+      1004, /* GL_NOR */
+       462, /* GL_EQUIV */
+       658, /* GL_INVERT */
+      1068, /* GL_OR_REVERSE */
        296, /* GL_COPY_INVERTED */
-      1059, /* GL_OR_INVERTED */
-       986, /* GL_NAND */
-      1392, /* GL_SET */
-       457, /* GL_EMISSION */
-      1400, /* GL_SHININESS */
+      1067, /* GL_OR_INVERTED */
+       994, /* GL_NAND */
+      1400, /* GL_SET */
+       459, /* GL_EMISSION */
+      1408, /* GL_SHININESS */
         48, /* GL_AMBIENT_AND_DIFFUSE */
        187, /* GL_COLOR_INDEXES */
-       936, /* GL_MODELVIEW */
-      1232, /* GL_PROJECTION */
-      1512, /* GL_TEXTURE */
+       944, /* GL_MODELVIEW */
+      1240, /* GL_PROJECTION */
+      1520, /* GL_TEXTURE */
        144, /* GL_COLOR */
-       340, /* GL_DEPTH */
-      1461, /* GL_STENCIL */
+       342, /* GL_DEPTH */
+      1469, /* GL_STENCIL */
        186, /* GL_COLOR_INDEX */
-      1480, /* GL_STENCIL_INDEX */
-       351, /* GL_DEPTH_COMPONENT */
-      1274, /* GL_RED */
-       584, /* GL_GREEN */
+      1488, /* GL_STENCIL_INDEX */
+       353, /* GL_DEPTH_COMPONENT */
+      1282, /* GL_RED */
+       586, /* GL_GREEN */
         89, /* GL_BLUE */
         31, /* GL_ALPHA */
-      1309, /* GL_RGB */
-      1328, /* GL_RGBA */
-       706, /* GL_LUMINANCE */
-       727, /* GL_LUMINANCE_ALPHA */
+      1317, /* GL_RGB */
+      1336, /* GL_RGBA */
+       708, /* GL_LUMINANCE */
+       729, /* GL_LUMINANCE_ALPHA */
         72, /* GL_BITMAP */
-      1112, /* GL_POINT */
-       676, /* GL_LINE */
-       475, /* GL_FILL */
-      1283, /* GL_RENDER */
-       471, /* GL_FEEDBACK */
-      1386, /* GL_SELECT */
-       476, /* GL_FLAT */
-      1410, /* GL_SMOOTH */
-       657, /* GL_KEEP */
-      1303, /* GL_REPLACE */
-       611, /* GL_INCR */
-       336, /* GL_DECR */
-      1748, /* GL_VENDOR */
-      1300, /* GL_RENDERER */
-      1749, /* GL_VERSION */
-       464, /* GL_EXTENSIONS */
-      1351, /* GL_S */
-      1503, /* GL_T */
-      1263, /* GL_R */
-      1252, /* GL_Q */
-       972, /* GL_MODULATE */
-       335, /* GL_DECAL */
-      1648, /* GL_TEXTURE_ENV_MODE */
-      1647, /* GL_TEXTURE_ENV_COLOR */
-      1646, /* GL_TEXTURE_ENV */
-       465, /* GL_EYE_LINEAR */
-      1019, /* GL_OBJECT_LINEAR */
-      1436, /* GL_SPHERE_MAP */
-      1650, /* GL_TEXTURE_GEN_MODE */
-      1021, /* GL_OBJECT_PLANE */
-       466, /* GL_EYE_PLANE */
-       987, /* GL_NEAREST */
-       677, /* GL_LINEAR */
-       991, /* GL_NEAREST_MIPMAP_NEAREST */
-       682, /* GL_LINEAR_MIPMAP_NEAREST */
-       990, /* GL_NEAREST_MIPMAP_LINEAR */
-       681, /* GL_LINEAR_MIPMAP_LINEAR */
-      1671, /* GL_TEXTURE_MAG_FILTER */
-      1679, /* GL_TEXTURE_MIN_FILTER */
-      1693, /* GL_TEXTURE_WRAP_S */
-      1694, /* GL_TEXTURE_WRAP_T */
+      1120, /* GL_POINT */
+       678, /* GL_LINE */
+       477, /* GL_FILL */
+      1291, /* GL_RENDER */
+       473, /* GL_FEEDBACK */
+      1394, /* GL_SELECT */
+       478, /* GL_FLAT */
+      1418, /* GL_SMOOTH */
+       659, /* GL_KEEP */
+      1311, /* GL_REPLACE */
+       613, /* GL_INCR */
+       338, /* GL_DECR */
+      1756, /* GL_VENDOR */
+      1308, /* GL_RENDERER */
+      1757, /* GL_VERSION */
+       466, /* GL_EXTENSIONS */
+      1359, /* GL_S */
+      1511, /* GL_T */
+      1271, /* GL_R */
+      1260, /* GL_Q */
+       980, /* GL_MODULATE */
+       337, /* GL_DECAL */
+      1656, /* GL_TEXTURE_ENV_MODE */
+      1655, /* GL_TEXTURE_ENV_COLOR */
+      1654, /* GL_TEXTURE_ENV */
+       467, /* GL_EYE_LINEAR */
+      1027, /* GL_OBJECT_LINEAR */
+      1444, /* GL_SPHERE_MAP */
+      1658, /* GL_TEXTURE_GEN_MODE */
+      1029, /* GL_OBJECT_PLANE */
+       468, /* GL_EYE_PLANE */
+       995, /* GL_NEAREST */
+       679, /* GL_LINEAR */
+       999, /* GL_NEAREST_MIPMAP_NEAREST */
+       684, /* GL_LINEAR_MIPMAP_NEAREST */
+       998, /* GL_NEAREST_MIPMAP_LINEAR */
+       683, /* GL_LINEAR_MIPMAP_LINEAR */
+      1679, /* GL_TEXTURE_MAG_FILTER */
+      1687, /* GL_TEXTURE_MIN_FILTER */
+      1701, /* GL_TEXTURE_WRAP_S */
+      1702, /* GL_TEXTURE_WRAP_T */
        123, /* GL_CLAMP */
-      1302, /* GL_REPEAT */
-      1150, /* GL_POLYGON_OFFSET_UNITS */
-      1149, /* GL_POLYGON_OFFSET_POINT */
-      1148, /* GL_POLYGON_OFFSET_LINE */
-      1264, /* GL_R3_G3_B2 */
-      1745, /* GL_V2F */
-      1746, /* GL_V3F */
+      1310, /* GL_REPEAT */
+      1158, /* GL_POLYGON_OFFSET_UNITS */
+      1157, /* GL_POLYGON_OFFSET_POINT */
+      1156, /* GL_POLYGON_OFFSET_LINE */
+      1272, /* GL_R3_G3_B2 */
+      1753, /* GL_V2F */
+      1754, /* GL_V3F */
        120, /* GL_C4UB_V2F */
        121, /* GL_C4UB_V3F */
        118, /* GL_C3F_V3F */
-       984, /* GL_N3F_V3F */
+       992, /* GL_N3F_V3F */
        119, /* GL_C4F_N3F_V3F */
-      1508, /* GL_T2F_V3F */
-      1510, /* GL_T4F_V4F */
-      1506, /* GL_T2F_C4UB_V3F */
-      1504, /* GL_T2F_C3F_V3F */
-      1507, /* GL_T2F_N3F_V3F */
-      1505, /* GL_T2F_C4F_N3F_V3F */
-      1509, /* GL_T4F_C4F_N3F_V4F */
+      1516, /* GL_T2F_V3F */
+      1518, /* GL_T4F_V4F */
+      1514, /* GL_T2F_C4UB_V3F */
+      1512, /* GL_T2F_C3F_V3F */
+      1515, /* GL_T2F_N3F_V3F */
+      1513, /* GL_T2F_C4F_N3F_V3F */
+      1517, /* GL_T4F_C4F_N3F_V4F */
        136, /* GL_CLIP_PLANE0 */
        137, /* GL_CLIP_PLANE1 */
        138, /* GL_CLIP_PLANE2 */
        139, /* GL_CLIP_PLANE3 */
        140, /* GL_CLIP_PLANE4 */
        141, /* GL_CLIP_PLANE5 */
-       661, /* GL_LIGHT0 */
-       662, /* GL_LIGHT1 */
-       663, /* GL_LIGHT2 */
-       664, /* GL_LIGHT3 */
-       665, /* GL_LIGHT4 */
-       666, /* GL_LIGHT5 */
-       667, /* GL_LIGHT6 */
-       668, /* GL_LIGHT7 */
-       588, /* GL_HINT_BIT */
+       663, /* GL_LIGHT0 */
+       664, /* GL_LIGHT1 */
+       665, /* GL_LIGHT2 */
+       666, /* GL_LIGHT3 */
+       667, /* GL_LIGHT4 */
+       668, /* GL_LIGHT5 */
+       669, /* GL_LIGHT6 */
+       670, /* GL_LIGHT7 */
+       590, /* GL_HINT_BIT */
        273, /* GL_CONSTANT_COLOR */
-      1031, /* GL_ONE_MINUS_CONSTANT_COLOR */
+      1039, /* GL_ONE_MINUS_CONSTANT_COLOR */
        268, /* GL_CONSTANT_ALPHA */
-      1029, /* GL_ONE_MINUS_CONSTANT_ALPHA */
+      1037, /* GL_ONE_MINUS_CONSTANT_ALPHA */
         75, /* GL_BLEND_COLOR */
-       572, /* GL_FUNC_ADD */
-       920, /* GL_MIN */
-       831, /* GL_MAX */
+       574, /* GL_FUNC_ADD */
+       928, /* GL_MIN */
+       839, /* GL_MAX */
         80, /* GL_BLEND_EQUATION */
-       576, /* GL_FUNC_SUBTRACT */
-       574, /* GL_FUNC_REVERSE_SUBTRACT */
+       578, /* GL_FUNC_SUBTRACT */
+       576, /* GL_FUNC_REVERSE_SUBTRACT */
        276, /* GL_CONVOLUTION_1D */
        277, /* GL_CONVOLUTION_2D */
-      1389, /* GL_SEPARABLE_2D */
+      1397, /* GL_SEPARABLE_2D */
        280, /* GL_CONVOLUTION_BORDER_MODE */
        284, /* GL_CONVOLUTION_FILTER_SCALE */
        282, /* GL_CONVOLUTION_FILTER_BIAS */
-      1275, /* GL_REDUCE */
+      1283, /* GL_REDUCE */
        286, /* GL_CONVOLUTION_FORMAT */
        290, /* GL_CONVOLUTION_WIDTH */
        288, /* GL_CONVOLUTION_HEIGHT */
-       846, /* GL_MAX_CONVOLUTION_WIDTH */
-       844, /* GL_MAX_CONVOLUTION_HEIGHT */
-      1189, /* GL_POST_CONVOLUTION_RED_SCALE */
-      1185, /* GL_POST_CONVOLUTION_GREEN_SCALE */
-      1180, /* GL_POST_CONVOLUTION_BLUE_SCALE */
-      1176, /* GL_POST_CONVOLUTION_ALPHA_SCALE */
-      1187, /* GL_POST_CONVOLUTION_RED_BIAS */
-      1183, /* GL_POST_CONVOLUTION_GREEN_BIAS */
-      1178, /* GL_POST_CONVOLUTION_BLUE_BIAS */
-      1174, /* GL_POST_CONVOLUTION_ALPHA_BIAS */
-       589, /* GL_HISTOGRAM */
-      1236, /* GL_PROXY_HISTOGRAM */
-       605, /* GL_HISTOGRAM_WIDTH */
-       595, /* GL_HISTOGRAM_FORMAT */
-       601, /* GL_HISTOGRAM_RED_SIZE */
-       597, /* GL_HISTOGRAM_GREEN_SIZE */
-       592, /* GL_HISTOGRAM_BLUE_SIZE */
-       590, /* GL_HISTOGRAM_ALPHA_SIZE */
-       599, /* GL_HISTOGRAM_LUMINANCE_SIZE */
-       603, /* GL_HISTOGRAM_SINK */
-       921, /* GL_MINMAX */
-       923, /* GL_MINMAX_FORMAT */
-       925, /* GL_MINMAX_SINK */
-      1511, /* GL_TABLE_TOO_LARGE_EXT */
-      1724, /* GL_UNSIGNED_BYTE_3_3_2 */
-      1735, /* GL_UNSIGNED_SHORT_4_4_4_4 */
-      1737, /* GL_UNSIGNED_SHORT_5_5_5_1 */
-      1730, /* GL_UNSIGNED_INT_8_8_8_8 */
-      1726, /* GL_UNSIGNED_INT_10_10_10_2 */
-      1147, /* GL_POLYGON_OFFSET_FILL */
-      1146, /* GL_POLYGON_OFFSET_FACTOR */
-      1145, /* GL_POLYGON_OFFSET_BIAS */
-      1306, /* GL_RESCALE_NORMAL */
+       854, /* GL_MAX_CONVOLUTION_WIDTH */
+       852, /* GL_MAX_CONVOLUTION_HEIGHT */
+      1197, /* GL_POST_CONVOLUTION_RED_SCALE */
+      1193, /* GL_POST_CONVOLUTION_GREEN_SCALE */
+      1188, /* GL_POST_CONVOLUTION_BLUE_SCALE */
+      1184, /* GL_POST_CONVOLUTION_ALPHA_SCALE */
+      1195, /* GL_POST_CONVOLUTION_RED_BIAS */
+      1191, /* GL_POST_CONVOLUTION_GREEN_BIAS */
+      1186, /* GL_POST_CONVOLUTION_BLUE_BIAS */
+      1182, /* GL_POST_CONVOLUTION_ALPHA_BIAS */
+       591, /* GL_HISTOGRAM */
+      1244, /* GL_PROXY_HISTOGRAM */
+       607, /* GL_HISTOGRAM_WIDTH */
+       597, /* GL_HISTOGRAM_FORMAT */
+       603, /* GL_HISTOGRAM_RED_SIZE */
+       599, /* GL_HISTOGRAM_GREEN_SIZE */
+       594, /* GL_HISTOGRAM_BLUE_SIZE */
+       592, /* GL_HISTOGRAM_ALPHA_SIZE */
+       601, /* GL_HISTOGRAM_LUMINANCE_SIZE */
+       605, /* GL_HISTOGRAM_SINK */
+       929, /* GL_MINMAX */
+       931, /* GL_MINMAX_FORMAT */
+       933, /* GL_MINMAX_SINK */
+      1519, /* GL_TABLE_TOO_LARGE_EXT */
+      1732, /* GL_UNSIGNED_BYTE_3_3_2 */
+      1743, /* GL_UNSIGNED_SHORT_4_4_4_4 */
+      1745, /* GL_UNSIGNED_SHORT_5_5_5_1 */
+      1738, /* GL_UNSIGNED_INT_8_8_8_8 */
+      1734, /* GL_UNSIGNED_INT_10_10_10_2 */
+      1155, /* GL_POLYGON_OFFSET_FILL */
+      1154, /* GL_POLYGON_OFFSET_FACTOR */
+      1153, /* GL_POLYGON_OFFSET_BIAS */
+      1314, /* GL_RESCALE_NORMAL */
         36, /* GL_ALPHA4 */
         38, /* GL_ALPHA8 */
         32, /* GL_ALPHA12 */
         34, /* GL_ALPHA16 */
-       717, /* GL_LUMINANCE4 */
-       723, /* GL_LUMINANCE8 */
-       707, /* GL_LUMINANCE12 */
-       713, /* GL_LUMINANCE16 */
-       718, /* GL_LUMINANCE4_ALPHA4 */
-       721, /* GL_LUMINANCE6_ALPHA2 */
-       724, /* GL_LUMINANCE8_ALPHA8 */
-       710, /* GL_LUMINANCE12_ALPHA4 */
-       708, /* GL_LUMINANCE12_ALPHA12 */
-       714, /* GL_LUMINANCE16_ALPHA16 */
-       630, /* GL_INTENSITY */
-       635, /* GL_INTENSITY4 */
-       637, /* GL_INTENSITY8 */
-       631, /* GL_INTENSITY12 */
-       633, /* GL_INTENSITY16 */
-      1318, /* GL_RGB2_EXT */
-      1319, /* GL_RGB4 */
-      1322, /* GL_RGB5 */
-      1326, /* GL_RGB8 */
-      1310, /* GL_RGB10 */
-      1314, /* GL_RGB12 */
-      1316, /* GL_RGB16 */
-      1333, /* GL_RGBA2 */
-      1335, /* GL_RGBA4 */
-      1323, /* GL_RGB5_A1 */
-      1339, /* GL_RGBA8 */
-      1311, /* GL_RGB10_A2 */
-      1329, /* GL_RGBA12 */
-      1331, /* GL_RGBA16 */
-      1684, /* GL_TEXTURE_RED_SIZE */
-      1656, /* GL_TEXTURE_GREEN_SIZE */
-      1595, /* GL_TEXTURE_BLUE_SIZE */
-      1582, /* GL_TEXTURE_ALPHA_SIZE */
-      1669, /* GL_TEXTURE_LUMINANCE_SIZE */
-      1660, /* GL_TEXTURE_INTENSITY_SIZE */
-      1304, /* GL_REPLACE_EXT */
-      1240, /* GL_PROXY_TEXTURE_1D */
-      1243, /* GL_PROXY_TEXTURE_2D */
-      1689, /* GL_TEXTURE_TOO_LARGE_EXT */
-      1681, /* GL_TEXTURE_PRIORITY */
-      1686, /* GL_TEXTURE_RESIDENT */
-      1585, /* GL_TEXTURE_BINDING_1D */
-      1587, /* GL_TEXTURE_BINDING_2D */
-      1589, /* GL_TEXTURE_BINDING_3D */
-      1067, /* GL_PACK_SKIP_IMAGES */
-      1063, /* GL_PACK_IMAGE_HEIGHT */
-      1718, /* GL_UNPACK_SKIP_IMAGES */
-      1715, /* GL_UNPACK_IMAGE_HEIGHT */
-      1581, /* GL_TEXTURE_3D */
-      1246, /* GL_PROXY_TEXTURE_3D */
-      1643, /* GL_TEXTURE_DEPTH */
-      1692, /* GL_TEXTURE_WRAP_R */
-       832, /* GL_MAX_3D_TEXTURE_SIZE */
-      1750, /* GL_VERTEX_ARRAY */
-       998, /* GL_NORMAL_ARRAY */
+       719, /* GL_LUMINANCE4 */
+       725, /* GL_LUMINANCE8 */
+       709, /* GL_LUMINANCE12 */
+       715, /* GL_LUMINANCE16 */
+       720, /* GL_LUMINANCE4_ALPHA4 */
+       723, /* GL_LUMINANCE6_ALPHA2 */
+       726, /* GL_LUMINANCE8_ALPHA8 */
+       712, /* GL_LUMINANCE12_ALPHA4 */
+       710, /* GL_LUMINANCE12_ALPHA12 */
+       716, /* GL_LUMINANCE16_ALPHA16 */
+       632, /* GL_INTENSITY */
+       637, /* GL_INTENSITY4 */
+       639, /* GL_INTENSITY8 */
+       633, /* GL_INTENSITY12 */
+       635, /* GL_INTENSITY16 */
+      1326, /* GL_RGB2_EXT */
+      1327, /* GL_RGB4 */
+      1330, /* GL_RGB5 */
+      1334, /* GL_RGB8 */
+      1318, /* GL_RGB10 */
+      1322, /* GL_RGB12 */
+      1324, /* GL_RGB16 */
+      1341, /* GL_RGBA2 */
+      1343, /* GL_RGBA4 */
+      1331, /* GL_RGB5_A1 */
+      1347, /* GL_RGBA8 */
+      1319, /* GL_RGB10_A2 */
+      1337, /* GL_RGBA12 */
+      1339, /* GL_RGBA16 */
+      1692, /* GL_TEXTURE_RED_SIZE */
+      1664, /* GL_TEXTURE_GREEN_SIZE */
+      1603, /* GL_TEXTURE_BLUE_SIZE */
+      1590, /* GL_TEXTURE_ALPHA_SIZE */
+      1677, /* GL_TEXTURE_LUMINANCE_SIZE */
+      1668, /* GL_TEXTURE_INTENSITY_SIZE */
+      1312, /* GL_REPLACE_EXT */
+      1248, /* GL_PROXY_TEXTURE_1D */
+      1251, /* GL_PROXY_TEXTURE_2D */
+      1697, /* GL_TEXTURE_TOO_LARGE_EXT */
+      1689, /* GL_TEXTURE_PRIORITY */
+      1694, /* GL_TEXTURE_RESIDENT */
+      1593, /* GL_TEXTURE_BINDING_1D */
+      1595, /* GL_TEXTURE_BINDING_2D */
+      1597, /* GL_TEXTURE_BINDING_3D */
+      1075, /* GL_PACK_SKIP_IMAGES */
+      1071, /* GL_PACK_IMAGE_HEIGHT */
+      1726, /* GL_UNPACK_SKIP_IMAGES */
+      1723, /* GL_UNPACK_IMAGE_HEIGHT */
+      1589, /* GL_TEXTURE_3D */
+      1254, /* GL_PROXY_TEXTURE_3D */
+      1651, /* GL_TEXTURE_DEPTH */
+      1700, /* GL_TEXTURE_WRAP_R */
+       840, /* GL_MAX_3D_TEXTURE_SIZE */
+      1758, /* GL_VERTEX_ARRAY */
+      1006, /* GL_NORMAL_ARRAY */
        145, /* GL_COLOR_ARRAY */
-       615, /* GL_INDEX_ARRAY */
-      1622, /* GL_TEXTURE_COORD_ARRAY */
-       449, /* GL_EDGE_FLAG_ARRAY */
-      1755, /* GL_VERTEX_ARRAY_SIZE */
-      1757, /* GL_VERTEX_ARRAY_TYPE */
-      1756, /* GL_VERTEX_ARRAY_STRIDE */
-      1003, /* GL_NORMAL_ARRAY_TYPE */
-      1002, /* GL_NORMAL_ARRAY_STRIDE */
+       617, /* GL_INDEX_ARRAY */
+      1630, /* GL_TEXTURE_COORD_ARRAY */
+       451, /* GL_EDGE_FLAG_ARRAY */
+      1763, /* GL_VERTEX_ARRAY_SIZE */
+      1765, /* GL_VERTEX_ARRAY_TYPE */
+      1764, /* GL_VERTEX_ARRAY_STRIDE */
+      1011, /* GL_NORMAL_ARRAY_TYPE */
+      1010, /* GL_NORMAL_ARRAY_STRIDE */
        149, /* GL_COLOR_ARRAY_SIZE */
        151, /* GL_COLOR_ARRAY_TYPE */
        150, /* GL_COLOR_ARRAY_STRIDE */
-       620, /* GL_INDEX_ARRAY_TYPE */
-       619, /* GL_INDEX_ARRAY_STRIDE */
-      1626, /* GL_TEXTURE_COORD_ARRAY_SIZE */
-      1628, /* GL_TEXTURE_COORD_ARRAY_TYPE */
-      1627, /* GL_TEXTURE_COORD_ARRAY_STRIDE */
-       453, /* GL_EDGE_FLAG_ARRAY_STRIDE */
-      1754, /* GL_VERTEX_ARRAY_POINTER */
-      1001, /* GL_NORMAL_ARRAY_POINTER */
+       622, /* GL_INDEX_ARRAY_TYPE */
+       621, /* GL_INDEX_ARRAY_STRIDE */
+      1634, /* GL_TEXTURE_COORD_ARRAY_SIZE */
+      1636, /* GL_TEXTURE_COORD_ARRAY_TYPE */
+      1635, /* GL_TEXTURE_COORD_ARRAY_STRIDE */
+       455, /* GL_EDGE_FLAG_ARRAY_STRIDE */
+      1762, /* GL_VERTEX_ARRAY_POINTER */
+      1009, /* GL_NORMAL_ARRAY_POINTER */
        148, /* GL_COLOR_ARRAY_POINTER */
-       618, /* GL_INDEX_ARRAY_POINTER */
-      1625, /* GL_TEXTURE_COORD_ARRAY_POINTER */
-       452, /* GL_EDGE_FLAG_ARRAY_POINTER */
-       977, /* GL_MULTISAMPLE */
-      1363, /* GL_SAMPLE_ALPHA_TO_COVERAGE */
-      1365, /* GL_SAMPLE_ALPHA_TO_ONE */
-      1370, /* GL_SAMPLE_COVERAGE */
-      1367, /* GL_SAMPLE_BUFFERS */
-      1358, /* GL_SAMPLES */
-      1374, /* GL_SAMPLE_COVERAGE_VALUE */
-      1372, /* GL_SAMPLE_COVERAGE_INVERT */
+       620, /* GL_INDEX_ARRAY_POINTER */
+      1633, /* GL_TEXTURE_COORD_ARRAY_POINTER */
+       454, /* GL_EDGE_FLAG_ARRAY_POINTER */
+       985, /* GL_MULTISAMPLE */
+      1371, /* GL_SAMPLE_ALPHA_TO_COVERAGE */
+      1373, /* GL_SAMPLE_ALPHA_TO_ONE */
+      1378, /* GL_SAMPLE_COVERAGE */
+      1375, /* GL_SAMPLE_BUFFERS */
+      1366, /* GL_SAMPLES */
+      1382, /* GL_SAMPLE_COVERAGE_VALUE */
+      1380, /* GL_SAMPLE_COVERAGE_INVERT */
        192, /* GL_COLOR_MATRIX */
        194, /* GL_COLOR_MATRIX_STACK_DEPTH */
-       840, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */
-      1172, /* GL_POST_COLOR_MATRIX_RED_SCALE */
-      1168, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */
-      1163, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */
-      1159, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */
-      1170, /* GL_POST_COLOR_MATRIX_RED_BIAS */
-      1166, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */
-      1161, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */
-      1157, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */
-      1605, /* GL_TEXTURE_COLOR_TABLE_SGI */
-      1247, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */
-      1607, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
+       848, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */
+      1180, /* GL_POST_COLOR_MATRIX_RED_SCALE */
+      1176, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */
+      1171, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */
+      1167, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */
+      1178, /* GL_POST_COLOR_MATRIX_RED_BIAS */
+      1174, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */
+      1169, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */
+      1165, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */
+      1613, /* GL_TEXTURE_COLOR_TABLE_SGI */
+      1255, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */
+      1615, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
         79, /* GL_BLEND_DST_RGB */
         88, /* GL_BLEND_SRC_RGB */
         78, /* GL_BLEND_DST_ALPHA */
         87, /* GL_BLEND_SRC_ALPHA */
        198, /* GL_COLOR_TABLE */
-      1182, /* GL_POST_CONVOLUTION_COLOR_TABLE */
-      1165, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */
-      1235, /* GL_PROXY_COLOR_TABLE */
-      1239, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */
-      1238, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */
+      1190, /* GL_POST_CONVOLUTION_COLOR_TABLE */
+      1173, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */
+      1243, /* GL_PROXY_COLOR_TABLE */
+      1247, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */
+      1246, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */
        222, /* GL_COLOR_TABLE_SCALE */
        202, /* GL_COLOR_TABLE_BIAS */
        207, /* GL_COLOR_TABLE_FORMAT */
@@ -4295,667 +4311,667 @@ static const unsigned reduced_enums[1319] =
        213, /* GL_COLOR_TABLE_INTENSITY_SIZE */
         70, /* GL_BGR */
         71, /* GL_BGRA */
-       854, /* GL_MAX_ELEMENTS_VERTICES */
-       853, /* GL_MAX_ELEMENTS_INDICES */
-      1659, /* GL_TEXTURE_INDEX_SIZE_EXT */
+       862, /* GL_MAX_ELEMENTS_VERTICES */
+       861, /* GL_MAX_ELEMENTS_INDICES */
+      1667, /* GL_TEXTURE_INDEX_SIZE_EXT */
        142, /* GL_CLIP_VOLUME_CLIPPING_HINT_EXT */
-      1129, /* GL_POINT_SIZE_MIN */
-      1125, /* GL_POINT_SIZE_MAX */
-      1119, /* GL_POINT_FADE_THRESHOLD_SIZE */
-      1115, /* GL_POINT_DISTANCE_ATTENUATION */
+      1137, /* GL_POINT_SIZE_MIN */
+      1133, /* GL_POINT_SIZE_MAX */
+      1127, /* GL_POINT_FADE_THRESHOLD_SIZE */
+      1123, /* GL_POINT_DISTANCE_ATTENUATION */
        124, /* GL_CLAMP_TO_BORDER */
        127, /* GL_CLAMP_TO_EDGE */
-      1680, /* GL_TEXTURE_MIN_LOD */
-      1678, /* GL_TEXTURE_MAX_LOD */
-      1584, /* GL_TEXTURE_BASE_LEVEL */
-      1677, /* GL_TEXTURE_MAX_LEVEL */
-       608, /* GL_IGNORE_BORDER_HP */
+      1688, /* GL_TEXTURE_MIN_LOD */
+      1686, /* GL_TEXTURE_MAX_LOD */
+      1592, /* GL_TEXTURE_BASE_LEVEL */
+      1685, /* GL_TEXTURE_MAX_LEVEL */
+       610, /* GL_IGNORE_BORDER_HP */
        272, /* GL_CONSTANT_BORDER_HP */
-      1305, /* GL_REPLICATE_BORDER_HP */
+      1313, /* GL_REPLICATE_BORDER_HP */
        278, /* GL_CONVOLUTION_BORDER_COLOR */
-      1026, /* GL_OCCLUSION_TEST_HP */
-      1027, /* GL_OCCLUSION_TEST_RESULT_HP */
-       679, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */
-      1599, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */
-      1601, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */
-      1603, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */
-      1604, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */
-      1602, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */
-      1600, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */
-       836, /* GL_MAX_CLIPMAP_DEPTH_SGIX */
-       837, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */
-      1192, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */
-      1194, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */
-      1191, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */
-      1193, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */
-      1667, /* GL_TEXTURE_LOD_BIAS_S_SGIX */
-      1668, /* GL_TEXTURE_LOD_BIAS_T_SGIX */
-      1666, /* GL_TEXTURE_LOD_BIAS_R_SGIX */
-       578, /* GL_GENERATE_MIPMAP */
-       579, /* GL_GENERATE_MIPMAP_HINT */
-       520, /* GL_FOG_OFFSET_SGIX */
-       521, /* GL_FOG_OFFSET_VALUE_SGIX */
-      1613, /* GL_TEXTURE_COMPARE_SGIX */
-      1612, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */
-      1663, /* GL_TEXTURE_LEQUAL_R_SGIX */
-      1655, /* GL_TEXTURE_GEQUAL_R_SGIX */
-       352, /* GL_DEPTH_COMPONENT16 */
-       355, /* GL_DEPTH_COMPONENT24 */
-       358, /* GL_DEPTH_COMPONENT32 */
-       300, /* GL_CULL_VERTEX_EXT */
-       302, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */
-       301, /* GL_CULL_VERTEX_EYE_POSITION_EXT */
-      1811, /* GL_WRAP_BORDER_SUN */
-      1606, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */
-       672, /* GL_LIGHT_MODEL_COLOR_CONTROL */
-      1403, /* GL_SINGLE_COLOR */
-      1390, /* GL_SEPARATE_SPECULAR_COLOR */
-      1399, /* GL_SHARED_TEXTURE_PALETTE_EXT */
-       531, /* GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */
-       532, /* GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */
-       539, /* GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */
-       534, /* GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */
-       530, /* GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */
-       529, /* GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */
-       533, /* GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */
-       540, /* GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */
-       551, /* GL_FRAMEBUFFER_DEFAULT */
-       564, /* GL_FRAMEBUFFER_UNDEFINED */
-       365, /* GL_DEPTH_STENCIL_ATTACHMENT */
-       614, /* GL_INDEX */
-      1723, /* GL_UNSIGNED_BYTE_2_3_3_REV */
-      1738, /* GL_UNSIGNED_SHORT_5_6_5 */
-      1739, /* GL_UNSIGNED_SHORT_5_6_5_REV */
-      1736, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */
-      1734, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */
-      1731, /* GL_UNSIGNED_INT_8_8_8_8_REV */
-      1729, /* GL_UNSIGNED_INT_2_10_10_10_REV */
-      1675, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */
-      1676, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */
-      1674, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */
-       928, /* GL_MIRRORED_REPEAT */
-      1346, /* GL_RGB_S3TC */
-      1321, /* GL_RGB4_S3TC */
-      1344, /* GL_RGBA_S3TC */
-      1338, /* GL_RGBA4_S3TC */
-      1342, /* GL_RGBA_DXT5_S3TC */
-      1336, /* GL_RGBA4_DXT5_S3TC */
+      1034, /* GL_OCCLUSION_TEST_HP */
+      1035, /* GL_OCCLUSION_TEST_RESULT_HP */
+       681, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */
+      1607, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */
+      1609, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */
+      1611, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */
+      1612, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */
+      1610, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */
+      1608, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */
+       844, /* GL_MAX_CLIPMAP_DEPTH_SGIX */
+       845, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */
+      1200, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */
+      1202, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */
+      1199, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */
+      1201, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */
+      1675, /* GL_TEXTURE_LOD_BIAS_S_SGIX */
+      1676, /* GL_TEXTURE_LOD_BIAS_T_SGIX */
+      1674, /* GL_TEXTURE_LOD_BIAS_R_SGIX */
+       580, /* GL_GENERATE_MIPMAP */
+       581, /* GL_GENERATE_MIPMAP_HINT */
+       522, /* GL_FOG_OFFSET_SGIX */
+       523, /* GL_FOG_OFFSET_VALUE_SGIX */
+      1621, /* GL_TEXTURE_COMPARE_SGIX */
+      1620, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */
+      1671, /* GL_TEXTURE_LEQUAL_R_SGIX */
+      1663, /* GL_TEXTURE_GEQUAL_R_SGIX */
+       354, /* GL_DEPTH_COMPONENT16 */
+       357, /* GL_DEPTH_COMPONENT24 */
+       360, /* GL_DEPTH_COMPONENT32 */
+       302, /* GL_CULL_VERTEX_EXT */
+       304, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */
+       303, /* GL_CULL_VERTEX_EYE_POSITION_EXT */
+      1819, /* GL_WRAP_BORDER_SUN */
+      1614, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */
+       674, /* GL_LIGHT_MODEL_COLOR_CONTROL */
+      1411, /* GL_SINGLE_COLOR */
+      1398, /* GL_SEPARATE_SPECULAR_COLOR */
+      1407, /* GL_SHARED_TEXTURE_PALETTE_EXT */
+       533, /* GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */
+       534, /* GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */
+       541, /* GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */
+       536, /* GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */
+       532, /* GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */
+       531, /* GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */
+       535, /* GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */
+       542, /* GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */
+       553, /* GL_FRAMEBUFFER_DEFAULT */
+       566, /* GL_FRAMEBUFFER_UNDEFINED */
+       367, /* GL_DEPTH_STENCIL_ATTACHMENT */
+       616, /* GL_INDEX */
+      1731, /* GL_UNSIGNED_BYTE_2_3_3_REV */
+      1746, /* GL_UNSIGNED_SHORT_5_6_5 */
+      1747, /* GL_UNSIGNED_SHORT_5_6_5_REV */
+      1744, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */
+      1742, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */
+      1739, /* GL_UNSIGNED_INT_8_8_8_8_REV */
+      1737, /* GL_UNSIGNED_INT_2_10_10_10_REV */
+      1683, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */
+      1684, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */
+      1682, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */
+       936, /* GL_MIRRORED_REPEAT */
+      1354, /* GL_RGB_S3TC */
+      1329, /* GL_RGB4_S3TC */
+      1352, /* GL_RGBA_S3TC */
+      1346, /* GL_RGBA4_S3TC */
+      1350, /* GL_RGBA_DXT5_S3TC */
+      1344, /* GL_RGBA4_DXT5_S3TC */
        261, /* GL_COMPRESSED_RGB_S3TC_DXT1_EXT */
        256, /* GL_COMPRESSED_RGBA_S3TC_DXT1_EXT */
        257, /* GL_COMPRESSED_RGBA_S3TC_DXT3_EXT */
        258, /* GL_COMPRESSED_RGBA_S3TC_DXT5_EXT */
-       989, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */
-       988, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */
-       680, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */
-       507, /* GL_FOG_COORDINATE_SOURCE */
-       499, /* GL_FOG_COORD */
-       523, /* GL_FRAGMENT_DEPTH */
-       306, /* GL_CURRENT_FOG_COORD */
-       506, /* GL_FOG_COORDINATE_ARRAY_TYPE */
-       505, /* GL_FOG_COORDINATE_ARRAY_STRIDE */
-       504, /* GL_FOG_COORDINATE_ARRAY_POINTER */
-       501, /* GL_FOG_COORDINATE_ARRAY */
+       997, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */
+       996, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */
+       682, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */
+       509, /* GL_FOG_COORDINATE_SOURCE */
+       501, /* GL_FOG_COORD */
+       525, /* GL_FRAGMENT_DEPTH */
+       308, /* GL_CURRENT_FOG_COORD */
+       508, /* GL_FOG_COORDINATE_ARRAY_TYPE */
+       507, /* GL_FOG_COORDINATE_ARRAY_STRIDE */
+       506, /* GL_FOG_COORDINATE_ARRAY_POINTER */
+       503, /* GL_FOG_COORDINATE_ARRAY */
        196, /* GL_COLOR_SUM */
-       326, /* GL_CURRENT_SECONDARY_COLOR */
-      1383, /* GL_SECONDARY_COLOR_ARRAY_SIZE */
-      1385, /* GL_SECONDARY_COLOR_ARRAY_TYPE */
-      1384, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */
-      1382, /* GL_SECONDARY_COLOR_ARRAY_POINTER */
-      1379, /* GL_SECONDARY_COLOR_ARRAY */
-       324, /* GL_CURRENT_RASTER_SECONDARY_COLOR */
+       328, /* GL_CURRENT_SECONDARY_COLOR */
+      1391, /* GL_SECONDARY_COLOR_ARRAY_SIZE */
+      1393, /* GL_SECONDARY_COLOR_ARRAY_TYPE */
+      1392, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */
+      1390, /* GL_SECONDARY_COLOR_ARRAY_POINTER */
+      1387, /* GL_SECONDARY_COLOR_ARRAY */
+       326, /* GL_CURRENT_RASTER_SECONDARY_COLOR */
         28, /* GL_ALIASED_POINT_SIZE_RANGE */
         27, /* GL_ALIASED_LINE_WIDTH_RANGE */
-      1513, /* GL_TEXTURE0 */
-      1515, /* GL_TEXTURE1 */
-      1537, /* GL_TEXTURE2 */
-      1559, /* GL_TEXTURE3 */
-      1565, /* GL_TEXTURE4 */
-      1567, /* GL_TEXTURE5 */
-      1569, /* GL_TEXTURE6 */
-      1571, /* GL_TEXTURE7 */
-      1573, /* GL_TEXTURE8 */
-      1575, /* GL_TEXTURE9 */
-      1516, /* GL_TEXTURE10 */
-      1518, /* GL_TEXTURE11 */
-      1520, /* GL_TEXTURE12 */
-      1522, /* GL_TEXTURE13 */
-      1524, /* GL_TEXTURE14 */
-      1526, /* GL_TEXTURE15 */
-      1528, /* GL_TEXTURE16 */
-      1530, /* GL_TEXTURE17 */
-      1532, /* GL_TEXTURE18 */
-      1534, /* GL_TEXTURE19 */
-      1538, /* GL_TEXTURE20 */
-      1540, /* GL_TEXTURE21 */
-      1542, /* GL_TEXTURE22 */
-      1544, /* GL_TEXTURE23 */
-      1546, /* GL_TEXTURE24 */
-      1548, /* GL_TEXTURE25 */
-      1550, /* GL_TEXTURE26 */
-      1552, /* GL_TEXTURE27 */
-      1554, /* GL_TEXTURE28 */
-      1556, /* GL_TEXTURE29 */
-      1560, /* GL_TEXTURE30 */
-      1562, /* GL_TEXTURE31 */
+      1521, /* GL_TEXTURE0 */
+      1523, /* GL_TEXTURE1 */
+      1545, /* GL_TEXTURE2 */
+      1567, /* GL_TEXTURE3 */
+      1573, /* GL_TEXTURE4 */
+      1575, /* GL_TEXTURE5 */
+      1577, /* GL_TEXTURE6 */
+      1579, /* GL_TEXTURE7 */
+      1581, /* GL_TEXTURE8 */
+      1583, /* GL_TEXTURE9 */
+      1524, /* GL_TEXTURE10 */
+      1526, /* GL_TEXTURE11 */
+      1528, /* GL_TEXTURE12 */
+      1530, /* GL_TEXTURE13 */
+      1532, /* GL_TEXTURE14 */
+      1534, /* GL_TEXTURE15 */
+      1536, /* GL_TEXTURE16 */
+      1538, /* GL_TEXTURE17 */
+      1540, /* GL_TEXTURE18 */
+      1542, /* GL_TEXTURE19 */
+      1546, /* GL_TEXTURE20 */
+      1548, /* GL_TEXTURE21 */
+      1550, /* GL_TEXTURE22 */
+      1552, /* GL_TEXTURE23 */
+      1554, /* GL_TEXTURE24 */
+      1556, /* GL_TEXTURE25 */
+      1558, /* GL_TEXTURE26 */
+      1560, /* GL_TEXTURE27 */
+      1562, /* GL_TEXTURE28 */
+      1564, /* GL_TEXTURE29 */
+      1568, /* GL_TEXTURE30 */
+      1570, /* GL_TEXTURE31 */
         18, /* GL_ACTIVE_TEXTURE */
        130, /* GL_CLIENT_ACTIVE_TEXTURE */
-       906, /* GL_MAX_TEXTURE_UNITS */
-      1702, /* GL_TRANSPOSE_MODELVIEW_MATRIX */
-      1705, /* GL_TRANSPOSE_PROJECTION_MATRIX */
-      1707, /* GL_TRANSPOSE_TEXTURE_MATRIX */
-      1699, /* GL_TRANSPOSE_COLOR_MATRIX */
-      1501, /* GL_SUBTRACT */
-       894, /* GL_MAX_RENDERBUFFER_SIZE_EXT */
+       914, /* GL_MAX_TEXTURE_UNITS */
+      1710, /* GL_TRANSPOSE_MODELVIEW_MATRIX */
+      1713, /* GL_TRANSPOSE_PROJECTION_MATRIX */
+      1715, /* GL_TRANSPOSE_TEXTURE_MATRIX */
+      1707, /* GL_TRANSPOSE_COLOR_MATRIX */
+      1509, /* GL_SUBTRACT */
+       902, /* GL_MAX_RENDERBUFFER_SIZE_EXT */
        244, /* GL_COMPRESSED_ALPHA */
        248, /* GL_COMPRESSED_LUMINANCE */
        249, /* GL_COMPRESSED_LUMINANCE_ALPHA */
        246, /* GL_COMPRESSED_INTENSITY */
        252, /* GL_COMPRESSED_RGB */
        253, /* GL_COMPRESSED_RGBA */
-      1620, /* GL_TEXTURE_COMPRESSION_HINT */
-      1682, /* GL_TEXTURE_RECTANGLE_ARB */
-      1592, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */
-      1250, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */
-       892, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */
-       364, /* GL_DEPTH_STENCIL */
-      1727, /* GL_UNSIGNED_INT_24_8 */
-       902, /* GL_MAX_TEXTURE_LOD_BIAS */
-      1673, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */
-       903, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */
-      1649, /* GL_TEXTURE_FILTER_CONTROL */
-      1664, /* GL_TEXTURE_LOD_BIAS */
+      1628, /* GL_TEXTURE_COMPRESSION_HINT */
+      1690, /* GL_TEXTURE_RECTANGLE_ARB */
+      1600, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */
+      1258, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */
+       900, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */
+       366, /* GL_DEPTH_STENCIL */
+      1735, /* GL_UNSIGNED_INT_24_8 */
+       910, /* GL_MAX_TEXTURE_LOD_BIAS */
+      1681, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */
+       911, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */
+      1657, /* GL_TEXTURE_FILTER_CONTROL */
+      1672, /* GL_TEXTURE_LOD_BIAS */
        229, /* GL_COMBINE4 */
-       896, /* GL_MAX_SHININESS_NV */
-       897, /* GL_MAX_SPOT_EXPONENT_NV */
-       612, /* GL_INCR_WRAP */
-       337, /* GL_DECR_WRAP */
-       948, /* GL_MODELVIEW1_ARB */
-      1004, /* GL_NORMAL_MAP */
-      1280, /* GL_REFLECTION_MAP */
-      1629, /* GL_TEXTURE_CUBE_MAP */
-      1590, /* GL_TEXTURE_BINDING_CUBE_MAP */
-      1637, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */
-      1631, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */
-      1639, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */
-      1633, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */
-      1641, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */
-      1635, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */
-      1248, /* GL_PROXY_TEXTURE_CUBE_MAP */
-       848, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */
-       983, /* GL_MULTISAMPLE_FILTER_HINT_NV */
-       515, /* GL_FOG_DISTANCE_MODE_NV */
-       468, /* GL_EYE_RADIAL_NV */
-       467, /* GL_EYE_PLANE_ABSOLUTE_NV */
+       904, /* GL_MAX_SHININESS_NV */
+       905, /* GL_MAX_SPOT_EXPONENT_NV */
+       614, /* GL_INCR_WRAP */
+       339, /* GL_DECR_WRAP */
+       956, /* GL_MODELVIEW1_ARB */
+      1012, /* GL_NORMAL_MAP */
+      1288, /* GL_REFLECTION_MAP */
+      1637, /* GL_TEXTURE_CUBE_MAP */
+      1598, /* GL_TEXTURE_BINDING_CUBE_MAP */
+      1645, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */
+      1639, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */
+      1647, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */
+      1641, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */
+      1649, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */
+      1643, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */
+      1256, /* GL_PROXY_TEXTURE_CUBE_MAP */
+       856, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */
+       991, /* GL_MULTISAMPLE_FILTER_HINT_NV */
+       517, /* GL_FOG_DISTANCE_MODE_NV */
+       470, /* GL_EYE_RADIAL_NV */
+       469, /* GL_EYE_PLANE_ABSOLUTE_NV */
        228, /* GL_COMBINE */
        235, /* GL_COMBINE_RGB */
        230, /* GL_COMBINE_ALPHA */
-      1347, /* GL_RGB_SCALE */
+      1355, /* GL_RGB_SCALE */
         24, /* GL_ADD_SIGNED */
-       640, /* GL_INTERPOLATE */
+       642, /* GL_INTERPOLATE */
        267, /* GL_CONSTANT */
-      1198, /* GL_PRIMARY_COLOR */
-      1195, /* GL_PREVIOUS */
-      1418, /* GL_SOURCE0_RGB */
-      1424, /* GL_SOURCE1_RGB */
-      1430, /* GL_SOURCE2_RGB */
-      1434, /* GL_SOURCE3_RGB_NV */
-      1415, /* GL_SOURCE0_ALPHA */
-      1421, /* GL_SOURCE1_ALPHA */
-      1427, /* GL_SOURCE2_ALPHA */
-      1433, /* GL_SOURCE3_ALPHA_NV */
-      1040, /* GL_OPERAND0_RGB */
-      1046, /* GL_OPERAND1_RGB */
-      1052, /* GL_OPERAND2_RGB */
-      1056, /* GL_OPERAND3_RGB_NV */
-      1037, /* GL_OPERAND0_ALPHA */
-      1043, /* GL_OPERAND1_ALPHA */
-      1049, /* GL_OPERAND2_ALPHA */
-      1055, /* GL_OPERAND3_ALPHA_NV */
-      1751, /* GL_VERTEX_ARRAY_BINDING_APPLE */
-      1815, /* GL_YCBCR_422_APPLE */
-      1740, /* GL_UNSIGNED_SHORT_8_8_APPLE */
-      1742, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */
-      1405, /* GL_SLICE_ACCUM_SUN */
-      1255, /* GL_QUAD_MESH_SUN */
-      1711, /* GL_TRIANGLE_MESH_SUN */
-      1789, /* GL_VERTEX_PROGRAM_ARB */
-      1800, /* GL_VERTEX_STATE_PROGRAM_NV */
-      1776, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */
-      1782, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */
-      1784, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */
-      1786, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */
-       328, /* GL_CURRENT_VERTEX_ATTRIB */
-      1211, /* GL_PROGRAM_LENGTH_ARB */
-      1225, /* GL_PROGRAM_STRING_ARB */
-       970, /* GL_MODELVIEW_PROJECTION_NV */
-       607, /* GL_IDENTITY_NV */
-       654, /* GL_INVERSE_NV */
-      1704, /* GL_TRANSPOSE_NV */
-       655, /* GL_INVERSE_TRANSPOSE_NV */
-       878, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */
-       877, /* GL_MAX_PROGRAM_MATRICES_ARB */
-       785, /* GL_MATRIX0_NV */
-       797, /* GL_MATRIX1_NV */
-       809, /* GL_MATRIX2_NV */
-       813, /* GL_MATRIX3_NV */
-       815, /* GL_MATRIX4_NV */
-       817, /* GL_MATRIX5_NV */
-       819, /* GL_MATRIX6_NV */
-       821, /* GL_MATRIX7_NV */
-       312, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */
-       309, /* GL_CURRENT_MATRIX_ARB */
-      1792, /* GL_VERTEX_PROGRAM_POINT_SIZE */
-      1795, /* GL_VERTEX_PROGRAM_TWO_SIDE */
-      1223, /* GL_PROGRAM_PARAMETER_NV */
-      1780, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */
-      1227, /* GL_PROGRAM_TARGET_NV */
-      1224, /* GL_PROGRAM_RESIDENT_NV */
-      1696, /* GL_TRACK_MATRIX_NV */
-      1697, /* GL_TRACK_MATRIX_TRANSFORM_NV */
-      1790, /* GL_VERTEX_PROGRAM_BINDING_NV */
-      1205, /* GL_PROGRAM_ERROR_POSITION_ARB */
-       349, /* GL_DEPTH_CLAMP_NV */
-      1758, /* GL_VERTEX_ATTRIB_ARRAY0_NV */
-      1765, /* GL_VERTEX_ATTRIB_ARRAY1_NV */
-      1766, /* GL_VERTEX_ATTRIB_ARRAY2_NV */
-      1767, /* GL_VERTEX_ATTRIB_ARRAY3_NV */
-      1768, /* GL_VERTEX_ATTRIB_ARRAY4_NV */
-      1769, /* GL_VERTEX_ATTRIB_ARRAY5_NV */
-      1770, /* GL_VERTEX_ATTRIB_ARRAY6_NV */
-      1771, /* GL_VERTEX_ATTRIB_ARRAY7_NV */
-      1772, /* GL_VERTEX_ATTRIB_ARRAY8_NV */
-      1773, /* GL_VERTEX_ATTRIB_ARRAY9_NV */
-      1759, /* GL_VERTEX_ATTRIB_ARRAY10_NV */
-      1760, /* GL_VERTEX_ATTRIB_ARRAY11_NV */
-      1761, /* GL_VERTEX_ATTRIB_ARRAY12_NV */
-      1762, /* GL_VERTEX_ATTRIB_ARRAY13_NV */
-      1763, /* GL_VERTEX_ATTRIB_ARRAY14_NV */
-      1764, /* GL_VERTEX_ATTRIB_ARRAY15_NV */
-       739, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */
-       746, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */
-       747, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */
-       748, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */
-       749, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */
-       750, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */
-       751, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */
-       752, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */
-       753, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */
-       754, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */
-       740, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */
-       741, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */
-       742, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */
-       743, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */
-       744, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */
-       745, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */
-       766, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */
-       773, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */
-       774, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */
-       775, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */
-       776, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */
-       777, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */
-       778, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */
-      1204, /* GL_PROGRAM_BINDING_ARB */
-       780, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */
-       781, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */
-       767, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */
-       768, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */
-       769, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */
-       770, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */
-       771, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */
-       772, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */
-      1618, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */
-      1615, /* GL_TEXTURE_COMPRESSED */
-      1009, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */
+      1206, /* GL_PRIMARY_COLOR */
+      1203, /* GL_PREVIOUS */
+      1426, /* GL_SOURCE0_RGB */
+      1432, /* GL_SOURCE1_RGB */
+      1438, /* GL_SOURCE2_RGB */
+      1442, /* GL_SOURCE3_RGB_NV */
+      1423, /* GL_SOURCE0_ALPHA */
+      1429, /* GL_SOURCE1_ALPHA */
+      1435, /* GL_SOURCE2_ALPHA */
+      1441, /* GL_SOURCE3_ALPHA_NV */
+      1048, /* GL_OPERAND0_RGB */
+      1054, /* GL_OPERAND1_RGB */
+      1060, /* GL_OPERAND2_RGB */
+      1064, /* GL_OPERAND3_RGB_NV */
+      1045, /* GL_OPERAND0_ALPHA */
+      1051, /* GL_OPERAND1_ALPHA */
+      1057, /* GL_OPERAND2_ALPHA */
+      1063, /* GL_OPERAND3_ALPHA_NV */
+      1759, /* GL_VERTEX_ARRAY_BINDING_APPLE */
+      1823, /* GL_YCBCR_422_APPLE */
+      1748, /* GL_UNSIGNED_SHORT_8_8_APPLE */
+      1750, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */
+      1413, /* GL_SLICE_ACCUM_SUN */
+      1263, /* GL_QUAD_MESH_SUN */
+      1719, /* GL_TRIANGLE_MESH_SUN */
+      1797, /* GL_VERTEX_PROGRAM_ARB */
+      1808, /* GL_VERTEX_STATE_PROGRAM_NV */
+      1784, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */
+      1790, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */
+      1792, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */
+      1794, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */
+       330, /* GL_CURRENT_VERTEX_ATTRIB */
+      1219, /* GL_PROGRAM_LENGTH_ARB */
+      1233, /* GL_PROGRAM_STRING_ARB */
+       978, /* GL_MODELVIEW_PROJECTION_NV */
+       609, /* GL_IDENTITY_NV */
+       656, /* GL_INVERSE_NV */
+      1712, /* GL_TRANSPOSE_NV */
+       657, /* GL_INVERSE_TRANSPOSE_NV */
+       886, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */
+       885, /* GL_MAX_PROGRAM_MATRICES_ARB */
+       793, /* GL_MATRIX0_NV */
+       805, /* GL_MATRIX1_NV */
+       817, /* GL_MATRIX2_NV */
+       821, /* GL_MATRIX3_NV */
+       823, /* GL_MATRIX4_NV */
+       825, /* GL_MATRIX5_NV */
+       827, /* GL_MATRIX6_NV */
+       829, /* GL_MATRIX7_NV */
+       314, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */
+       311, /* GL_CURRENT_MATRIX_ARB */
+      1800, /* GL_VERTEX_PROGRAM_POINT_SIZE */
+      1803, /* GL_VERTEX_PROGRAM_TWO_SIDE */
+      1231, /* GL_PROGRAM_PARAMETER_NV */
+      1788, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */
+      1235, /* GL_PROGRAM_TARGET_NV */
+      1232, /* GL_PROGRAM_RESIDENT_NV */
+      1704, /* GL_TRACK_MATRIX_NV */
+      1705, /* GL_TRACK_MATRIX_TRANSFORM_NV */
+      1798, /* GL_VERTEX_PROGRAM_BINDING_NV */
+      1213, /* GL_PROGRAM_ERROR_POSITION_ARB */
+       351, /* GL_DEPTH_CLAMP_NV */
+      1766, /* GL_VERTEX_ATTRIB_ARRAY0_NV */
+      1773, /* GL_VERTEX_ATTRIB_ARRAY1_NV */
+      1774, /* GL_VERTEX_ATTRIB_ARRAY2_NV */
+      1775, /* GL_VERTEX_ATTRIB_ARRAY3_NV */
+      1776, /* GL_VERTEX_ATTRIB_ARRAY4_NV */
+      1777, /* GL_VERTEX_ATTRIB_ARRAY5_NV */
+      1778, /* GL_VERTEX_ATTRIB_ARRAY6_NV */
+      1779, /* GL_VERTEX_ATTRIB_ARRAY7_NV */
+      1780, /* GL_VERTEX_ATTRIB_ARRAY8_NV */
+      1781, /* GL_VERTEX_ATTRIB_ARRAY9_NV */
+      1767, /* GL_VERTEX_ATTRIB_ARRAY10_NV */
+      1768, /* GL_VERTEX_ATTRIB_ARRAY11_NV */
+      1769, /* GL_VERTEX_ATTRIB_ARRAY12_NV */
+      1770, /* GL_VERTEX_ATTRIB_ARRAY13_NV */
+      1771, /* GL_VERTEX_ATTRIB_ARRAY14_NV */
+      1772, /* GL_VERTEX_ATTRIB_ARRAY15_NV */
+       741, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */
+       748, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */
+       749, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */
+       750, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */
+       751, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */
+       752, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */
+       753, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */
+       754, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */
+       755, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */
+       756, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */
+       742, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */
+       743, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */
+       744, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */
+       745, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */
+       746, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */
+       747, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */
+       768, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */
+       775, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */
+       776, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */
+       777, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */
+       778, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */
+       779, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */
+       780, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */
+      1212, /* GL_PROGRAM_BINDING_ARB */
+       782, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */
+       783, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */
+       769, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */
+       770, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */
+       771, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */
+       772, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */
+       773, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */
+       774, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */
+      1626, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */
+      1623, /* GL_TEXTURE_COMPRESSED */
+      1017, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */
        266, /* GL_COMPRESSED_TEXTURE_FORMATS */
-       918, /* GL_MAX_VERTEX_UNITS_ARB */
+       926, /* GL_MAX_VERTEX_UNITS_ARB */
         22, /* GL_ACTIVE_VERTEX_UNITS_ARB */
-      1810, /* GL_WEIGHT_SUM_UNITY_ARB */
-      1788, /* GL_VERTEX_BLEND_ARB */
-       330, /* GL_CURRENT_WEIGHT_ARB */
-      1809, /* GL_WEIGHT_ARRAY_TYPE_ARB */
-      1808, /* GL_WEIGHT_ARRAY_STRIDE_ARB */
-      1807, /* GL_WEIGHT_ARRAY_SIZE_ARB */
-      1806, /* GL_WEIGHT_ARRAY_POINTER_ARB */
-      1803, /* GL_WEIGHT_ARRAY_ARB */
-       377, /* GL_DOT3_RGB */
-       378, /* GL_DOT3_RGBA */
+      1818, /* GL_WEIGHT_SUM_UNITY_ARB */
+      1796, /* GL_VERTEX_BLEND_ARB */
+       332, /* GL_CURRENT_WEIGHT_ARB */
+      1817, /* GL_WEIGHT_ARRAY_TYPE_ARB */
+      1816, /* GL_WEIGHT_ARRAY_STRIDE_ARB */
+      1815, /* GL_WEIGHT_ARRAY_SIZE_ARB */
+      1814, /* GL_WEIGHT_ARRAY_POINTER_ARB */
+      1811, /* GL_WEIGHT_ARRAY_ARB */
+       379, /* GL_DOT3_RGB */
+       380, /* GL_DOT3_RGBA */
        260, /* GL_COMPRESSED_RGB_FXT1_3DFX */
        255, /* GL_COMPRESSED_RGBA_FXT1_3DFX */
-       978, /* GL_MULTISAMPLE_3DFX */
-      1368, /* GL_SAMPLE_BUFFERS_3DFX */
-      1359, /* GL_SAMPLES_3DFX */
-       959, /* GL_MODELVIEW2_ARB */
-       962, /* GL_MODELVIEW3_ARB */
-       963, /* GL_MODELVIEW4_ARB */
-       964, /* GL_MODELVIEW5_ARB */
-       965, /* GL_MODELVIEW6_ARB */
-       966, /* GL_MODELVIEW7_ARB */
-       967, /* GL_MODELVIEW8_ARB */
-       968, /* GL_MODELVIEW9_ARB */
-       938, /* GL_MODELVIEW10_ARB */
-       939, /* GL_MODELVIEW11_ARB */
-       940, /* GL_MODELVIEW12_ARB */
-       941, /* GL_MODELVIEW13_ARB */
-       942, /* GL_MODELVIEW14_ARB */
-       943, /* GL_MODELVIEW15_ARB */
-       944, /* GL_MODELVIEW16_ARB */
-       945, /* GL_MODELVIEW17_ARB */
-       946, /* GL_MODELVIEW18_ARB */
-       947, /* GL_MODELVIEW19_ARB */
-       949, /* GL_MODELVIEW20_ARB */
-       950, /* GL_MODELVIEW21_ARB */
-       951, /* GL_MODELVIEW22_ARB */
-       952, /* GL_MODELVIEW23_ARB */
-       953, /* GL_MODELVIEW24_ARB */
-       954, /* GL_MODELVIEW25_ARB */
-       955, /* GL_MODELVIEW26_ARB */
-       956, /* GL_MODELVIEW27_ARB */
-       957, /* GL_MODELVIEW28_ARB */
-       958, /* GL_MODELVIEW29_ARB */
-       960, /* GL_MODELVIEW30_ARB */
-       961, /* GL_MODELVIEW31_ARB */
-       382, /* GL_DOT3_RGB_EXT */
-       380, /* GL_DOT3_RGBA_EXT */
-       932, /* GL_MIRROR_CLAMP_EXT */
-       935, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */
-       973, /* GL_MODULATE_ADD_ATI */
-       974, /* GL_MODULATE_SIGNED_ADD_ATI */
-       975, /* GL_MODULATE_SUBTRACT_ATI */
-      1816, /* GL_YCBCR_MESA */
-      1064, /* GL_PACK_INVERT_MESA */
-       333, /* GL_DEBUG_OBJECT_MESA */
-       334, /* GL_DEBUG_PRINT_MESA */
-       332, /* GL_DEBUG_ASSERT_MESA */
+       986, /* GL_MULTISAMPLE_3DFX */
+      1376, /* GL_SAMPLE_BUFFERS_3DFX */
+      1367, /* GL_SAMPLES_3DFX */
+       967, /* GL_MODELVIEW2_ARB */
+       970, /* GL_MODELVIEW3_ARB */
+       971, /* GL_MODELVIEW4_ARB */
+       972, /* GL_MODELVIEW5_ARB */
+       973, /* GL_MODELVIEW6_ARB */
+       974, /* GL_MODELVIEW7_ARB */
+       975, /* GL_MODELVIEW8_ARB */
+       976, /* GL_MODELVIEW9_ARB */
+       946, /* GL_MODELVIEW10_ARB */
+       947, /* GL_MODELVIEW11_ARB */
+       948, /* GL_MODELVIEW12_ARB */
+       949, /* GL_MODELVIEW13_ARB */
+       950, /* GL_MODELVIEW14_ARB */
+       951, /* GL_MODELVIEW15_ARB */
+       952, /* GL_MODELVIEW16_ARB */
+       953, /* GL_MODELVIEW17_ARB */
+       954, /* GL_MODELVIEW18_ARB */
+       955, /* GL_MODELVIEW19_ARB */
+       957, /* GL_MODELVIEW20_ARB */
+       958, /* GL_MODELVIEW21_ARB */
+       959, /* GL_MODELVIEW22_ARB */
+       960, /* GL_MODELVIEW23_ARB */
+       961, /* GL_MODELVIEW24_ARB */
+       962, /* GL_MODELVIEW25_ARB */
+       963, /* GL_MODELVIEW26_ARB */
+       964, /* GL_MODELVIEW27_ARB */
+       965, /* GL_MODELVIEW28_ARB */
+       966, /* GL_MODELVIEW29_ARB */
+       968, /* GL_MODELVIEW30_ARB */
+       969, /* GL_MODELVIEW31_ARB */
+       384, /* GL_DOT3_RGB_EXT */
+       382, /* GL_DOT3_RGBA_EXT */
+       940, /* GL_MIRROR_CLAMP_EXT */
+       943, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */
+       981, /* GL_MODULATE_ADD_ATI */
+       982, /* GL_MODULATE_SIGNED_ADD_ATI */
+       983, /* GL_MODULATE_SUBTRACT_ATI */
+      1824, /* GL_YCBCR_MESA */
+      1072, /* GL_PACK_INVERT_MESA */
+       335, /* GL_DEBUG_OBJECT_MESA */
+       336, /* GL_DEBUG_PRINT_MESA */
+       334, /* GL_DEBUG_ASSERT_MESA */
        107, /* GL_BUFFER_SIZE */
        109, /* GL_BUFFER_USAGE */
        113, /* GL_BUMP_ROT_MATRIX_ATI */
        114, /* GL_BUMP_ROT_MATRIX_SIZE_ATI */
        112, /* GL_BUMP_NUM_TEX_UNITS_ATI */
        116, /* GL_BUMP_TEX_UNITS_ATI */
-       441, /* GL_DUDV_ATI */
-       440, /* GL_DU8DV8_ATI */
+       443, /* GL_DUDV_ATI */
+       442, /* GL_DU8DV8_ATI */
        111, /* GL_BUMP_ENVMAP_ATI */
        115, /* GL_BUMP_TARGET_ATI */
-      1466, /* GL_STENCIL_BACK_FUNC */
-      1464, /* GL_STENCIL_BACK_FAIL */
-      1468, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */
-      1470, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */
-       524, /* GL_FRAGMENT_PROGRAM_ARB */
-      1202, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */
-      1230, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */
-      1229, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */
-      1214, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
-      1220, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
-      1219, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
-       867, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */
-       890, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */
-       889, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */
-       880, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
-       886, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
-       885, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
-       850, /* GL_MAX_DRAW_BUFFERS */
-       386, /* GL_DRAW_BUFFER0 */
-       389, /* GL_DRAW_BUFFER1 */
-       410, /* GL_DRAW_BUFFER2 */
-       413, /* GL_DRAW_BUFFER3 */
-       416, /* GL_DRAW_BUFFER4 */
-       419, /* GL_DRAW_BUFFER5 */
-       422, /* GL_DRAW_BUFFER6 */
-       425, /* GL_DRAW_BUFFER7 */
-       428, /* GL_DRAW_BUFFER8 */
-       431, /* GL_DRAW_BUFFER9 */
-       390, /* GL_DRAW_BUFFER10 */
-       393, /* GL_DRAW_BUFFER11 */
-       396, /* GL_DRAW_BUFFER12 */
-       399, /* GL_DRAW_BUFFER13 */
-       402, /* GL_DRAW_BUFFER14 */
-       405, /* GL_DRAW_BUFFER15 */
+      1474, /* GL_STENCIL_BACK_FUNC */
+      1472, /* GL_STENCIL_BACK_FAIL */
+      1476, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */
+      1478, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */
+       526, /* GL_FRAGMENT_PROGRAM_ARB */
+      1210, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */
+      1238, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */
+      1237, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */
+      1222, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
+      1228, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
+      1227, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
+       875, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */
+       898, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */
+       897, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */
+       888, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
+       894, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
+       893, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
+       858, /* GL_MAX_DRAW_BUFFERS */
+       388, /* GL_DRAW_BUFFER0 */
+       391, /* GL_DRAW_BUFFER1 */
+       412, /* GL_DRAW_BUFFER2 */
+       415, /* GL_DRAW_BUFFER3 */
+       418, /* GL_DRAW_BUFFER4 */
+       421, /* GL_DRAW_BUFFER5 */
+       424, /* GL_DRAW_BUFFER6 */
+       427, /* GL_DRAW_BUFFER7 */
+       430, /* GL_DRAW_BUFFER8 */
+       433, /* GL_DRAW_BUFFER9 */
+       392, /* GL_DRAW_BUFFER10 */
+       395, /* GL_DRAW_BUFFER11 */
+       398, /* GL_DRAW_BUFFER12 */
+       401, /* GL_DRAW_BUFFER13 */
+       404, /* GL_DRAW_BUFFER14 */
+       407, /* GL_DRAW_BUFFER15 */
         81, /* GL_BLEND_EQUATION_ALPHA */
-       830, /* GL_MATRIX_PALETTE_ARB */
-       861, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */
-       864, /* GL_MAX_PALETTE_MATRICES_ARB */
-       315, /* GL_CURRENT_PALETTE_MATRIX_ARB */
-       824, /* GL_MATRIX_INDEX_ARRAY_ARB */
-       310, /* GL_CURRENT_MATRIX_INDEX_ARB */
-       826, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */
-       828, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */
-       827, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */
-       825, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */
-      1644, /* GL_TEXTURE_DEPTH_SIZE */
-       370, /* GL_DEPTH_TEXTURE_MODE */
-      1610, /* GL_TEXTURE_COMPARE_MODE */
-      1608, /* GL_TEXTURE_COMPARE_FUNC */
+       838, /* GL_MATRIX_PALETTE_ARB */
+       869, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */
+       872, /* GL_MAX_PALETTE_MATRICES_ARB */
+       317, /* GL_CURRENT_PALETTE_MATRIX_ARB */
+       832, /* GL_MATRIX_INDEX_ARRAY_ARB */
+       312, /* GL_CURRENT_MATRIX_INDEX_ARB */
+       834, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */
+       836, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */
+       835, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */
+       833, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */
+      1652, /* GL_TEXTURE_DEPTH_SIZE */
+       372, /* GL_DEPTH_TEXTURE_MODE */
+      1618, /* GL_TEXTURE_COMPARE_MODE */
+      1616, /* GL_TEXTURE_COMPARE_FUNC */
        239, /* GL_COMPARE_R_TO_TEXTURE */
-      1136, /* GL_POINT_SPRITE */
+      1144, /* GL_POINT_SPRITE */
        292, /* GL_COORD_REPLACE */
-      1140, /* GL_POINT_SPRITE_R_MODE_NV */
-      1257, /* GL_QUERY_COUNTER_BITS */
-       317, /* GL_CURRENT_QUERY */
-      1259, /* GL_QUERY_RESULT */
-      1261, /* GL_QUERY_RESULT_AVAILABLE */
-       912, /* GL_MAX_VERTEX_ATTRIBS */
-      1778, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */
-       368, /* GL_DEPTH_STENCIL_TO_RGBA_NV */
-       367, /* GL_DEPTH_STENCIL_TO_BGRA_NV */
-       898, /* GL_MAX_TEXTURE_COORDS */
-       900, /* GL_MAX_TEXTURE_IMAGE_UNITS */
-      1207, /* GL_PROGRAM_ERROR_STRING_ARB */
-      1209, /* GL_PROGRAM_FORMAT_ASCII_ARB */
-      1208, /* GL_PROGRAM_FORMAT_ARB */
-      1690, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */
-       347, /* GL_DEPTH_BOUNDS_TEST_EXT */
-       346, /* GL_DEPTH_BOUNDS_EXT */
+      1148, /* GL_POINT_SPRITE_R_MODE_NV */
+      1265, /* GL_QUERY_COUNTER_BITS */
+       319, /* GL_CURRENT_QUERY */
+      1267, /* GL_QUERY_RESULT */
+      1269, /* GL_QUERY_RESULT_AVAILABLE */
+       920, /* GL_MAX_VERTEX_ATTRIBS */
+      1786, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */
+       370, /* GL_DEPTH_STENCIL_TO_RGBA_NV */
+       369, /* GL_DEPTH_STENCIL_TO_BGRA_NV */
+       906, /* GL_MAX_TEXTURE_COORDS */
+       908, /* GL_MAX_TEXTURE_IMAGE_UNITS */
+      1215, /* GL_PROGRAM_ERROR_STRING_ARB */
+      1217, /* GL_PROGRAM_FORMAT_ASCII_ARB */
+      1216, /* GL_PROGRAM_FORMAT_ARB */
+      1698, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */
+       349, /* GL_DEPTH_BOUNDS_TEST_EXT */
+       348, /* GL_DEPTH_BOUNDS_EXT */
         52, /* GL_ARRAY_BUFFER */
-       454, /* GL_ELEMENT_ARRAY_BUFFER */
+       456, /* GL_ELEMENT_ARRAY_BUFFER */
         53, /* GL_ARRAY_BUFFER_BINDING */
-       455, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */
-      1752, /* GL_VERTEX_ARRAY_BUFFER_BINDING */
-       999, /* GL_NORMAL_ARRAY_BUFFER_BINDING */
+       457, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */
+      1760, /* GL_VERTEX_ARRAY_BUFFER_BINDING */
+      1007, /* GL_NORMAL_ARRAY_BUFFER_BINDING */
        146, /* GL_COLOR_ARRAY_BUFFER_BINDING */
-       616, /* GL_INDEX_ARRAY_BUFFER_BINDING */
-      1623, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */
-       450, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */
-      1380, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */
-       502, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */
-      1804, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */
-      1774, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */
-      1210, /* GL_PROGRAM_INSTRUCTIONS_ARB */
-       873, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */
-      1216, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
-       882, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
-      1228, /* GL_PROGRAM_TEMPORARIES_ARB */
-       888, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */
-      1218, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */
-       884, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */
-      1222, /* GL_PROGRAM_PARAMETERS_ARB */
-       887, /* GL_MAX_PROGRAM_PARAMETERS_ARB */
-      1217, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */
-       883, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */
-      1203, /* GL_PROGRAM_ATTRIBS_ARB */
-       868, /* GL_MAX_PROGRAM_ATTRIBS_ARB */
-      1215, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */
-       881, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */
-      1201, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */
-       866, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */
-      1213, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
-       879, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
-       874, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */
-       870, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */
-      1231, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */
-      1701, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */
-      1270, /* GL_READ_ONLY */
-      1812, /* GL_WRITE_ONLY */
-      1272, /* GL_READ_WRITE */
+       618, /* GL_INDEX_ARRAY_BUFFER_BINDING */
+      1631, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */
+       452, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */
+      1388, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */
+       504, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */
+      1812, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */
+      1782, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */
+      1218, /* GL_PROGRAM_INSTRUCTIONS_ARB */
+       881, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */
+      1224, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
+       890, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
+      1236, /* GL_PROGRAM_TEMPORARIES_ARB */
+       896, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */
+      1226, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */
+       892, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */
+      1230, /* GL_PROGRAM_PARAMETERS_ARB */
+       895, /* GL_MAX_PROGRAM_PARAMETERS_ARB */
+      1225, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */
+       891, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */
+      1211, /* GL_PROGRAM_ATTRIBS_ARB */
+       876, /* GL_MAX_PROGRAM_ATTRIBS_ARB */
+      1223, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */
+       889, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */
+      1209, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */
+       874, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */
+      1221, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
+       887, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
+       882, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */
+       878, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */
+      1239, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */
+      1709, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */
+      1278, /* GL_READ_ONLY */
+      1820, /* GL_WRITE_ONLY */
+      1280, /* GL_READ_WRITE */
        101, /* GL_BUFFER_ACCESS */
        103, /* GL_BUFFER_MAPPED */
        105, /* GL_BUFFER_MAP_POINTER */
-      1695, /* GL_TIME_ELAPSED_EXT */
-       784, /* GL_MATRIX0_ARB */
-       796, /* GL_MATRIX1_ARB */
-       808, /* GL_MATRIX2_ARB */
-       812, /* GL_MATRIX3_ARB */
-       814, /* GL_MATRIX4_ARB */
-       816, /* GL_MATRIX5_ARB */
-       818, /* GL_MATRIX6_ARB */
-       820, /* GL_MATRIX7_ARB */
-       822, /* GL_MATRIX8_ARB */
-       823, /* GL_MATRIX9_ARB */
-       786, /* GL_MATRIX10_ARB */
-       787, /* GL_MATRIX11_ARB */
-       788, /* GL_MATRIX12_ARB */
-       789, /* GL_MATRIX13_ARB */
-       790, /* GL_MATRIX14_ARB */
-       791, /* GL_MATRIX15_ARB */
-       792, /* GL_MATRIX16_ARB */
-       793, /* GL_MATRIX17_ARB */
-       794, /* GL_MATRIX18_ARB */
-       795, /* GL_MATRIX19_ARB */
-       798, /* GL_MATRIX20_ARB */
-       799, /* GL_MATRIX21_ARB */
-       800, /* GL_MATRIX22_ARB */
-       801, /* GL_MATRIX23_ARB */
-       802, /* GL_MATRIX24_ARB */
-       803, /* GL_MATRIX25_ARB */
-       804, /* GL_MATRIX26_ARB */
-       805, /* GL_MATRIX27_ARB */
-       806, /* GL_MATRIX28_ARB */
-       807, /* GL_MATRIX29_ARB */
-       810, /* GL_MATRIX30_ARB */
-       811, /* GL_MATRIX31_ARB */
-      1496, /* GL_STREAM_DRAW */
-      1498, /* GL_STREAM_READ */
-      1494, /* GL_STREAM_COPY */
-      1457, /* GL_STATIC_DRAW */
-      1459, /* GL_STATIC_READ */
-      1455, /* GL_STATIC_COPY */
-       444, /* GL_DYNAMIC_DRAW */
-       446, /* GL_DYNAMIC_READ */
-       442, /* GL_DYNAMIC_COPY */
-      1104, /* GL_PIXEL_PACK_BUFFER */
-      1108, /* GL_PIXEL_UNPACK_BUFFER */
-      1105, /* GL_PIXEL_PACK_BUFFER_BINDING */
-      1109, /* GL_PIXEL_UNPACK_BUFFER_BINDING */
-       341, /* GL_DEPTH24_STENCIL8 */
-      1688, /* GL_TEXTURE_STENCIL_SIZE */
-       871, /* GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */
-       869, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */
-       872, /* GL_MAX_PROGRAM_IF_DEPTH_NV */
-       876, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */
-       875, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */
-       833, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */
-      1490, /* GL_STENCIL_TEST_TWO_SIDE_EXT */
+      1703, /* GL_TIME_ELAPSED_EXT */
+       792, /* GL_MATRIX0_ARB */
+       804, /* GL_MATRIX1_ARB */
+       816, /* GL_MATRIX2_ARB */
+       820, /* GL_MATRIX3_ARB */
+       822, /* GL_MATRIX4_ARB */
+       824, /* GL_MATRIX5_ARB */
+       826, /* GL_MATRIX6_ARB */
+       828, /* GL_MATRIX7_ARB */
+       830, /* GL_MATRIX8_ARB */
+       831, /* GL_MATRIX9_ARB */
+       794, /* GL_MATRIX10_ARB */
+       795, /* GL_MATRIX11_ARB */
+       796, /* GL_MATRIX12_ARB */
+       797, /* GL_MATRIX13_ARB */
+       798, /* GL_MATRIX14_ARB */
+       799, /* GL_MATRIX15_ARB */
+       800, /* GL_MATRIX16_ARB */
+       801, /* GL_MATRIX17_ARB */
+       802, /* GL_MATRIX18_ARB */
+       803, /* GL_MATRIX19_ARB */
+       806, /* GL_MATRIX20_ARB */
+       807, /* GL_MATRIX21_ARB */
+       808, /* GL_MATRIX22_ARB */
+       809, /* GL_MATRIX23_ARB */
+       810, /* GL_MATRIX24_ARB */
+       811, /* GL_MATRIX25_ARB */
+       812, /* GL_MATRIX26_ARB */
+       813, /* GL_MATRIX27_ARB */
+       814, /* GL_MATRIX28_ARB */
+       815, /* GL_MATRIX29_ARB */
+       818, /* GL_MATRIX30_ARB */
+       819, /* GL_MATRIX31_ARB */
+      1504, /* GL_STREAM_DRAW */
+      1506, /* GL_STREAM_READ */
+      1502, /* GL_STREAM_COPY */
+      1465, /* GL_STATIC_DRAW */
+      1467, /* GL_STATIC_READ */
+      1463, /* GL_STATIC_COPY */
+       446, /* GL_DYNAMIC_DRAW */
+       448, /* GL_DYNAMIC_READ */
+       444, /* GL_DYNAMIC_COPY */
+      1112, /* GL_PIXEL_PACK_BUFFER */
+      1116, /* GL_PIXEL_UNPACK_BUFFER */
+      1113, /* GL_PIXEL_PACK_BUFFER_BINDING */
+      1117, /* GL_PIXEL_UNPACK_BUFFER_BINDING */
+       343, /* GL_DEPTH24_STENCIL8 */
+      1696, /* GL_TEXTURE_STENCIL_SIZE */
+       879, /* GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */
+       877, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */
+       880, /* GL_MAX_PROGRAM_IF_DEPTH_NV */
+       884, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */
+       883, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */
+       841, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */
+      1498, /* GL_STENCIL_TEST_TWO_SIDE_EXT */
         17, /* GL_ACTIVE_STENCIL_FACE_EXT */
-       933, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */
-      1361, /* GL_SAMPLES_PASSED */
-       525, /* GL_FRAGMENT_SHADER */
-      1798, /* GL_VERTEX_SHADER */
-      1221, /* GL_PROGRAM_OBJECT_ARB */
-      1393, /* GL_SHADER_OBJECT_ARB */
-       857, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */
-       916, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */
-       910, /* GL_MAX_VARYING_FLOATS */
-       914, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */
-       842, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */
-      1024, /* GL_OBJECT_TYPE_ARB */
-      1395, /* GL_SHADER_TYPE */
-       490, /* GL_FLOAT_VEC2 */
-       492, /* GL_FLOAT_VEC3 */
-       494, /* GL_FLOAT_VEC4 */
-       643, /* GL_INT_VEC2 */
-       645, /* GL_INT_VEC3 */
-       647, /* GL_INT_VEC4 */
+       941, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */
+      1369, /* GL_SAMPLES_PASSED */
+       527, /* GL_FRAGMENT_SHADER */
+      1806, /* GL_VERTEX_SHADER */
+      1229, /* GL_PROGRAM_OBJECT_ARB */
+      1401, /* GL_SHADER_OBJECT_ARB */
+       865, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */
+       924, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */
+       918, /* GL_MAX_VARYING_FLOATS */
+       922, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */
+       850, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */
+      1032, /* GL_OBJECT_TYPE_ARB */
+      1403, /* GL_SHADER_TYPE */
+       492, /* GL_FLOAT_VEC2 */
+       494, /* GL_FLOAT_VEC3 */
+       496, /* GL_FLOAT_VEC4 */
+       645, /* GL_INT_VEC2 */
+       647, /* GL_INT_VEC3 */
+       649, /* GL_INT_VEC4 */
         93, /* GL_BOOL */
         95, /* GL_BOOL_VEC2 */
         97, /* GL_BOOL_VEC3 */
         99, /* GL_BOOL_VEC4 */
-       478, /* GL_FLOAT_MAT2 */
-       482, /* GL_FLOAT_MAT3 */
-       486, /* GL_FLOAT_MAT4 */
-      1352, /* GL_SAMPLER_1D */
-      1354, /* GL_SAMPLER_2D */
-      1356, /* GL_SAMPLER_3D */
-      1357, /* GL_SAMPLER_CUBE */
-      1353, /* GL_SAMPLER_1D_SHADOW */
-      1355, /* GL_SAMPLER_2D_SHADOW */
-       480, /* GL_FLOAT_MAT2x3 */
-       481, /* GL_FLOAT_MAT2x4 */
-       484, /* GL_FLOAT_MAT3x2 */
-       485, /* GL_FLOAT_MAT3x4 */
-       488, /* GL_FLOAT_MAT4x2 */
-       489, /* GL_FLOAT_MAT4x3 */
-       339, /* GL_DELETE_STATUS */
+       480, /* GL_FLOAT_MAT2 */
+       484, /* GL_FLOAT_MAT3 */
+       488, /* GL_FLOAT_MAT4 */
+      1360, /* GL_SAMPLER_1D */
+      1362, /* GL_SAMPLER_2D */
+      1364, /* GL_SAMPLER_3D */
+      1365, /* GL_SAMPLER_CUBE */
+      1361, /* GL_SAMPLER_1D_SHADOW */
+      1363, /* GL_SAMPLER_2D_SHADOW */
+       482, /* GL_FLOAT_MAT2x3 */
+       483, /* GL_FLOAT_MAT2x4 */
+       486, /* GL_FLOAT_MAT3x2 */
+       487, /* GL_FLOAT_MAT3x4 */
+       490, /* GL_FLOAT_MAT4x2 */
+       491, /* GL_FLOAT_MAT4x3 */
+       341, /* GL_DELETE_STATUS */
        243, /* GL_COMPILE_STATUS */
-       697, /* GL_LINK_STATUS */
-      1747, /* GL_VALIDATE_STATUS */
-       628, /* GL_INFO_LOG_LENGTH */
+       699, /* GL_LINK_STATUS */
+      1755, /* GL_VALIDATE_STATUS */
+       630, /* GL_INFO_LOG_LENGTH */
         55, /* GL_ATTACHED_SHADERS */
         20, /* GL_ACTIVE_UNIFORMS */
         21, /* GL_ACTIVE_UNIFORM_MAX_LENGTH */
-      1394, /* GL_SHADER_SOURCE_LENGTH */
+      1402, /* GL_SHADER_SOURCE_LENGTH */
         15, /* GL_ACTIVE_ATTRIBUTES */
         16, /* GL_ACTIVE_ATTRIBUTE_MAX_LENGTH */
-       527, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */
-      1397, /* GL_SHADING_LANGUAGE_VERSION */
-       316, /* GL_CURRENT_PROGRAM */
-      1073, /* GL_PALETTE4_RGB8_OES */
-      1075, /* GL_PALETTE4_RGBA8_OES */
-      1071, /* GL_PALETTE4_R5_G6_B5_OES */
-      1074, /* GL_PALETTE4_RGBA4_OES */
-      1072, /* GL_PALETTE4_RGB5_A1_OES */
-      1078, /* GL_PALETTE8_RGB8_OES */
-      1080, /* GL_PALETTE8_RGBA8_OES */
-      1076, /* GL_PALETTE8_R5_G6_B5_OES */
-      1079, /* GL_PALETTE8_RGBA4_OES */
-      1077, /* GL_PALETTE8_RGB5_A1_OES */
-       610, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */
-       609, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */
-      1732, /* GL_UNSIGNED_NORMALIZED */
-      1578, /* GL_TEXTURE_1D_ARRAY_EXT */
-      1241, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */
-      1580, /* GL_TEXTURE_2D_ARRAY_EXT */
-      1244, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */
-      1586, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */
-      1588, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */
-      1449, /* GL_SRGB */
-      1450, /* GL_SRGB8 */
-      1452, /* GL_SRGB_ALPHA */
-      1451, /* GL_SRGB8_ALPHA8 */
-      1409, /* GL_SLUMINANCE_ALPHA */
-      1408, /* GL_SLUMINANCE8_ALPHA8 */
-      1406, /* GL_SLUMINANCE */
-      1407, /* GL_SLUMINANCE8 */
+       529, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */
+      1405, /* GL_SHADING_LANGUAGE_VERSION */
+       318, /* GL_CURRENT_PROGRAM */
+      1081, /* GL_PALETTE4_RGB8_OES */
+      1083, /* GL_PALETTE4_RGBA8_OES */
+      1079, /* GL_PALETTE4_R5_G6_B5_OES */
+      1082, /* GL_PALETTE4_RGBA4_OES */
+      1080, /* GL_PALETTE4_RGB5_A1_OES */
+      1086, /* GL_PALETTE8_RGB8_OES */
+      1088, /* GL_PALETTE8_RGBA8_OES */
+      1084, /* GL_PALETTE8_R5_G6_B5_OES */
+      1087, /* GL_PALETTE8_RGBA4_OES */
+      1085, /* GL_PALETTE8_RGB5_A1_OES */
+       612, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */
+       611, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */
+      1740, /* GL_UNSIGNED_NORMALIZED */
+      1586, /* GL_TEXTURE_1D_ARRAY_EXT */
+      1249, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */
+      1588, /* GL_TEXTURE_2D_ARRAY_EXT */
+      1252, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */
+      1594, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */
+      1596, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */
+      1457, /* GL_SRGB */
+      1458, /* GL_SRGB8 */
+      1460, /* GL_SRGB_ALPHA */
+      1459, /* GL_SRGB8_ALPHA8 */
+      1417, /* GL_SLUMINANCE_ALPHA */
+      1416, /* GL_SLUMINANCE8_ALPHA8 */
+      1414, /* GL_SLUMINANCE */
+      1415, /* GL_SLUMINANCE8 */
        264, /* GL_COMPRESSED_SRGB */
        265, /* GL_COMPRESSED_SRGB_ALPHA */
        262, /* GL_COMPRESSED_SLUMINANCE */
        263, /* GL_COMPRESSED_SLUMINANCE_ALPHA */
-      1138, /* GL_POINT_SPRITE_COORD_ORIGIN */
-       705, /* GL_LOWER_LEFT */
-      1744, /* GL_UPPER_LEFT */
-      1472, /* GL_STENCIL_BACK_REF */
-      1473, /* GL_STENCIL_BACK_VALUE_MASK */
-      1474, /* GL_STENCIL_BACK_WRITEMASK */
-       435, /* GL_DRAW_FRAMEBUFFER_BINDING_EXT */
-      1286, /* GL_RENDERBUFFER_BINDING_EXT */
-      1267, /* GL_READ_FRAMEBUFFER */
-       434, /* GL_DRAW_FRAMEBUFFER */
-      1268, /* GL_READ_FRAMEBUFFER_BINDING_EXT */
-      1296, /* GL_RENDERBUFFER_SAMPLES */
-       537, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */
-       535, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */
-       546, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */
-       542, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */
-       544, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */
-       549, /* GL_FRAMEBUFFER_COMPLETE */
-       553, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */
-       559, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */
-       557, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */
-       555, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */
-       558, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */
-       556, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT */
-       562, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT */
-       565, /* GL_FRAMEBUFFER_UNSUPPORTED */
-       563, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */
-       839, /* GL_MAX_COLOR_ATTACHMENTS_EXT */
+      1146, /* GL_POINT_SPRITE_COORD_ORIGIN */
+       707, /* GL_LOWER_LEFT */
+      1752, /* GL_UPPER_LEFT */
+      1480, /* GL_STENCIL_BACK_REF */
+      1481, /* GL_STENCIL_BACK_VALUE_MASK */
+      1482, /* GL_STENCIL_BACK_WRITEMASK */
+       437, /* GL_DRAW_FRAMEBUFFER_BINDING_EXT */
+      1294, /* GL_RENDERBUFFER_BINDING_EXT */
+      1275, /* GL_READ_FRAMEBUFFER */
+       436, /* GL_DRAW_FRAMEBUFFER */
+      1276, /* GL_READ_FRAMEBUFFER_BINDING_EXT */
+      1304, /* GL_RENDERBUFFER_SAMPLES */
+       539, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */
+       537, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */
+       548, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */
+       544, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */
+       546, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */
+       551, /* GL_FRAMEBUFFER_COMPLETE */
+       555, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */
+       561, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */
+       559, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */
+       557, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */
+       560, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */
+       558, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT */
+       564, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT */
+       567, /* GL_FRAMEBUFFER_UNSUPPORTED */
+       565, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */
+       847, /* GL_MAX_COLOR_ATTACHMENTS_EXT */
        152, /* GL_COLOR_ATTACHMENT0 */
        154, /* GL_COLOR_ATTACHMENT1 */
        168, /* GL_COLOR_ATTACHMENT2 */
@@ -4972,36 +4988,38 @@ static const unsigned reduced_enums[1319] =
        161, /* GL_COLOR_ATTACHMENT13 */
        163, /* GL_COLOR_ATTACHMENT14 */
        165, /* GL_COLOR_ATTACHMENT15 */
-       342, /* GL_DEPTH_ATTACHMENT */
-      1462, /* GL_STENCIL_ATTACHMENT */
-       528, /* GL_FRAMEBUFFER */
-      1284, /* GL_RENDERBUFFER */
-      1298, /* GL_RENDERBUFFER_WIDTH */
-      1291, /* GL_RENDERBUFFER_HEIGHT */
-      1293, /* GL_RENDERBUFFER_INTERNAL_FORMAT */
-      1485, /* GL_STENCIL_INDEX_EXT */
-      1482, /* GL_STENCIL_INDEX1_EXT */
-      1483, /* GL_STENCIL_INDEX4_EXT */
-      1484, /* GL_STENCIL_INDEX8_EXT */
-      1481, /* GL_STENCIL_INDEX16_EXT */
-      1295, /* GL_RENDERBUFFER_RED_SIZE */
-      1290, /* GL_RENDERBUFFER_GREEN_SIZE */
-      1287, /* GL_RENDERBUFFER_BLUE_SIZE */
-      1285, /* GL_RENDERBUFFER_ALPHA_SIZE */
-      1288, /* GL_RENDERBUFFER_DEPTH_SIZE */
-      1297, /* GL_RENDERBUFFER_STENCIL_SIZE */
-       561, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */
-       895, /* GL_MAX_SAMPLES */
-      1345, /* GL_RGBA_SNORM */
-      1341, /* GL_RGBA8_SNORM */
-      1402, /* GL_SIGNED_NORMALIZED */
-       461, /* GL_EVAL_BIT */
-      1265, /* GL_RASTER_POSITION_UNCLIPPED_IBM */
-       699, /* GL_LIST_BIT */
-      1594, /* GL_TEXTURE_BIT */
-      1376, /* GL_SCISSOR_BIT */
+       344, /* GL_DEPTH_ATTACHMENT */
+      1470, /* GL_STENCIL_ATTACHMENT */
+       530, /* GL_FRAMEBUFFER */
+      1292, /* GL_RENDERBUFFER */
+      1306, /* GL_RENDERBUFFER_WIDTH */
+      1299, /* GL_RENDERBUFFER_HEIGHT */
+      1301, /* GL_RENDERBUFFER_INTERNAL_FORMAT */
+      1493, /* GL_STENCIL_INDEX_EXT */
+      1490, /* GL_STENCIL_INDEX1_EXT */
+      1491, /* GL_STENCIL_INDEX4_EXT */
+      1492, /* GL_STENCIL_INDEX8_EXT */
+      1489, /* GL_STENCIL_INDEX16_EXT */
+      1303, /* GL_RENDERBUFFER_RED_SIZE */
+      1298, /* GL_RENDERBUFFER_GREEN_SIZE */
+      1295, /* GL_RENDERBUFFER_BLUE_SIZE */
+      1293, /* GL_RENDERBUFFER_ALPHA_SIZE */
+      1296, /* GL_RENDERBUFFER_DEPTH_SIZE */
+      1305, /* GL_RENDERBUFFER_STENCIL_SIZE */
+       563, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */
+       903, /* GL_MAX_SAMPLES */
+       298, /* GL_COPY_READ_BUFFER */
+       299, /* GL_COPY_WRITE_BUFFER */
+      1353, /* GL_RGBA_SNORM */
+      1349, /* GL_RGBA8_SNORM */
+      1410, /* GL_SIGNED_NORMALIZED */
+       463, /* GL_EVAL_BIT */
+      1273, /* GL_RASTER_POSITION_UNCLIPPED_IBM */
+       701, /* GL_LIST_BIT */
+      1602, /* GL_TEXTURE_BIT */
+      1384, /* GL_SCISSOR_BIT */
         29, /* GL_ALL_ATTRIB_BITS */
-       980, /* GL_MULTISAMPLE_BIT */
+       988, /* GL_MULTISAMPLE_BIT */
         30, /* GL_ALL_CLIENT_ATTRIB_BITS */
 };
 
index 5c4bea9cf628cc7fc1509ae4c44cbf6cc8ff6ac6..0d708fc246c0d0bf2ae3a712a93f6b4087264f00 100644 (file)
@@ -1,8 +1,9 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.3
+ * Version:  7.6
  *
  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ * Copyright (C) 2009  VMware, 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"),
@@ -44,6 +45,7 @@ static const struct {
    const char *name;
    int flag_offset;
 } default_extensions[] = {
+   { OFF, "GL_ARB_copy_buffer",                F(ARB_copy_buffer) },
    { OFF, "GL_ARB_depth_texture",              F(ARB_depth_texture) },
    { ON,  "GL_ARB_draw_buffers",               F(ARB_draw_buffers) },
    { OFF, "GL_ARB_fragment_program",           F(ARB_fragment_program) },
@@ -52,6 +54,7 @@ static const struct {
    { OFF, "GL_ARB_framebuffer_object",         F(ARB_framebuffer_object) },
    { OFF, "GL_ARB_half_float_pixel",           F(ARB_half_float_pixel) },
    { OFF, "GL_ARB_imaging",                    F(ARB_imaging) },
+   { OFF, "GL_ARB_map_buffer_range",           F(ARB_map_buffer_range) },
    { ON,  "GL_ARB_multisample",                F(ARB_multisample) },
    { OFF, "GL_ARB_multitexture",               F(ARB_multitexture) },
    { OFF, "GL_ARB_occlusion_query",            F(ARB_occlusion_query) },
@@ -183,6 +186,7 @@ static const struct {
 void
 _mesa_enable_sw_extensions(GLcontext *ctx)
 {
+   ctx->Extensions.ARB_copy_buffer = GL_TRUE;
    ctx->Extensions.ARB_depth_texture = GL_TRUE;
    /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/
 #if FEATURE_ARB_fragment_program
@@ -197,6 +201,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
 #endif
    ctx->Extensions.ARB_half_float_pixel = GL_TRUE;
    ctx->Extensions.ARB_imaging = GL_TRUE;
+   ctx->Extensions.ARB_map_buffer_range = GL_TRUE;
    ctx->Extensions.ARB_multitexture = GL_TRUE;
 #if FEATURE_ARB_occlusion_query
    ctx->Extensions.ARB_occlusion_query = GL_TRUE;
@@ -440,8 +445,9 @@ _mesa_enable_2_1_extensions(GLcontext *ctx)
 
 /**
  * Either enable or disable the named extension.
+ * \return GL_TRUE for success, GL_FALSE if invalid extension name
  */
-static void
+static GLboolean
 set_extension( GLcontext *ctx, const char *name, GLboolean state )
 {
    GLboolean *base = (GLboolean *) &ctx->Extensions;
@@ -450,7 +456,7 @@ set_extension( GLcontext *ctx, const char *name, GLboolean state )
    if (ctx->Extensions.String) {
       /* The string was already queried - can't change it now! */
       _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name);
-      return;
+      return GL_FALSE;
    }
 
    for (i = 0 ; i < Elements(default_extensions) ; i++) {
@@ -459,10 +465,10 @@ set_extension( GLcontext *ctx, const char *name, GLboolean state )
             GLboolean *enabled = base + default_extensions[i].flag_offset;
             *enabled = state;
          }
-         return;
+         return GL_TRUE;
       }
    }
-   _mesa_problem(ctx, "Trying to enable unknown extension: %s", name);
+   return GL_FALSE;
 }
 
 
@@ -473,7 +479,8 @@ set_extension( GLcontext *ctx, const char *name, GLboolean state )
 void
 _mesa_enable_extension( GLcontext *ctx, const char *name )
 {
-   set_extension(ctx, name, GL_TRUE);
+   if (!set_extension(ctx, name, GL_TRUE))
+      _mesa_problem(ctx, "Trying to enable unknown extension: %s", name);
 }
 
 
@@ -484,7 +491,8 @@ _mesa_enable_extension( GLcontext *ctx, const char *name )
 void
 _mesa_disable_extension( GLcontext *ctx, const char *name )
 {
-   set_extension(ctx, name, GL_FALSE);
+   if (!set_extension(ctx, name, GL_FALSE))
+      _mesa_problem(ctx, "Trying to disable unknown extension: %s", name);
 }
 
 
@@ -508,6 +516,80 @@ _mesa_extension_is_enabled( GLcontext *ctx, const char *name )
 }
 
 
+/**
+ * Append string 'b' onto string 'a'.  Free 'a' and return new string.
+ */
+static char *
+append(const char *a, const char *b)
+{
+   const GLuint aLen = a ? _mesa_strlen(a) : 0;
+   const GLuint bLen = b ? _mesa_strlen(b) : 0;
+   char *s = _mesa_calloc(aLen + bLen + 1);
+   if (s) {
+      if (a)
+         _mesa_memcpy(s, a, aLen);
+      if (b)
+         _mesa_memcpy(s + aLen, b, bLen);
+      s[aLen + bLen] = '\0';
+   }
+   if (a)
+      _mesa_free((void *) a);
+   return s;
+}
+
+
+/**
+ * Check the MESA_EXTENSION_OVERRIDE env var.
+ * For extension names that are recognized, turn them on.  For extension
+ * names that are recognized and prefixed with '-', turn them off.
+ * Return a string of the unknown/leftover names.
+ */
+static const char *
+get_extension_override( GLcontext *ctx )
+{
+   const char *envExt = _mesa_getenv("MESA_EXTENSION_OVERRIDE");
+   char *extraExt = NULL;
+   char ext[1000];
+   GLuint extLen = 0;
+   GLuint i;
+   GLboolean disableExt = GL_FALSE;
+
+   if (!envExt)
+      return NULL;
+
+   for (i = 0; ; i++) {
+      if (envExt[i] == '\0' || envExt[i] == ' ') {
+         /* terminate/process 'ext' if extLen > 0 */
+         if (extLen > 0) {
+            assert(extLen < sizeof(ext));
+            /* enable extension named by 'ext' */
+            ext[extLen] = 0;
+            if (!set_extension(ctx, ext, !disableExt)) {
+               /* unknown extension name, append it to extraExt */
+               if (extraExt) {
+                  extraExt = append(extraExt, " ");
+               }
+               extraExt = append(extraExt, ext);
+            }
+            extLen = 0;
+            disableExt = GL_FALSE;
+         }
+         if (envExt[i] == '\0')
+            break;
+      }
+      else if (envExt[i] == '-') {
+         disableExt = GL_TRUE;
+      }
+      else {
+         /* accumulate this non-space character */
+         ext[extLen++] = envExt[i];
+      }
+   }
+
+   return extraExt;
+}
+
+
 /**
  * Run through the default_extensions array above and set the
  * ctx->Extensions.ARB/EXT_* flags accordingly.
@@ -536,8 +618,9 @@ GLubyte *
 _mesa_make_extension_string( GLcontext *ctx )
 {
    const GLboolean *base = (const GLboolean *) &ctx->Extensions;
+   const char *extraExt = get_extension_override(ctx);
    GLuint extStrLen = 0;
-   GLubyte *s;
+   char *s;
    GLuint i;
 
    /* first, compute length of the extension string */
@@ -547,7 +630,14 @@ _mesa_make_extension_string( GLcontext *ctx )
          extStrLen += (GLuint)_mesa_strlen(default_extensions[i].name) + 1;
       }
    }
-   s = (GLubyte *) _mesa_malloc(extStrLen);
+
+   if (extraExt)
+      extStrLen += _mesa_strlen(extraExt) + 1; /* +1 for space */
+
+   /* allocate the extension string */
+   s = (char *) _mesa_malloc(extStrLen);
+   if (!s)
+      return NULL;
 
    /* second, build the extension string */
    extStrLen = 0;
@@ -557,13 +647,18 @@ _mesa_make_extension_string( GLcontext *ctx )
          GLuint len = (GLuint)_mesa_strlen(default_extensions[i].name);
          _mesa_memcpy(s + extStrLen, default_extensions[i].name, len);
          extStrLen += len;
-         s[extStrLen] = (GLubyte) ' ';
+         s[extStrLen] = ' ';
          extStrLen++;
       }
    }
    ASSERT(extStrLen > 0);
 
-   s[extStrLen - 1] = 0;
+   s[extStrLen - 1] = 0; /* -1 to overwrite trailing the ' ' */
 
-   return s;
+   if (extraExt) {
+      s = append(s, " ");
+      s = append(s, extraExt);
+   }
+
+   return (GLubyte *) s;
 }
index e8e8c2bf30e53163915020537a8872519bebd571..83301f1e621156369312cddf5fb8e683f84e1631 100644 (file)
@@ -368,6 +368,11 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format,
             att->Complete = GL_FALSE;
             return;
          }
+         if (texImage->TexFormat->TexelBytes == 0) {
+            att_incomplete("compressed internalformat");
+            att->Complete = GL_FALSE;
+            return;
+         }
       }
       else if (format == GL_DEPTH) {
          if (texImage->TexFormat->BaseFormat == GL_DEPTH_COMPONENT) {
index 01fbe40a03b418f72ef98f9d1f81246dfaf0b9b7..090e5eb330086287488098f88e6ffd37084514d3 100644 (file)
@@ -182,6 +182,8 @@ _mesa_sizeof_type( GLenum type )
         return sizeof(GLint);
       case GL_FLOAT:
         return sizeof(GLfloat);
+      case GL_DOUBLE:
+        return sizeof(GLdouble);
       case GL_HALF_FLOAT_ARB:
         return sizeof(GLhalfARB);
       default:
index 62c3ead3e1bb3eeecdec673b8dfbd0e3abeffe86..ef973314e35d265c11147fc741cc756ebd510289 100644 (file)
@@ -61,6 +61,7 @@
 #define FEATURE_ARB_occlusion_query  _HAVE_FULL_GL
 #define FEATURE_ARB_fragment_program  _HAVE_FULL_GL
 #define FEATURE_ARB_framebuffer_object  _HAVE_FULL_GL
+#define FEATURE_ARB_map_buffer_range  _HAVE_FULL_GL
 #define FEATURE_ARB_pixel_buffer_object  _HAVE_FULL_GL
 #define FEATURE_ARB_vertex_buffer_object  _HAVE_FULL_GL
 #define FEATURE_ARB_vertex_program  _HAVE_FULL_GL
index 7a719745fcc593d26a192928e7d1af0d498f9486..872982fa4306738e81fe1585f087e1d2c7f38ade 100644 (file)
@@ -1481,9 +1481,12 @@ next_mipmap_level_size(GLenum target, GLint border,
 
 
 /**
- * For GL_SGIX_generate_mipmap:
- * Generate a complete set of mipmaps from texObj's base-level image.
+ * Automatic mipmap generation.
+ * This is the fallback/default function for ctx->Driver.GenerateMipmap().
+ * Generate a complete set of mipmaps from texObj's BaseLevel image.
  * Stop at texObj's MaxLevel or when we get to the 1x1 texture.
+ * For cube maps, target will be one of
+ * GL_TEXTURE_CUBE_MAP_POSITIVE/NEGATIVE_X/Y/Z; never GL_TEXTURE_CUBE_MAP.
  */
 void
 _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
index 50dc2def87f65ad1b2aaf26cb8453f7e8e5c899d..71a85a9db817363fd542570bafe51c7be8035e48 100644 (file)
@@ -1028,7 +1028,7 @@ struct gl_stencil_attrib
 
 /**
  * An index for each type of texture object.  These correspond to the GL
- * target target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc.
+ * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc.
  * Note: the order is from highest priority to lowest priority.
  */
 typedef enum
@@ -1498,14 +1498,17 @@ struct gl_buffer_object
 {
    GLint RefCount;
    GLuint Name;
-   GLenum Usage;
-   GLenum Access;
-   GLvoid *Pointer;          /**< Only valid while buffer is mapped */
-   GLintptr Offset;          /**< mapped offset */
-   GLsizeiptr Length;        /**< mapped length */
-   GLsizeiptrARB Size;       /**< Size of storage in bytes */
-   GLubyte *Data;            /**< Location of storage either in RAM or VRAM. */
-   GLboolean OnCard;         /**< Is buffer in VRAM? (hardware drivers) */
+   GLenum Usage;        /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */
+   GLsizeiptrARB Size;  /**< Size of buffer storage in bytes */
+   GLubyte *Data;       /**< Location of storage either in RAM or VRAM. */
+   /** Fields describing a mapped buffer */
+   /*@{*/
+   GLbitfield AccessFlags; /**< Mask of GL_MAP_x_BIT flags */
+   GLvoid *Pointer;     /**< User-space address of mapping */
+   GLintptr Offset;     /**< Mapped offset */
+   GLsizeiptr Length;   /**< Mapped length */
+   /*@}*/
+   GLboolean Written;   /**< Ever written to? (for debugging) */
 };
 
 
@@ -1541,10 +1544,10 @@ struct gl_client_array
    const GLubyte *Ptr;          /**< Points to array data */
    GLboolean Enabled;          /**< Enabled flag is a boolean */
    GLboolean Normalized;        /**< GL_ARB_vertex_program */
+   GLuint _ElementSize;         /**< size of each element in bytes */
 
-   /**< GL_ARB_vertex_buffer_object */
-   struct gl_buffer_object *BufferObj;
-   GLuint _MaxElement;
+   struct gl_buffer_object *BufferObj;/**< GL_ARB_vertex_buffer_object */
+   GLuint _MaxElement;          /**< max element index into array buffer + 1 */
 };
 
 
@@ -1563,6 +1566,7 @@ struct gl_array_object
    /** Conventional vertex arrays */
    /*@{*/
    struct gl_client_array Vertex;
+   struct gl_client_array Weight;
    struct gl_client_array Normal;
    struct gl_client_array Color;
    struct gl_client_array SecondaryColor;
@@ -1573,11 +1577,22 @@ struct gl_array_object
    struct gl_client_array PointSize;
    /*@}*/
 
-   /** Generic arrays for vertex programs/shaders */
-   struct gl_client_array VertexAttrib[VERT_ATTRIB_MAX];
+   /**
+    * Generic arrays for vertex programs/shaders.
+    * For NV vertex programs, these attributes alias and take priority
+    * over the conventional attribs above.  For ARB vertex programs and
+    * GLSL vertex shaders, these attributes are separate.
+    */
+   struct gl_client_array VertexAttrib[MAX_VERTEX_GENERIC_ATTRIBS];
 
    /** Mask of _NEW_ARRAY_* values indicating which arrays are enabled */
    GLbitfield _Enabled;
+
+   /**
+    * Min of all enabled arrays' _MaxElement.  When arrays reside inside VBOs
+    * we can determine the max legal (in bounds) glDrawElements array index.
+    */
+   GLuint _MaxElement;
 };
 
 
@@ -1586,7 +1601,10 @@ struct gl_array_object
  */
 struct gl_array_attrib
 {
+   /** Currently bound array object. See _mesa_BindVertexArrayAPPLE() */
    struct gl_array_object *ArrayObj;
+
+   /** The default vertex array object */
    struct gl_array_object *DefaultArrayObj;
 
    GLint ActiveTexture;                /**< Client Active Texture */
@@ -1596,11 +1614,9 @@ struct gl_array_attrib
    GLbitfield NewState;                /**< mask of _NEW_ARRAY_* values */
 
 #if FEATURE_ARB_vertex_buffer_object
-   struct gl_buffer_object *NullBufferObj;
    struct gl_buffer_object *ArrayBufferObj;
    struct gl_buffer_object *ElementArrayBufferObj;
 #endif
-   GLuint _MaxElement;          /* Min of all enabled array's maxes */
 };
 
 
@@ -2053,6 +2069,9 @@ struct gl_shared_state
    /** Default texture objects (shared by all texture units) */
    struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS];
 
+   /** Fallback texture used when a bound texture is incomplete */
+   struct gl_texture_object *FallbackTex;
+
    /**
     * \name Thread safety and statechange notification for texture
     * objects. 
@@ -2064,6 +2083,8 @@ struct gl_shared_state
    GLuint TextureStateStamp;           /**< state notification for shared tex */
    /*@}*/
 
+   /** Default buffer object for vertex arrays that aren't in VBOs */
+   struct gl_buffer_object *NullBufferObj;
 
    /**
     * \name Vertex/fragment programs
@@ -2413,6 +2434,7 @@ struct gl_constants
 struct gl_extensions
 {
    GLboolean dummy;  /* don't remove this! */
+   GLboolean ARB_copy_buffer;
    GLboolean ARB_depth_texture;
    GLboolean ARB_draw_buffers;
    GLboolean ARB_fragment_program;
@@ -2421,6 +2443,7 @@ struct gl_extensions
    GLboolean ARB_framebuffer_object;
    GLboolean ARB_half_float_pixel;
    GLboolean ARB_imaging;
+   GLboolean ARB_map_buffer_range;
    GLboolean ARB_multisample;
    GLboolean ARB_multitexture;
    GLboolean ARB_occlusion_query;
@@ -2619,6 +2642,7 @@ struct gl_matrix_stack
 #define _NEW_PROGRAM            0x8000000  /**< __GLcontextRec::VertexProgram */
 #define _NEW_CURRENT_ATTRIB     0x10000000  /**< __GLcontextRec::Current */
 #define _NEW_PROGRAM_CONSTANTS  0x20000000
+#define _NEW_BUFFER_OBJECT      0x40000000
 #define _NEW_ALL ~0
 /*@}*/
 
@@ -2937,6 +2961,9 @@ struct __GLcontextRec
    struct gl_shader_state Shader; /**< GLSL shader object state */
 
    struct gl_query_state Query;  /**< occlusion, timer queries */
+
+   struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */
+   struct gl_buffer_object *CopyWriteBuffer; /**< GL_ARB_copy_buffer */
    /*@}*/
 
 #if FEATURE_EXT_framebuffer_object
index 57ae9c721a823e42b0aefac04f045eca947773fc..d9f3e476e81e0f52f7bfc0c9a97a45a37c92558b 100644 (file)
@@ -170,7 +170,7 @@ _mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values )
          return;
       }
       /* restore */
-      ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+      ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj;
       buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
                                               GL_READ_ONLY_ARB,
                                               ctx->Unpack.BufferObj);
@@ -229,7 +229,7 @@ _mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values )
          return;
       }
       /* restore */
-      ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+      ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj;
       buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
                                               GL_READ_ONLY_ARB,
                                               ctx->Unpack.BufferObj);
@@ -303,7 +303,7 @@ _mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values )
          return;
       }
       /* restore */
-      ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+      ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj;
       buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
                                               GL_READ_ONLY_ARB,
                                               ctx->Unpack.BufferObj);
@@ -371,7 +371,7 @@ _mesa_GetPixelMapfv( GLenum map, GLfloat *values )
          return;
       }
       /* restore */
-      ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+      ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj;
       buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
                                               GL_WRITE_ONLY_ARB,
                                               ctx->Pack.BufferObj);
@@ -432,7 +432,7 @@ _mesa_GetPixelMapuiv( GLenum map, GLuint *values )
          return;
       }
       /* restore */
-      ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+      ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj;
       buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
                                               GL_WRITE_ONLY_ARB,
                                               ctx->Pack.BufferObj);
@@ -494,7 +494,7 @@ _mesa_GetPixelMapusv( GLenum map, GLushort *values )
          return;
       }
       /* restore */
-      ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+      ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj;
       buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
                                               GL_WRITE_ONLY_ARB,
                                               ctx->Pack.BufferObj);
index ff1a6344cc946f5540630c81373754a7a0c67dcb..6a641f83f27fea499748db7b4d1388e245fba0fd 100644 (file)
@@ -245,7 +245,8 @@ _mesa_init_pixelstore( GLcontext *ctx )
    ctx->Pack.ClientStorage = GL_FALSE;
    ctx->Pack.Invert = GL_FALSE;
 #if FEATURE_EXT_pixel_buffer_object
-   ctx->Pack.BufferObj = ctx->Array.NullBufferObj;
+   _mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj,
+                                 ctx->Shared->NullBufferObj);
 #endif
    ctx->Unpack.Alignment = 4;
    ctx->Unpack.RowLength = 0;
@@ -258,7 +259,8 @@ _mesa_init_pixelstore( GLcontext *ctx )
    ctx->Unpack.ClientStorage = GL_FALSE;
    ctx->Unpack.Invert = GL_FALSE;
 #if FEATURE_EXT_pixel_buffer_object
-   ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
+   _mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj,
+                                 ctx->Shared->NullBufferObj);
 #endif
 
    /*
@@ -278,6 +280,7 @@ _mesa_init_pixelstore( GLcontext *ctx )
    ctx->DefaultPacking.ClientStorage = GL_FALSE;
    ctx->DefaultPacking.Invert = GL_FALSE;
 #if FEATURE_EXT_pixel_buffer_object
-   ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+   _mesa_reference_buffer_object(ctx, &ctx->DefaultPacking.BufferObj,
+                                 ctx->Shared->NullBufferObj);
 #endif
 }
index ae8dd2a83643abf79ec173c014d24c1e6a87177e..731a15404081736cddd7c0722654b086d3e56963 100644 (file)
@@ -33,6 +33,7 @@
 #include "mtypes.h"
 #include "hash.h"
 #include "arrayobj.h"
+#include "bufferobj.h"
 #include "shared.h"
 #include "shader/program.h"
 #include "shader/shader_api.h"
@@ -92,6 +93,13 @@ _mesa_alloc_shared_state(GLcontext *ctx)
    shared->BufferObjects = _mesa_NewHashTable();
 #endif
 
+   /* Allocate the default buffer object and set refcount so high that
+    * it never gets deleted.
+    * XXX with recent/improved refcounting this may not longer be needed.
+    */
+   shared->NullBufferObj = _mesa_new_buffer_object(ctx, 0, 0);
+   shared->NullBufferObj->RefCount = 1000 * 1000 * 1000;
+
    shared->ArrayObjects = _mesa_NewHashTable();
 
    /* Create default texture objects */
@@ -341,6 +349,10 @@ _mesa_free_shared_state(GLcontext *ctx, struct gl_shared_state *shared)
    _mesa_DeleteHashTable(shared->RenderBuffers);
 #endif
 
+#if FEATURE_ARB_vertex_buffer_object
+   _mesa_delete_buffer_object(ctx, shared->NullBufferObj);
+#endif
+
    /*
     * Free texture objects (after FBOs since some textures might have
     * been bound to FBOs).
index 94e37e3dab5f9908d3f9a70517377a631e39d802..7b41b8f4da479f862518eeaae04633bc83b0250c 100644 (file)
@@ -64,114 +64,149 @@ update_separate_specular(GLcontext *ctx)
 
 
 /**
- * Update state dependent on vertex arrays.
+ * Compute the index of the last array element that can be safely accessed
+ * in a vertex array.  We can really only do this when the array lives in
+ * a VBO.
+ * The array->_MaxElement field will be updated.
+ * Later in glDrawArrays/Elements/etc we can do some bounds checking.
+ */
+static void
+compute_max_element(struct gl_client_array *array)
+{
+   assert(array->Enabled);
+   if (array->BufferObj->Name) {
+      /* Compute the max element we can access in the VBO without going
+       * out of bounds.
+       */
+      array->_MaxElement = ((GLsizeiptrARB) array->BufferObj->Size
+                            - (GLsizeiptrARB) array->Ptr + array->StrideB
+                            - array->_ElementSize) / array->StrideB;
+   }
+   else {
+      /* user-space array, no idea how big it is */
+      array->_MaxElement = 2 * 1000 * 1000 * 1000; /* just a big number */
+   }
+}
+
+
+/**
+ * Helper for update_arrays().
+ * \return  min(current min, array->_MaxElement).
+ */
+static GLuint
+update_min(GLuint min, struct gl_client_array *array)
+{
+   compute_max_element(array);
+   return MIN2(min, array->_MaxElement);
+}
+
+
+/**
+ * Update ctx->Array._MaxElement (the max legal index into all enabled arrays).
+ * Need to do this upon new array state or new buffer object state.
  */
 static void
 update_arrays( GLcontext *ctx )
 {
-   GLuint i, min;
+   struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
+   GLuint i, min = ~0;
 
    /* find min of _MaxElement values for all enabled arrays */
 
    /* 0 */
    if (ctx->VertexProgram._Current
-       && ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) {
-      min = ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS]._MaxElement;
+       && arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) {
+      min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_POS]);
    }
-   else if (ctx->Array.ArrayObj->Vertex.Enabled) {
-      min = ctx->Array.ArrayObj->Vertex._MaxElement;
-   }
-   else {
-      /* can't draw anything without vertex positions! */
-      min = 0;
+   else if (arrayObj->Vertex.Enabled) {
+      min = update_min(min, &arrayObj->Vertex);
    }
 
    /* 1 */
    if (ctx->VertexProgram._Enabled
-       && ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_WEIGHT].Enabled) {
-      min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_WEIGHT]._MaxElement);
+       && arrayObj->VertexAttrib[VERT_ATTRIB_WEIGHT].Enabled) {
+      min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_WEIGHT]);
    }
    /* no conventional vertex weight array */
 
    /* 2 */
    if (ctx->VertexProgram._Enabled
-       && ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) {
-      min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_NORMAL]._MaxElement);
+       && arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) {
+      min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL]);
    }
-   else if (ctx->Array.ArrayObj->Normal.Enabled) {
-      min = MIN2(min, ctx->Array.ArrayObj->Normal._MaxElement);
+   else if (arrayObj->Normal.Enabled) {
+      min = update_min(min, &arrayObj->Normal);
    }
 
    /* 3 */
    if (ctx->VertexProgram._Enabled
-       && ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) {
-      min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR0]._MaxElement);
+       && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) {
+      min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0]);
    }
-   else if (ctx->Array.ArrayObj->Color.Enabled) {
-      min = MIN2(min, ctx->Array.ArrayObj->Color._MaxElement);
+   else if (arrayObj->Color.Enabled) {
+      min = update_min(min, &arrayObj->Color);
    }
 
    /* 4 */
    if (ctx->VertexProgram._Enabled
-       && ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) {
-      min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR1]._MaxElement);
+       && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) {
+      min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1]);
    }
-   else if (ctx->Array.ArrayObj->SecondaryColor.Enabled) {
-      min = MIN2(min, ctx->Array.ArrayObj->SecondaryColor._MaxElement);
+   else if (arrayObj->SecondaryColor.Enabled) {
+      min = update_min(min, &arrayObj->SecondaryColor);
    }
 
    /* 5 */
    if (ctx->VertexProgram._Enabled
-       && ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled) {
-      min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_FOG]._MaxElement);
+       && arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled) {
+      min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_FOG]);
    }
-   else if (ctx->Array.ArrayObj->FogCoord.Enabled) {
-      min = MIN2(min, ctx->Array.ArrayObj->FogCoord._MaxElement);
+   else if (arrayObj->FogCoord.Enabled) {
+      min = update_min(min, &arrayObj->FogCoord);
    }
 
    /* 6 */
    if (ctx->VertexProgram._Enabled
-       && ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) {
-      min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX]._MaxElement);
+       && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) {
+      min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX]);
    }
-   else if (ctx->Array.ArrayObj->Index.Enabled) {
-      min = MIN2(min, ctx->Array.ArrayObj->Index._MaxElement);
+   else if (arrayObj->Index.Enabled) {
+      min = update_min(min, &arrayObj->Index);
    }
 
-
    /* 7 */
    if (ctx->VertexProgram._Enabled
-       && ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) {
-      min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG]._MaxElement);
+       && arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) {
+      min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG]);
    }
 
    /* 8..15 */
    for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++) {
       if (ctx->VertexProgram._Enabled
-          && ctx->Array.ArrayObj->VertexAttrib[i].Enabled) {
-         min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[i]._MaxElement);
+          && arrayObj->VertexAttrib[i].Enabled) {
+         min = update_min(min, &arrayObj->VertexAttrib[i]);
       }
       else if (i - VERT_ATTRIB_TEX0 < ctx->Const.MaxTextureCoordUnits
-               && ctx->Array.ArrayObj->TexCoord[i - VERT_ATTRIB_TEX0].Enabled) {
-         min = MIN2(min, ctx->Array.ArrayObj->TexCoord[i - VERT_ATTRIB_TEX0]._MaxElement);
+               && arrayObj->TexCoord[i - VERT_ATTRIB_TEX0].Enabled) {
+         min = update_min(min, &arrayObj->TexCoord[i - VERT_ATTRIB_TEX0]);
       }
    }
 
    /* 16..31 */
    if (ctx->VertexProgram._Current) {
-      for (i = 0; i < Elements(ctx->Array.ArrayObj->VertexAttrib); i++) {
-         if (ctx->Array.ArrayObj->VertexAttrib[i].Enabled) {
-            min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[i]._MaxElement);
+      for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) {
+         if (arrayObj->VertexAttrib[i].Enabled) {
+            min = update_min(min, &arrayObj->VertexAttrib[i]);
          }
       }
    }
 
-   if (ctx->Array.ArrayObj->EdgeFlag.Enabled) {
-      min = MIN2(min, ctx->Array.ArrayObj->EdgeFlag._MaxElement);
+   if (arrayObj->EdgeFlag.Enabled) {
+      min = update_min(min, &arrayObj->EdgeFlag);
    }
 
    /* _MaxElement is one past the last legal array element */
-   ctx->Array._MaxElement = min;
+   arrayObj->_MaxElement = min;
 }
 
 
@@ -547,7 +582,7 @@ _mesa_update_state_locked( GLcontext *ctx )
    if (new_state & _DD_NEW_SEPARATE_SPECULAR)
       update_separate_specular( ctx );
 
-   if (new_state & (_NEW_ARRAY | _NEW_PROGRAM))
+   if (new_state & (_NEW_ARRAY | _NEW_PROGRAM | _NEW_BUFFER_OBJECT))
       update_arrays( ctx );
 
    if (new_state & (_NEW_BUFFERS | _NEW_VIEWPORT))
index b63f747fe8d3936cd2b5e40e246ac77e524d3fcb..2082f945f1852d0132f477346fe44ddbc9d1d17b 100644 (file)
@@ -281,7 +281,8 @@ valid_texture_object(const struct gl_texture_object *tex)
       _mesa_problem(NULL, "invalid reference to a deleted texture object");
       return GL_FALSE;
    default:
-      _mesa_problem(NULL, "invalid texture object Target value");
+      _mesa_problem(NULL, "invalid texture object Target 0x%x, Id = %u",
+                    tex->Target, tex->Name);
       return GL_FALSE;
    }
 }
@@ -662,6 +663,59 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
    }
 }
 
+
+/**
+ * Return pointer to a default/fallback texture.
+ * The texture is a 2D 8x8 RGBA texture with all texels = (0,0,0,1).
+ * That's the value a sampler should get when sampling from an
+ * incomplete texture.
+ */
+struct gl_texture_object *
+_mesa_get_fallback_texture(GLcontext *ctx)
+{
+   if (!ctx->Shared->FallbackTex) {
+      /* create fallback texture now */
+      static GLubyte texels[8 * 8][4];
+      struct gl_texture_object *texObj;
+      struct gl_texture_image *texImage;
+      GLuint i;
+
+      for (i = 0; i < 8 * 8; i++) {
+         texels[i][0] =
+         texels[i][1] =
+         texels[i][2] = 0x0;
+         texels[i][3] = 0xff;
+      }
+
+      /* create texture object */
+      texObj = ctx->Driver.NewTextureObject(ctx, 0, GL_TEXTURE_2D);
+      assert(texObj->RefCount == 1);
+      texObj->MinFilter = GL_NEAREST;
+      texObj->MagFilter = GL_NEAREST;
+
+      /* create level[0] texture image */
+      texImage = _mesa_get_tex_image(ctx, texObj, GL_TEXTURE_2D, 0);
+
+      /* init the image fields */
+      _mesa_init_teximage_fields(ctx, GL_TEXTURE_2D, texImage,
+                                    8, 8, 1, 0, GL_RGBA); 
+
+      /* set image data */
+      ctx->Driver.TexImage2D(ctx, GL_TEXTURE_2D, 0, GL_RGBA,
+                             8, 8, 0,
+                             GL_RGBA, GL_UNSIGNED_BYTE, texels,
+                             &ctx->DefaultPacking, texObj, texImage);
+
+      _mesa_test_texobj_completeness(ctx, texObj);
+      assert(texObj->_Complete);
+
+      ctx->Shared->FallbackTex = texObj;
+   }
+   return ctx->Shared->FallbackTex;
+}
+
+
+
 /*@}*/
 
 
@@ -891,6 +945,7 @@ _mesa_BindTexture( GLenum target, GLuint texName )
    struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
    struct gl_texture_object *newTexObj = NULL, *defaultTexObj = NULL;
    GLint targetIndex;
+   GLboolean early_out = GL_FALSE;
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
@@ -944,6 +999,17 @@ _mesa_BindTexture( GLenum target, GLuint texName )
 
    assert(valid_texture_object(newTexObj));
 
+   _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
+   if ((ctx->Shared->RefCount == 1)
+       && (newTexObj == texUnit->CurrentTex[targetIndex])) {
+      early_out = GL_TRUE;
+   }
+   _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+
+   if (early_out) {
+      return;
+   }
+
    /* flush before changing binding */
    FLUSH_VERTICES(ctx, _NEW_TEXTURE);
 
index d5374c5d6c4fd1034bb97eb5b66e07753101f5b0..2599c0816a9c867a4ae194b9fdf77466e6862c76 100644 (file)
@@ -65,6 +65,9 @@ extern void
 _mesa_test_texobj_completeness( const GLcontext *ctx,
                                 struct gl_texture_object *obj );
 
+extern struct gl_texture_object *
+_mesa_get_fallback_texture(GLcontext *ctx);
+
 extern void
 _mesa_unlock_context_textures( GLcontext *ctx );
 
index e60ab6aa123a6f105cff51c7b1d3b1eb5bfe8690..2195a334d3ea9fa69dcd4c974d5f5e6b2b5b21bf 100644 (file)
@@ -469,8 +469,10 @@ set_tex_parameterf(GLcontext *ctx,
          return GL_TRUE;
       }
       else {
-         _mesa_error(ctx, GL_INVALID_ENUM,
-                     "glTexParameter(pname=GL_TEXTURE_MAX_ANISOTROPY_EXT)");
+         static GLuint count = 0;
+         if (count++ < 10)
+            _mesa_error(ctx, GL_INVALID_ENUM,
+                        "glTexParameter(pname=GL_TEXTURE_MAX_ANISOTROPY_EXT)");
       }
       return GL_FALSE;
 
index cef58d7a496fee9b0476048bbd7bf32f7206a2a0..6e0c0c688a19ac3171b7e1b86936ffbbab5f038c 100644 (file)
@@ -561,8 +561,19 @@ update_texture_state( GLcontext *ctx )
       }
 
       if (!texUnit->_ReallyEnabled) {
-         _mesa_reference_texobj(&texUnit->_Current, NULL);
-         continue;
+         if (fprog) {
+            /* If we get here it means the shader is expecting a texture
+             * object, but there isn't one (or it's incomplete).  Use the
+             * fallback texture.
+             */
+            struct gl_texture_object *texObj = _mesa_get_fallback_texture(ctx);
+            texUnit->_ReallyEnabled = 1 << TEXTURE_2D_INDEX;
+            _mesa_reference_texobj(&texUnit->_Current, texObj);
+         }
+         else {
+            /* fixed-function: texture unit is really disabled */
+            continue;
+         }
       }
 
       /* if we get here, we know this texture unit is enabled */
index 0882e8f37a237dd05033efc062857450674c7480..f04c137c6d373ae5ebde2a742173a9e1dc8fb821 100644 (file)
@@ -1,8 +1,9 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.2
+ * Version:  7.6
  *
  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ * Copyright (C) 2009  VMware, 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"),
 
 
 /**
- * Update the fields of a vertex array object.
- * We need to do a few special things for arrays that live in
- * vertex buffer objects.
+ * Set the fields of a vertex array.
  *
  * \param array  the array to update
  * \param dirtyBit  which bit to set in ctx->Array.NewState for this array
  * \param elementSize  size of each array element, in bytes
  * \param size  components per element (1, 2, 3 or 4)
  * \param type  datatype of each component (GL_FLOAT, GL_INT, etc)
+ * \param format  either GL_RGBA or GL_BGRA
  * \param stride  stride between elements, in elements
  * \param normalized  are integer types converted to floats in [-1, 1]?
  * \param ptr  the address (or offset inside VBO) of the array data
@@ -63,22 +63,11 @@ update_array(GLcontext *ctx, struct gl_client_array *array,
    array->StrideB = stride ? stride : elementSize;
    array->Normalized = normalized;
    array->Ptr = (const GLubyte *) ptr;
-#if FEATURE_ARB_vertex_buffer_object
+   array->_ElementSize = elementSize;
+
    _mesa_reference_buffer_object(ctx, &array->BufferObj,
                                  ctx->Array.ArrayBufferObj);
 
-   /* Compute the index of the last array element that's inside the buffer.
-    * Later in glDrawArrays we'll check if start + count > _MaxElement to
-    * be sure we won't go out of bounds.
-    */
-   if (ctx->Array.ArrayBufferObj->Name)
-      array->_MaxElement = ((GLsizeiptrARB) ctx->Array.ArrayBufferObj->Size
-                            - (GLsizeiptrARB) array->Ptr + array->StrideB
-                            - elementSize) / array->StrideB;
-   else
-#endif
-      array->_MaxElement = 2 * 1000 * 1000 * 1000; /* just a big number */
-
    ctx->NewState |= _NEW_ARRAY;
    ctx->Array.NewState |= dirtyBit;
 }
@@ -528,6 +517,12 @@ _mesa_PointSizePointer(GLenum type, GLsizei stride, const GLvoid *ptr)
 
 
 #if FEATURE_NV_vertex_program
+/**
+ * Set a vertex attribute array.
+ * Note that these arrays DO alias the conventional GL vertex arrays
+ * (position, normal, color, fog, texcoord, etc).
+ * The generic attribute slots at #16 and above are not touched.
+ */
 void GLAPIENTRY
 _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
                             GLsizei stride, const GLvoid *ptr)
@@ -538,7 +533,7 @@ _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) {
+   if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) {
       _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(index)");
       return;
    }
@@ -604,6 +599,11 @@ _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
 
 
 #if FEATURE_ARB_vertex_program
+/**
+ * Set a generic vertex attribute array.
+ * Note that these arrays DO NOT alias the conventional GL vertex arrays
+ * (position, normal, color, fog, texcoord, etc).
+ */
 void GLAPIENTRY
 _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
                              GLboolean normalized,
@@ -1064,6 +1064,52 @@ _mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count,
 }
 
 
+/**
+ * Print vertex array's fields.
+ */
+static void
+print_array(const char *name, GLint index, const struct gl_client_array *array)
+{
+   if (index >= 0)
+      _mesa_printf("  %s[%d]: ", name, index);
+   else
+      _mesa_printf("  %s: ", name);
+   _mesa_printf("Ptr=%p, Type=0x%x, Size=%d, ElemSize=%u, Stride=%d, Buffer=%u(Size %u), MaxElem=%u\n",
+                array->Ptr, array->Type, array->Size,
+                array->_ElementSize, array->StrideB,
+                array->BufferObj->Name, array->BufferObj->Size,
+                array->_MaxElement);
+}
+
+
+/**
+ * Print current vertex object/array info.  For debug.
+ */
+void
+_mesa_print_arrays(GLcontext *ctx)
+{
+   struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
+   GLuint i;
+
+   _mesa_update_array_object_max_element(ctx, arrayObj);
+
+   _mesa_printf("Array Object %u\n", arrayObj->Name);
+   if (arrayObj->Vertex.Enabled)
+      print_array("Vertex", -1, &arrayObj->Vertex);
+   if (arrayObj->Normal.Enabled)
+      print_array("Normal", -1, &arrayObj->Normal);
+   if (arrayObj->Color.Enabled)
+      print_array("Color", -1, &arrayObj->Color);
+   for (i = 0; i < Elements(arrayObj->TexCoord); i++)
+      if (arrayObj->TexCoord[i].Enabled)
+         print_array("TexCoord", i, &arrayObj->TexCoord[i]);
+   for (i = 0; i < Elements(arrayObj->VertexAttrib); i++)
+      if (arrayObj->VertexAttrib[i].Enabled)
+         print_array("Attrib", i, &arrayObj->VertexAttrib[i]);
+   _mesa_printf("  _MaxElement = %u\n", arrayObj->_MaxElement);
+}
+
+
 /**
  * Initialize vertex array state for given context.
  */
index 97d5c8219d0e765df69751321a606d3a3c498afd..46cc3ee3425e15ccc68b935480be0f6faac541eb 100644 (file)
@@ -1,18 +1,9 @@
-/**
- * \file varray.h
- * Vertex arrays.
- *
- * \if subset
- * (No-op)
- *
- * \endif
- */
-
 /*
  * Mesa 3-D graphics library
- * Version:  4.1
+ * Version:  7.6
  *
- * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ * Copyright (C) 2009  VMware, 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"),
@@ -169,6 +160,8 @@ _mesa_DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count,
                         GLenum type, const GLvoid *indices);
 
 
+extern void
+_mesa_print_arrays(GLcontext *ctx);
 
 extern void
 _mesa_init_varray( GLcontext * ctx );
index 015ac71a178d3d30c3d1ca2671eab5cf10af25d1..d4d3dd1a94e1dfb87712b4c3a185b65e02ae7adc 100644 (file)
@@ -1,8 +1,9 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.5
+ * Version:  7.6
  *
  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ * Copyright (C) 2009  VMware, 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"),
@@ -29,9 +30,9 @@
 
 /* Mesa version */
 #define MESA_MAJOR 7
-#define MESA_MINOR 5
+#define MESA_MINOR 6
 #define MESA_PATCH 0
-#define MESA_VERSION_STRING "7.5-rc3"
+#define MESA_VERSION_STRING "7.6-devel"
 
 /* To make version comparison easy */
 #define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
index c5e2fd1de123715c669e1dde9c5cc7ca7641a7d2..4cbab11a35808abd1f9555528be66f30af10c459 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Mesa 3-D graphics library
  * Version:  3.5
 
 
 
-/*
+/**
  * Given a vector [count][4] of floats, set all the [][elt] values
  * to 0 (if elt = 0, 1, 2) or 1.0 (if elt = 3).
  */
-void _mesa_vector4f_clean_elem( GLvector4f *vec, GLuint count, GLuint elt )
+void
+_mesa_vector4f_clean_elem( GLvector4f *vec, GLuint count, GLuint elt )
 {
    static const GLubyte elem_bits[4] = {
       VEC_DIRTY_0,
@@ -54,12 +54,13 @@ void _mesa_vector4f_clean_elem( GLvector4f *vec, GLuint count, GLuint elt )
    GLfloat (*data)[4] = (GLfloat (*)[4])vec->start;
    GLuint i;
 
-   for (i = 0 ; i < count ; i++)
+   for (i = 0; i < count; i++)
       data[i][elt] = v;
 
    vec->flags &= ~elem_bits[elt];
 }
 
+
 static const GLubyte size_bits[5] = {
    0,
    VEC_SIZE_1,
@@ -69,61 +70,53 @@ static const GLubyte size_bits[5] = {
 };
 
 
-
-/*
+/**
  * Initialize GLvector objects.
- * Input: v - the vector object to initialize.
- *        flags - bitwise-OR of VEC_* flags
- *        storage - pointer to storage for the vector's data
+ * \param v  the vector object to initialize.
+ * \param flags  bitwise-OR of VEC_* flags
+ * \param storage  pointer to storage for the vector's data
  */
-
-
-void _mesa_vector4f_init( GLvector4f *v, GLuint flags, GLfloat (*storage)[4] )
+void
+_mesa_vector4f_init( GLvector4f *v, GLbitfield flags, GLfloat (*storage)[4] )
 {
    v->stride = 4 * sizeof(GLfloat);
    v->size = 2;   /* may change: 2-4 for vertices and 1-4 for texcoords */
    v->data = storage;
    v->start = (GLfloat *) storage;
    v->count = 0;
-   v->flags = size_bits[4] | flags ;
+   v->flags = size_bits[4] | flags;
 }
 
 
-
-
-/*
+/**
  * Initialize GLvector objects and allocate storage.
- * Input: v - the vector object
- *        sz - unused????
- *        flags - bitwise-OR of VEC_* flags
- *        count - number of elements to allocate in vector
- *        alignment - desired memory alignment for the data (in bytes)
+ * \param v  the vector object
+ * \param flags  bitwise-OR of VEC_* flags
+ * \param count  number of elements to allocate in vector
+ * \param alignment  desired memory alignment for the data (in bytes)
  */
-
-
-void _mesa_vector4f_alloc( GLvector4f *v, GLuint flags, GLuint count,
-                       GLuint alignment )
+void
+_mesa_vector4f_alloc( GLvector4f *v, GLbitfield flags, GLuint count,
+                      GLuint alignment )
 {
    v->stride = 4 * sizeof(GLfloat);
    v->size = 2;
    v->storage = ALIGN_MALLOC( count * 4 * sizeof(GLfloat), alignment );
+   v->storage_count = count;
    v->start = (GLfloat *) v->storage;
    v->data = (GLfloat (*)[4]) v->storage;
    v->count = 0;
-   v->flags = size_bits[4] | flags | VEC_MALLOC ;
+   v->flags = size_bits[4] | flags | VEC_MALLOC;
 }
 
 
-
-
-/*
+/**
  * Vector deallocation.  Free whatever memory is pointed to by the
  * vector's storage field if the VEC_MALLOC flag is set.
  * DO NOT free the GLvector object itself, though.
  */
-
-
-void _mesa_vector4f_free( GLvector4f *v )
+void
+_mesa_vector4f_free( GLvector4f *v )
 {
    if (v->flags & VEC_MALLOC) {
       ALIGN_FREE( v->storage );
@@ -135,13 +128,15 @@ void _mesa_vector4f_free( GLvector4f *v )
 }
 
 
-/*
+/**
  * For debugging
  */
-void _mesa_vector4f_print( GLvector4f *v, GLubyte *cullmask, GLboolean culling )
+void
+_mesa_vector4f_print( const GLvector4f *v, const GLubyte *cullmask,
+                      GLboolean culling )
 {
-   GLfloat c[4] = { 0, 0, 0, 1 };
-   const char *templates[5] = {
+   static const GLfloat c[4] = { 0, 0, 0, 1 };
+   static const char *templates[5] = {
       "%d:\t0, 0, 0, 1\n",
       "%d:\t%f, 0, 0, 1\n",
       "%d:\t%f, %f, 0, 1\n",
@@ -154,30 +149,32 @@ void _mesa_vector4f_print( GLvector4f *v, GLubyte *cullmask, GLboolean culling )
    GLuint j, i = 0, count;
 
    _mesa_printf("data-start\n");
-   for ( ; d != v->start ; STRIDE_F(d, v->stride), i++)
+   for (; d != v->start; STRIDE_F(d, v->stride), i++)
       _mesa_printf(t, i, d[0], d[1], d[2], d[3]);
 
    _mesa_printf("start-count(%u)\n", v->count);
    count = i + v->count;
 
    if (culling) {
-      for ( ; i < count ; STRIDE_F(d, v->stride), i++)
+      for (; i < count; STRIDE_F(d, v->stride), i++)
         if (cullmask[i])
            _mesa_printf(t, i, d[0], d[1], d[2], d[3]);
    }
    else {
-      for ( ; i < count ; STRIDE_F(d, v->stride), i++)
+      for (; i < count; STRIDE_F(d, v->stride), i++)
         _mesa_printf(t, i, d[0], d[1], d[2], d[3]);
    }
 
-   for (j = v->size ; j < 4; j++) {
+   for (j = v->size; j < 4; j++) {
       if ((v->flags & (1<<j)) == 0) {
 
         _mesa_printf("checking col %u is clean as advertised ", j);
 
-        for (i = 0, d = (GLfloat *) v->data ;
-             i < count && d[j] == c[j] ;
-             i++, STRIDE_F(d, v->stride)) {};
+        for (i = 0, d = (GLfloat *) v->data;
+             i < count && d[j] == c[j];
+             i++, STRIDE_F(d, v->stride)) {
+            /* no-op */
+         }
 
         if (i == count)
            _mesa_printf(" --> ok\n");
@@ -186,5 +183,3 @@ void _mesa_vector4f_print( GLvector4f *v, GLubyte *cullmask, GLboolean culling )
       }
    }
 }
-
-
index 647388ac7d0ebf127479e6458f4a0d5b034690ba..71281d57589a940eef23b74409c81f72fc14e077 100644 (file)
@@ -31,7 +31,6 @@
 #define _M_VECTOR_H_
 
 #include "main/glheader.h"
-#include "main/mtypes.h"               /* hack for GLchan */
 
 
 #define VEC_DIRTY_0        0x1
@@ -50,7 +49,8 @@
 
 
 
-/* Wrap all the information about vectors up in a struct.  Has
+/**
+ * Wrap all the information about vectors up in a struct.  Has
  * additional fields compared to the other vectors to help us track of
  * different vertex sizes, and whether we need to clean columns out
  * because they contain non-(0,0,0,1) values.
  * the transformation routines.
  */
 typedef struct {
-   GLfloat (*data)[4]; /* may be malloc'd or point to client data */
-   GLfloat *start;     /* points somewhere inside of <data> */
-   GLuint count;       /* size of the vector (in elements) */
-   GLuint stride;      /* stride from one element to the next (in bytes) */
-   GLuint size;                /* 2-4 for vertices and 1-4 for texcoords */
-   GLuint flags;       /* which columns are dirty */
-   void *storage;      /* self-allocated storage */
+   GLfloat (*data)[4]; /**< may be malloc'd or point to client data */
+   GLfloat *start;     /**< points somewhere inside of <data> */
+   GLuint count;       /**< size of the vector (in elements) */
+   GLuint stride;      /**< stride from one element to the next (in bytes) */
+   GLuint size;                /**< 2-4 for vertices and 1-4 for texcoords */
+   GLbitfield flags;   /**< bitmask of VEC_x flags */
+   void *storage;      /**< self-allocated storage */
+   GLuint storage_count; /**< storage size in elements */
 } GLvector4f;
 
 
-extern void _mesa_vector4f_init( GLvector4f *v, GLuint flags,
+extern void _mesa_vector4f_init( GLvector4f *v, GLbitfield flags,
                              GLfloat (*storage)[4] );
-extern void _mesa_vector4f_alloc( GLvector4f *v, GLuint flags,
+extern void _mesa_vector4f_alloc( GLvector4f *v, GLbitfield flags,
                               GLuint count, GLuint alignment );
 extern void _mesa_vector4f_free( GLvector4f *v );
-extern void _mesa_vector4f_print( GLvector4f *v, GLubyte *, GLboolean );
+extern void _mesa_vector4f_print( const GLvector4f *v, const GLubyte *, GLboolean );
 extern void _mesa_vector4f_clean_elem( GLvector4f *vec, GLuint nr, GLuint elt );
 
 
-
-
-
-/*
+/**
  * Given vector <v>, return a pointer (cast to <type *> to the <i>-th element.
  *
  * End up doing a lot of slow imuls if not careful.
index bb4c5b38d410dec11aa21ff9f44db828150c0498..7e166830fd5a0a4f31c4964d5981c331ed228f79 100644 (file)
@@ -563,6 +563,7 @@ struct var_cache
                                  * we take up with our state tokens or constants. Note that
                                  * this is _not_ the same as the number of param registers
                                  * we eventually use */
+   GLuint swizzle;              /**< swizzle to access this variable */
    struct var_cache *next;
 };
 
@@ -581,6 +582,7 @@ var_cache_create (struct var_cache **va)
       (**va).param_binding_begin = ~0;
       (**va).param_binding_length = ~0;
       (**va).alias_binding = NULL;
+      (**va).swizzle = SWIZZLE_XYZW;
       (**va).next = NULL;
    }
 }
@@ -872,15 +874,16 @@ parse_signed_float (const GLubyte ** inst, struct arb_program *Program)
  * This picks out a constant value from the parsed array. The constant vector is r
  * returned in the *values array, which should be of length 4.
  *
- * \param values - The 4 component vector with the constant value in it
+ * \param values - return the vector constant values.
+ * \param size - returns the number elements in valuesOut [1..4]
  */
 static GLvoid
-parse_constant (const GLubyte ** inst, GLfloat *values, struct arb_program *Program,
-                GLboolean use)
+parse_constant(const GLubyte ** inst, GLfloat *values, GLint *size,
+               struct arb_program *Program,
+               GLboolean use)
 {
    GLuint components, i;
 
-
    switch (*(*inst)++) {
       case CONSTANT_SCALAR:
          if (use == GL_TRUE) {
@@ -893,7 +896,7 @@ parse_constant (const GLubyte ** inst, GLfloat *values, struct arb_program *Prog
                values[1] =
                values[2] = values[3] = parse_signed_float (inst, Program);
          }
-
+         *size = 1;
          break;
       case CONSTANT_VECTOR:
          values[0] = values[1] = values[2] = 0;
@@ -902,7 +905,12 @@ parse_constant (const GLubyte ** inst, GLfloat *values, struct arb_program *Prog
          for (i = 0; i < components; i++) {
             values[i] = parse_signed_float (inst, Program);
          }
+         *size = 4;
          break;
+      default:
+         _mesa_problem(NULL, "unexpected case in parse_constant()");
+         values[0] = 0.0F;
+         *size = 0;
    }
 }
 
@@ -945,7 +953,7 @@ parse_generic_attrib_num(GLcontext *ctx, const GLubyte ** inst,
 {
    GLint i = parse_integer(inst, Program);
 
-   if ((i < 0) || (i >= MAX_VERTEX_PROGRAM_ATTRIBS))
+   if ((i < 0) || (i >= MAX_VERTEX_GENERIC_ATTRIBS))
    {
       program_error(ctx, Program->Position,
                     "Invalid generic vertex attribute index");
@@ -1505,10 +1513,10 @@ generic_attrib_check(struct var_cache *vc_head)
 {
    int a;
    struct var_cache *curr;
-   GLboolean explicitAttrib[MAX_VERTEX_PROGRAM_ATTRIBS],
-      genericAttrib[MAX_VERTEX_PROGRAM_ATTRIBS];
+   GLboolean explicitAttrib[MAX_VERTEX_GENERIC_ATTRIBS],
+      genericAttrib[MAX_VERTEX_GENERIC_ATTRIBS];
 
-   for (a=0; a<MAX_VERTEX_PROGRAM_ATTRIBS; a++) {
+   for (a=0; a<MAX_VERTEX_GENERIC_ATTRIBS; a++) {
       explicitAttrib[a] = GL_FALSE;
       genericAttrib[a] = GL_FALSE;
    }
@@ -1519,11 +1527,11 @@ generic_attrib_check(struct var_cache *vc_head)
          if (curr->attrib_is_generic) {
             GLuint attr = (curr->attrib_binding == 0)
                ? 0 : (curr->attrib_binding - VERT_ATTRIB_GENERIC0);
-            assert(attr < MAX_VERTEX_PROGRAM_ATTRIBS);
+            assert(attr < MAX_VERTEX_GENERIC_ATTRIBS);
             genericAttrib[attr] = GL_TRUE;
          }
          else {
-            assert(curr->attrib_binding < MAX_VERTEX_PROGRAM_ATTRIBS);
+            assert(curr->attrib_binding < MAX_VERTEX_GENERIC_ATTRIBS);
             explicitAttrib[ curr->attrib_binding ] = GL_TRUE;
          }
       }
@@ -1531,7 +1539,7 @@ generic_attrib_check(struct var_cache *vc_head)
       curr = curr->next;
    }
 
-   for (a=0; a<MAX_VERTEX_PROGRAM_ATTRIBS; a++) {
+   for (a=0; a<MAX_VERTEX_GENERIC_ATTRIBS; a++) {
       if ((explicitAttrib[a]) && (genericAttrib[a]))
          return 1;
    }
@@ -1819,7 +1827,6 @@ parse_param_elements (GLcontext * ctx, const GLubyte ** inst,
    GLint idx;
    GLuint err = 0;
    gl_state_index state_tokens[STATE_LENGTH] = {0, 0, 0, 0, 0};
-   GLfloat const_values[4];
 
    GLubyte token = *(*inst)++;
 
@@ -1911,18 +1918,31 @@ parse_param_elements (GLcontext * ctx, const GLubyte ** inst,
 
       case PARAM_CONSTANT:
          /* parsing something like {1.0, 2.0, 3.0, 4.0} */
-         parse_constant (inst, const_values, Program, use);
-         idx = _mesa_add_named_constant(Program->Base.Parameters,
-                                        (char *) param_var->name,
-                                        const_values, 4);
-         if (param_var->param_binding_begin == ~0U)
-            param_var->param_binding_begin = idx;
-         param_var->param_binding_type = PROGRAM_STATE_VAR;
-         /* Note: when we reference this parameter in an instruction later,
-          * we'll check if it's really a constant/immediate and set the
-          * instruction register type appropriately.
-          */
-         param_var->param_binding_length++;
+         {
+            GLfloat const_values[4];
+            GLint size;
+            parse_constant(inst, const_values, &size, Program, use);
+            if (param_var->name[0] == ' ') {
+               /* this is an unnamed constant */
+               idx = _mesa_add_unnamed_constant(Program->Base.Parameters,
+                                                const_values, size,
+                                                &param_var->swizzle);
+            }
+            else {
+               /* named parameter/constant */
+               idx = _mesa_add_named_constant(Program->Base.Parameters,
+                                              (char *) param_var->name,
+                                              const_values, size);
+            }
+            if (param_var->param_binding_begin == ~0U)
+               param_var->param_binding_begin = idx;
+            param_var->param_binding_type = PROGRAM_STATE_VAR;
+            /* Note: when we reference this parameter in an instruction later,
+             * we'll check if it's really a constant/immediate and set the
+             * instruction register type appropriately.
+             */
+            param_var->param_binding_length++;
+         }
          break;
 
       default:
@@ -2431,6 +2451,9 @@ parse_swizzle_mask(const GLubyte ** inst, GLubyte *swizzle, GLint len)
             return;
       }
    }
+
+   if (len == 1)
+      swizzle[1] = swizzle[2] = swizzle[3] = swizzle[0];
 }
 
 
@@ -2485,7 +2508,7 @@ static GLuint
 parse_src_reg (GLcontext * ctx, const GLubyte ** inst,
                struct var_cache **vc_head,
                struct arb_program *Program,
-               gl_register_file * File, GLint * Index,
+               gl_register_file * File, GLint * Index, GLuint *swizzle,
                GLboolean *IsRelOffset )
 {
    struct var_cache *src;
@@ -2494,6 +2517,8 @@ parse_src_reg (GLcontext * ctx, const GLubyte ** inst,
 
    *IsRelOffset = 0;
 
+   *swizzle = SWIZZLE_XYZW; /* default */
+
    /* And the binding for the src */
    switch (*(*inst)++) {
       case REGISTER_ATTRIB:
@@ -2549,6 +2574,7 @@ parse_src_reg (GLcontext * ctx, const GLubyte ** inst,
                      }
 
                      *Index = src->param_binding_begin + offset;
+                     *swizzle = src->swizzle;
                      break;
 
                   case ARRAY_INDEX_RELATIVE:
@@ -2571,6 +2597,7 @@ parse_src_reg (GLcontext * ctx, const GLubyte ** inst,
                         /* And store it properly */
                         *Index = src->param_binding_begin + rel_off;
                         *IsRelOffset = 1;
+                        *swizzle = src->swizzle;
                      }
                      break;
                }
@@ -2582,6 +2609,7 @@ parse_src_reg (GLcontext * ctx, const GLubyte ** inst,
 
                *File = (gl_register_file) src->param_binding_type;
                *Index = src->param_binding_begin;
+               *swizzle = src->swizzle;
                break;
          }
          break;
@@ -2650,6 +2678,21 @@ parse_src_reg (GLcontext * ctx, const GLubyte ** inst,
 }
 
 
+static GLuint
+swizzle_swizzle(GLuint baseSwizzle, const GLubyte swizzle[4])
+{
+   GLuint i, swz, s[4];
+   for (i = 0; i < 4; i++) {
+      GLuint c = swizzle[i];
+      if (c <= SWIZZLE_W)
+         s[i] = GET_SWZ(baseSwizzle, c);
+      else
+         s[i] = c;
+   }
+   swz = MAKE_SWIZZLE4(s[0], s[1], s[2], s[3]);
+   return swz;
+}
+
 /**
  * Parse vertex/fragment program vector source register.
  */
@@ -2664,12 +2707,14 @@ parse_vector_src_reg(GLcontext *ctx, const GLubyte **inst,
    GLubyte negateMask;
    GLubyte swizzle[4];
    GLboolean isRelOffset;
+   GLuint baseSwizzle;
 
    /* Grab the sign */
    negateMask = (parse_sign (inst) == -1) ? NEGATE_XYZW : NEGATE_NONE;
 
    /* And the src reg */
-   if (parse_src_reg(ctx, inst, vc_head, program, &file, &index, &isRelOffset))
+   if (parse_src_reg(ctx, inst, vc_head, program, &file, &index, &baseSwizzle,
+                     &isRelOffset))
       return 1;
 
    /* finally, the swizzle */
@@ -2677,7 +2722,7 @@ parse_vector_src_reg(GLcontext *ctx, const GLubyte **inst,
 
    reg->File = file;
    reg->Index = index;
-   reg->Swizzle = MAKE_SWIZZLE4(swizzle[0], swizzle[1], swizzle[2], swizzle[3]);
+   reg->Swizzle = swizzle_swizzle(baseSwizzle, swizzle);
    reg->Negate = negateMask;
    reg->RelAddr = isRelOffset;
    return 0;
@@ -2698,12 +2743,14 @@ parse_scalar_src_reg(GLcontext *ctx, const GLubyte **inst,
    GLubyte negateMask;
    GLubyte swizzle[4];
    GLboolean isRelOffset;
+   GLuint baseSwizzle;
 
    /* Grab the sign */
    negateMask = (parse_sign (inst) == -1) ? NEGATE_XYZW : NEGATE_NONE;
 
    /* And the src reg */
-   if (parse_src_reg(ctx, inst, vc_head, program, &file, &index, &isRelOffset))
+   if (parse_src_reg(ctx, inst, vc_head, program, &file, &index, &baseSwizzle,
+                     &isRelOffset))
       return 1;
 
    /* finally, the swizzle */
@@ -2711,7 +2758,7 @@ parse_scalar_src_reg(GLcontext *ctx, const GLubyte **inst,
 
    reg->File = file;
    reg->Index = index;
-   reg->Swizzle = (swizzle[0] << 0);
+   reg->Swizzle = swizzle_swizzle(baseSwizzle, swizzle);
    reg->Negate = negateMask;
    reg->RelAddr = isRelOffset;
    return 0;
@@ -3022,8 +3069,10 @@ parse_fp_instruction (GLcontext * ctx, const GLubyte ** inst,
            GLubyte negateMask;
             gl_register_file file;
            GLint index;
+            GLuint baseSwizzle;
 
-           if (parse_src_reg(ctx, inst, vc_head, Program, &file, &index, &rel))
+           if (parse_src_reg(ctx, inst, vc_head, Program, &file, &index,
+                              &baseSwizzle, &rel))
               return 1;
            parse_extended_swizzle_mask(inst, swizzle, &negateMask);
            fp->SrcReg[0].File = file;
@@ -3363,11 +3412,13 @@ parse_vp_instruction (GLcontext * ctx, const GLubyte ** inst,
            GLboolean relAddr;
             gl_register_file file;
            GLint index;
+            GLuint baseSwizzle;
 
            if (parse_dst_reg(ctx, inst, vc_head, Program, &vp->DstReg))
               return 1;
 
-           if (parse_src_reg(ctx, inst, vc_head, Program, &file, &index, &relAddr))
+           if (parse_src_reg(ctx, inst, vc_head, Program, &file, &index,
+                              &baseSwizzle, &relAddr))
               return 1;
            parse_extended_swizzle_mask (inst, swizzle, &negateMask);
            vp->SrcReg[0].File = file;
index 981565ab8f1880438c34722aa2685d84fe627a08..39136efadac2e755de8d7f43813150a2d8887ee3 100644 (file)
@@ -74,8 +74,6 @@ _mesa_BindProgram(GLenum target, GLuint id)
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   FLUSH_VERTICES(ctx, _NEW_PROGRAM);
-
    /* Error-check target and get curProg */
    if ((target == GL_VERTEX_PROGRAM_ARB) && /* == GL_VERTEX_PROGRAM_NV */
         (ctx->Extensions.NV_vertex_program ||
@@ -132,6 +130,9 @@ _mesa_BindProgram(GLenum target, GLuint id)
       return;
    }
 
+   /* signal new program (and its new constants) */
+   FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
+
    /* bind newProg */
    if (target == GL_VERTEX_PROGRAM_ARB) { /* == GL_VERTEX_PROGRAM_NV */
       _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current,
@@ -253,6 +254,8 @@ _mesa_EnableVertexAttribArrayARB(GLuint index)
       return;
    }
 
+   ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib));
+
    FLUSH_VERTICES(ctx, _NEW_ARRAY);
    ctx->Array.ArrayObj->VertexAttrib[index].Enabled = GL_TRUE;
    ctx->Array.ArrayObj->_Enabled |= _NEW_ARRAY_ATTRIB(index);
@@ -272,6 +275,8 @@ _mesa_DisableVertexAttribArrayARB(GLuint index)
       return;
    }
 
+   ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib));
+
    FLUSH_VERTICES(ctx, _NEW_ARRAY);
    ctx->Array.ArrayObj->VertexAttrib[index].Enabled = GL_FALSE;
    ctx->Array.ArrayObj->_Enabled &= ~_NEW_ARRAY_ATTRIB(index);
@@ -298,32 +303,41 @@ _mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params)
 }
 
 
+/**
+ * Return info for a generic vertex attribute array (no alias with
+ * legacy vertex attributes (pos, normal, color, etc)).
+ */
 void GLAPIENTRY
 _mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params)
 {
+   const struct gl_client_array *array;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) {
+   if (index >= MAX_VERTEX_GENERIC_ATTRIBS) {
       _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribfvARB(index)");
       return;
    }
 
+   ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib));
+
+   array = &ctx->Array.ArrayObj->VertexAttrib[index];
+
    switch (pname) {
       case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB:
-         params[0] = (GLfloat) ctx->Array.ArrayObj->VertexAttrib[index].Enabled;
+         params[0] = (GLfloat) array->Enabled;
          break;
       case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB:
-         params[0] = (GLfloat) ctx->Array.ArrayObj->VertexAttrib[index].Size;
+         params[0] = (GLfloat) array->Size;
          break;
       case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB:
-         params[0] = (GLfloat) ctx->Array.ArrayObj->VertexAttrib[index].Stride;
+         params[0] = (GLfloat) array->Stride;
          break;
       case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB:
-         params[0] = (GLfloat) ctx->Array.ArrayObj->VertexAttrib[index].Type;
+         params[0] = (GLfloat) array->Type;
          break;
       case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB:
-         params[0] = ctx->Array.ArrayObj->VertexAttrib[index].Normalized;
+         params[0] = array->Normalized;
          break;
       case GL_CURRENT_VERTEX_ATTRIB_ARB:
          if (index == 0) {
@@ -335,7 +349,7 @@ _mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params)
          COPY_4V(params, ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index]);
          break;
       case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB:
-         params[0] = (GLfloat) ctx->Array.ArrayObj->VertexAttrib[index].BufferObj->Name;
+         params[0] = (GLfloat) array->BufferObj->Name;
          break;
       default:
          _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribfvARB(pname)");
@@ -379,6 +393,8 @@ _mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer)
       return;
    }
 
+   ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib));
+
    *pointer = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[index].Ptr;
 }
 
@@ -489,7 +505,7 @@ _mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index,
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
+   FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
 
    if (target == GL_FRAGMENT_PROGRAM_ARB
        && ctx->Extensions.ARB_fragment_program) {
@@ -537,7 +553,7 @@ _mesa_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
    GLfloat * dest;
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
+   FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
 
    if (count <= 0) {
       _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameters4fv(count)");
@@ -631,7 +647,7 @@ _mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index,
    struct gl_program *prog;
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
+   FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
 
    if ((target == GL_FRAGMENT_PROGRAM_NV
         && ctx->Extensions.NV_fragment_program) ||
@@ -685,7 +701,7 @@ _mesa_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
    GLint i;
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
+   FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
 
    if (count <= 0) {
       _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameters4fv(count)");
index 5142c2a4a5988a696d4ed96e0ac863f0f03b6887..d6469b17bea7074228a4061219acbd4c26b527eb 100644 (file)
@@ -354,6 +354,7 @@ _mesa_GetTrackMatrixivNV(GLenum target, GLuint address,
 void GLAPIENTRY
 _mesa_GetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble *params)
 {
+   const struct gl_client_array *array;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
@@ -362,15 +363,17 @@ _mesa_GetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble *params)
       return;
    }
 
+   array = &ctx->Array.ArrayObj->VertexAttrib[index];
+
    switch (pname) {
       case GL_ATTRIB_ARRAY_SIZE_NV:
-         params[0] = ctx->Array.ArrayObj->VertexAttrib[index].Size;
+         params[0] = array->Size;
          break;
       case GL_ATTRIB_ARRAY_STRIDE_NV:
-         params[0] = ctx->Array.ArrayObj->VertexAttrib[index].Stride;
+         params[0] = array->Stride;
          break;
       case GL_ATTRIB_ARRAY_TYPE_NV:
-         params[0] = ctx->Array.ArrayObj->VertexAttrib[index].Type;
+         params[0] = array->Type;
          break;
       case GL_CURRENT_ATTRIB_NV:
          if (index == 0) {
@@ -395,6 +398,7 @@ _mesa_GetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble *params)
 void GLAPIENTRY
 _mesa_GetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat *params)
 {
+   const struct gl_client_array *array;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
@@ -403,15 +407,17 @@ _mesa_GetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat *params)
       return;
    }
 
+   array = &ctx->Array.ArrayObj->VertexAttrib[index];
+
    switch (pname) {
       case GL_ATTRIB_ARRAY_SIZE_NV:
-         params[0] = (GLfloat) ctx->Array.ArrayObj->VertexAttrib[index].Size;
+         params[0] = (GLfloat) array->Size;
          break;
       case GL_ATTRIB_ARRAY_STRIDE_NV:
-         params[0] = (GLfloat) ctx->Array.ArrayObj->VertexAttrib[index].Stride;
+         params[0] = (GLfloat) array->Stride;
          break;
       case GL_ATTRIB_ARRAY_TYPE_NV:
-         params[0] = (GLfloat) ctx->Array.ArrayObj->VertexAttrib[index].Type;
+         params[0] = (GLfloat) array->Type;
          break;
       case GL_CURRENT_ATTRIB_NV:
          if (index == 0) {
@@ -436,6 +442,7 @@ _mesa_GetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat *params)
 void GLAPIENTRY
 _mesa_GetVertexAttribivNV(GLuint index, GLenum pname, GLint *params)
 {
+   const struct gl_client_array *array;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
@@ -444,15 +451,17 @@ _mesa_GetVertexAttribivNV(GLuint index, GLenum pname, GLint *params)
       return;
    }
 
+   array = &ctx->Array.ArrayObj->VertexAttrib[index];
+
    switch (pname) {
       case GL_ATTRIB_ARRAY_SIZE_NV:
-         params[0] = ctx->Array.ArrayObj->VertexAttrib[index].Size;
+         params[0] = array->Size;
          break;
       case GL_ATTRIB_ARRAY_STRIDE_NV:
-         params[0] = ctx->Array.ArrayObj->VertexAttrib[index].Stride;
+         params[0] = array->Stride;
          break;
       case GL_ATTRIB_ARRAY_TYPE_NV:
-         params[0] = ctx->Array.ArrayObj->VertexAttrib[index].Type;
+         params[0] = array->Type;
          break;
       case GL_CURRENT_ATTRIB_NV:
          if (index == 0) {
@@ -467,7 +476,7 @@ _mesa_GetVertexAttribivNV(GLuint index, GLenum pname, GLint *params)
          params[3] = (GLint) ctx->Current.Attrib[index][3];
          break;
       case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB:
-         params[0] = ctx->Array.ArrayObj->VertexAttrib[index].BufferObj->Name;
+         params[0] = array->BufferObj->Name;
          break;
       default:
          _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV");
@@ -706,7 +715,7 @@ _mesa_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name,
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
+   FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
 
    prog = _mesa_lookup_program(ctx, id);
    if (!prog || prog->Target != GL_FRAGMENT_PROGRAM_NV) {
index 68a59350a1388b3b735d16d7429fc853ae7fee1d..f4beb9a78b62d6b249621b9fabb049cde27094f9 100644 (file)
@@ -225,6 +225,13 @@ fetch_vector4(const struct prog_src_register *source,
       result[2] = -result[2];
       result[3] = -result[3];
    }
+
+#ifdef NAN_CHECK
+   assert(!IS_INF_OR_NAN(result[0]));
+   assert(!IS_INF_OR_NAN(result[0]));
+   assert(!IS_INF_OR_NAN(result[0]));
+   assert(!IS_INF_OR_NAN(result[0]));
+#endif
 }
 
 
@@ -479,6 +486,13 @@ store_vector4(const struct prog_instruction *inst,
       }
    }
 
+#ifdef NAN_CHECK
+   assert(!IS_INF_OR_NAN(value[0]));
+   assert(!IS_INF_OR_NAN(value[0]));
+   assert(!IS_INF_OR_NAN(value[0]));
+   assert(!IS_INF_OR_NAN(value[0]));
+#endif
+
    if (writeMask & WRITEMASK_X)
       dst[0] = value[0];
    if (writeMask & WRITEMASK_Y)
@@ -832,10 +846,14 @@ _mesa_execute_program(GLcontext * ctx,
          break;
       case OPCODE_EX2:         /* Exponential base 2 */
          {
-            GLfloat a[4], result[4];
+            GLfloat a[4], result[4], val;
             fetch_vector1(&inst->SrcReg[0], machine, a);
-            result[0] = result[1] = result[2] = result[3] =
-               (GLfloat) _mesa_pow(2.0, a[0]);
+            val = (GLfloat) _mesa_pow(2.0, a[0]);
+            /*
+            if (IS_INF_OR_NAN(val))
+               val = 1.0e10;
+            */
+            result[0] = result[1] = result[2] = result[3] = val;
             store_vector4(inst, machine, result);
          }
          break;
@@ -911,12 +929,17 @@ _mesa_execute_program(GLcontext * ctx,
          break;
       case OPCODE_LG2:         /* log base 2 */
          {
-            GLfloat a[4], result[4];
+            GLfloat a[4], result[4], val;
             fetch_vector1(&inst->SrcReg[0], machine, a);
            /* The fast LOG2 macro doesn't meet the precision requirements.
             */
-            result[0] = result[1] = result[2] = result[3] =
-               (log(a[0]) * 1.442695F);
+            if (a[0] == 0.0F) {
+               val = 0.0F;
+            }
+            else {
+               val = log(a[0]) * 1.442695F;
+            }
+            result[0] = result[1] = result[2] = result[3] = val;
             store_vector4(inst, machine, result);
          }
          break;
index ae3a003feedc3ad546e201007e1c9e41fd386aed..44c961927a382c6532aed5c89443da2d2ae3c732 100644 (file)
@@ -343,7 +343,10 @@ _mesa_opcode_string(gl_inst_opcode opcode)
 {
    if (opcode < MAX_OPCODE)
       return InstInfo[opcode].Name;
-   else
-      return "OP?";
+   else {
+      static char s[20];
+      _mesa_snprintf(s, sizeof(s), "OP%u", opcode);
+      return s;
+   }
 }
 
index 6ba2e76ff969a3c50b998c09b103d755898aa0d8..be903106a08d55467b727158ee9946ae1ac25362 100644 (file)
@@ -547,15 +547,13 @@ update_interval(GLint intBegin[], GLint intEnd[], GLuint index, GLuint ic)
 
 
 /**
- * Find the live intervals for each temporary register in the program.
- * For register R, the interval [A,B] indicates that R is referenced
- * from instruction A through instruction B.
- * Special consideration is needed for loops and subroutines.
- * \return GL_TRUE if success, GL_FALSE if we cannot proceed for some reason
+ * Find first/last instruction that references each temporary register.
  */
-static GLboolean
-find_live_intervals(struct gl_program *prog,
-                    struct interval_list *liveIntervals)
+GLboolean
+_mesa_find_temp_intervals(const struct prog_instruction *instructions,
+                          GLuint numInstructions,
+                          GLint intBegin[MAX_PROGRAM_TEMPS],
+                          GLint intEnd[MAX_PROGRAM_TEMPS])
 {
    struct loop_info
    {
@@ -563,26 +561,15 @@ find_live_intervals(struct gl_program *prog,
    };
    struct loop_info loopStack[MAX_LOOP_NESTING];
    GLuint loopStackDepth = 0;
-   GLint intBegin[MAX_PROGRAM_TEMPS], intEnd[MAX_PROGRAM_TEMPS];
    GLuint i;
 
-   /*
-    * Note: we'll return GL_FALSE below if we find relative indexing
-    * into the TEMP register file.  We can't handle that yet.
-    * We also give up on subroutines for now.
-    */
-
-   if (dbg) {
-      _mesa_printf("Optimize: Begin find intervals\n");
-   }
-
    for (i = 0; i < MAX_PROGRAM_TEMPS; i++){
       intBegin[i] = intEnd[i] = -1;
    }
 
    /* Scan instructions looking for temporary registers */
-   for (i = 0; i < prog->NumInstructions; i++) {
-      const struct prog_instruction *inst = prog->Instructions + i;
+   for (i = 0; i < numInstructions; i++) {
+      const struct prog_instruction *inst = instructions + i;
       if (inst->Opcode == OPCODE_BGNLOOP) {
          loopStack[loopStackDepth].Start = i;
          loopStack[loopStackDepth].End = inst->BranchTarget;
@@ -595,7 +582,7 @@ find_live_intervals(struct gl_program *prog,
          return GL_FALSE;
       }
       else {
-         const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode);
+         const GLuint numSrc = 3;/*_mesa_num_inst_src_regs(inst->Opcode);*/
          GLuint j;
          for (j = 0; j < numSrc; j++) {
             if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) {
@@ -624,6 +611,39 @@ find_live_intervals(struct gl_program *prog,
       }
    }
 
+   return GL_TRUE;
+}
+
+
+/**
+ * Find the live intervals for each temporary register in the program.
+ * For register R, the interval [A,B] indicates that R is referenced
+ * from instruction A through instruction B.
+ * Special consideration is needed for loops and subroutines.
+ * \return GL_TRUE if success, GL_FALSE if we cannot proceed for some reason
+ */
+static GLboolean
+find_live_intervals(struct gl_program *prog,
+                    struct interval_list *liveIntervals)
+{
+   GLint intBegin[MAX_PROGRAM_TEMPS], intEnd[MAX_PROGRAM_TEMPS];
+   GLuint i;
+
+   /*
+    * Note: we'll return GL_FALSE below if we find relative indexing
+    * into the TEMP register file.  We can't handle that yet.
+    * We also give up on subroutines for now.
+    */
+
+   if (dbg) {
+      _mesa_printf("Optimize: Begin find intervals\n");
+   }
+
+   /* build intermediate arrays */
+   if (!_mesa_find_temp_intervals(prog->Instructions, prog->NumInstructions,
+                                  intBegin, intEnd))
+      return GL_FALSE;
+
    /* Build live intervals list from intermediate arrays */
    liveIntervals->Num = 0;
    for (i = 0; i < MAX_PROGRAM_TEMPS; i++) {
@@ -792,8 +812,6 @@ _mesa_reallocate_registers(struct gl_program *prog)
 }
 
 
-
-
 /**
  * Apply optimizations to the given program to eliminate unnecessary
  * instructions, temp regs, etc.
index d102cfd9fc13fdaf19c76e8387dee8fc4841b6a7..43894a2723772f34cca1a397880c8da867a10d20 100644 (file)
 #ifndef PROG_OPT_H
 #define PROG_OPT_H
 
+
+#include "main/config.h"
+
+
 struct gl_program;
+struct prog_instruction;
+
+
+extern GLboolean
+_mesa_find_temp_intervals(const struct prog_instruction *instructions,
+                          GLuint numInstructions,
+                          GLint intBegin[MAX_PROGRAM_TEMPS],
+                          GLint intEnd[MAX_PROGRAM_TEMPS]);
 
 extern void
 _mesa_optimize_program(GLcontext *ctx, struct gl_program *program);
index 9967f2978de819be589ee71a45020ab56a256c51..de7fef1f861e1c133405fc100b673cb95e6a1fb3 100644 (file)
@@ -75,7 +75,11 @@ file_string(gl_register_file f, gl_prog_print_mode mode)
    case PROGRAM_UNDEFINED:
       return "UNDEFINED";
    default:
-      return "Unknown program file!";
+      {
+         static char s[20];
+         _mesa_snprintf(s, sizeof(s), "FILE%u", f);
+         return s;
+      }
    }
 }
 
@@ -736,7 +740,10 @@ _mesa_fprint_instruction_opt(FILE *f,
                                 mode, prog);
       }
       else {
-         _mesa_fprintf(f, "Other opcode %d\n", inst->Opcode);
+         fprint_alu_instruction(f, inst,
+                                _mesa_opcode_string(inst->Opcode),
+                                3/*_mesa_num_inst_src_regs(inst->Opcode)*/,
+                                mode, prog);
       }
       break;
    }
@@ -941,6 +948,10 @@ _mesa_write_shader_to_file(const struct gl_shader *shader)
       fprintf(f, "/*\n");
       _mesa_fprint_program_opt(f, shader->Program, PROG_PRINT_DEBUG, GL_TRUE);
       fprintf(f, "*/\n");
+      fprintf(f, "/* Parameters / constants */\n");
+      fprintf(f, "/*\n");
+      _mesa_fprint_parameter_list(f, shader->Program->Parameters);
+      fprintf(f, "*/\n");
    }
 
    fclose(f);
index 644cd39185cf163c406d4ef85a4565247886c207..a8390d30942796df7095d3cad392a05af6ad9391 100644 (file)
@@ -1487,7 +1487,7 @@ _mesa_use_program(GLcontext *ctx, GLuint program)
       return;
    }
 
-   FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+   FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
 
    if (program) {
       shProg = _mesa_lookup_shader_program_err(ctx, program, "glUseProgram");
@@ -1509,6 +1509,10 @@ _mesa_use_program(GLcontext *ctx, GLuint program)
                          shProg->Shaders[i]->Name,
                          shProg->Shaders[i]->Type);
          }
+         if (shProg->VertexProgram)
+            printf(" vert prog %u\n", shProg->VertexProgram->Base.Id);
+         if (shProg->FragmentProgram)
+            printf(" frag prog %u\n", shProg->FragmentProgram->Base.Id);
       }
    }
    else {
@@ -1789,7 +1793,7 @@ _mesa_uniform(GLcontext *ctx, GLint location, GLsizei count,
       return;
    }
 
-   FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
+   FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
 
    uniform = &shProg->Uniforms->Uniforms[location];
 
@@ -1929,7 +1933,7 @@ _mesa_uniform_matrix(GLcontext *ctx, GLint cols, GLint rows,
       return;
    }
 
-   FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
+   FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
 
    uniform = &shProg->Uniforms->Uniforms[location];
 
index 1fdf4db054c3a722d521f0e041621bed571f7fb2..5ea89d2ff3e6b1aaef52a81350b21b92a49dcba0 100644 (file)
@@ -97,7 +97,8 @@ bits_agree(GLbitfield flags1, GLbitfield flags2, GLbitfield bit)
  * which inputs are centroid-sampled, invariant, etc.
  */
 static GLboolean
-link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog)
+link_varying_vars(GLcontext *ctx,
+                  struct gl_shader_program *shProg, struct gl_program *prog)
 {
    GLuint *map, i, firstVarying, newFile;
    GLbitfield *inOutFlags;
@@ -156,8 +157,12 @@ link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog)
                                var->Flags);
       }
 
+      if (shProg->Varying->NumParameters > ctx->Const.MaxVarying) {
+         link_error(shProg, "Too many varying variables");
+         return GL_FALSE;
+      }
+
       /* Map varying[i] to varying[j].
-       * Plus, set prog->Input/OutputFlags[] as described above.
        * Note: the loop here takes care of arrays or large (sz>4) vars.
        */
       {
@@ -319,7 +324,7 @@ _slang_resolve_attributes(struct gl_shader_program *shProg,
                           const struct gl_program *origProg,
                           struct gl_program *linkedProg)
 {
-   GLint attribMap[MAX_VERTEX_ATTRIBS];
+   GLint attribMap[MAX_VERTEX_GENERIC_ATTRIBS];
    GLuint i, j;
    GLbitfield usedAttributes; /* generics only, not legacy attributes */
 
@@ -355,7 +360,7 @@ _slang_resolve_attributes(struct gl_shader_program *shProg,
    }
 
    /* initialize the generic attribute map entries to -1 */
-   for (i = 0; i < MAX_VERTEX_ATTRIBS; i++) {
+   for (i = 0; i < MAX_VERTEX_GENERIC_ATTRIBS; i++) {
       attribMap[i] = -1;
    }
 
@@ -396,11 +401,11 @@ _slang_resolve_attributes(struct gl_shader_program *shProg,
                    * Start at 1 since generic attribute 0 always aliases
                    * glVertex/position.
                    */
-                  for (attr = 0; attr < MAX_VERTEX_ATTRIBS; attr++) {
+                  for (attr = 0; attr < MAX_VERTEX_GENERIC_ATTRIBS; attr++) {
                      if (((1 << attr) & usedAttributes) == 0)
                         break;
                   }
-                  if (attr == MAX_VERTEX_ATTRIBS) {
+                  if (attr == MAX_VERTEX_GENERIC_ATTRIBS) {
                      link_error(shProg, "Too many vertex attributes");
                      return GL_FALSE;
                   }
@@ -712,6 +717,8 @@ _slang_link(GLcontext *ctx,
       struct gl_vertex_program *linked_vprog =
          vertex_program(_mesa_clone_program(ctx, &vertProg->Base));
       shProg->VertexProgram = linked_vprog; /* refcount OK */
+      /* vertex program ID not significant; just set Id for debugging purposes */
+      shProg->VertexProgram->Base.Id = shProg->Name;
       ASSERT(shProg->VertexProgram->Base.RefCount == 1);
    }
 
@@ -720,16 +727,18 @@ _slang_link(GLcontext *ctx,
       struct gl_fragment_program *linked_fprog = 
          fragment_program(_mesa_clone_program(ctx, &fragProg->Base));
       shProg->FragmentProgram = linked_fprog; /* refcount OK */
+      /* vertex program ID not significant; just set Id for debugging purposes */
+      shProg->FragmentProgram->Base.Id = shProg->Name;
       ASSERT(shProg->FragmentProgram->Base.RefCount == 1);
    }
 
    /* link varying vars */
    if (shProg->VertexProgram) {
-      if (!link_varying_vars(shProg, &shProg->VertexProgram->Base))
+      if (!link_varying_vars(ctx, shProg, &shProg->VertexProgram->Base))
          return;
    }
    if (shProg->FragmentProgram) {
-      if (!link_varying_vars(shProg, &shProg->FragmentProgram->Base))
+      if (!link_varying_vars(ctx, shProg, &shProg->FragmentProgram->Base))
          return;
    }
 
index 493e094cde5ce9818ac80534d2e365411b23665e..1771c576ab225d15186ccd6b53e707901b9dd0ed 100644 (file)
@@ -759,23 +759,26 @@ gl_dispatch_functions_start:
        GL_STUB(glGetAttribLocationARB, _gloffset_GetAttribLocationARB)
        GL_STUB(glDrawBuffersARB, _gloffset_DrawBuffersARB)
        GL_STUB(glRenderbufferStorageMultisample, _gloffset_RenderbufferStorageMultisample)
+       GL_STUB(glFlushMappedBufferRange, _gloffset_FlushMappedBufferRange)
+       GL_STUB(glMapBufferRange, _gloffset_MapBufferRange)
+       GL_STUB(glCopyBufferSubData, _gloffset_CopyBufferSubData)
        GL_STUB(glPolygonOffsetEXT, _gloffset_PolygonOffsetEXT)
-       GL_STUB(gl_dispatch_stub_563, _gloffset_GetPixelTexGenParameterfvSGIS)
-       HIDDEN(gl_dispatch_stub_563)
-       GL_STUB(gl_dispatch_stub_564, _gloffset_GetPixelTexGenParameterivSGIS)
-       HIDDEN(gl_dispatch_stub_564)
-       GL_STUB(gl_dispatch_stub_565, _gloffset_PixelTexGenParameterfSGIS)
-       HIDDEN(gl_dispatch_stub_565)
-       GL_STUB(gl_dispatch_stub_566, _gloffset_PixelTexGenParameterfvSGIS)
+       GL_STUB(gl_dispatch_stub_566, _gloffset_GetPixelTexGenParameterfvSGIS)
        HIDDEN(gl_dispatch_stub_566)
-       GL_STUB(gl_dispatch_stub_567, _gloffset_PixelTexGenParameteriSGIS)
+       GL_STUB(gl_dispatch_stub_567, _gloffset_GetPixelTexGenParameterivSGIS)
        HIDDEN(gl_dispatch_stub_567)
-       GL_STUB(gl_dispatch_stub_568, _gloffset_PixelTexGenParameterivSGIS)
+       GL_STUB(gl_dispatch_stub_568, _gloffset_PixelTexGenParameterfSGIS)
        HIDDEN(gl_dispatch_stub_568)
-       GL_STUB(gl_dispatch_stub_569, _gloffset_SampleMaskSGIS)
+       GL_STUB(gl_dispatch_stub_569, _gloffset_PixelTexGenParameterfvSGIS)
        HIDDEN(gl_dispatch_stub_569)
-       GL_STUB(gl_dispatch_stub_570, _gloffset_SamplePatternSGIS)
+       GL_STUB(gl_dispatch_stub_570, _gloffset_PixelTexGenParameteriSGIS)
        HIDDEN(gl_dispatch_stub_570)
+       GL_STUB(gl_dispatch_stub_571, _gloffset_PixelTexGenParameterivSGIS)
+       HIDDEN(gl_dispatch_stub_571)
+       GL_STUB(gl_dispatch_stub_572, _gloffset_SampleMaskSGIS)
+       HIDDEN(gl_dispatch_stub_572)
+       GL_STUB(gl_dispatch_stub_573, _gloffset_SamplePatternSGIS)
+       HIDDEN(gl_dispatch_stub_573)
        GL_STUB(glColorPointerEXT, _gloffset_ColorPointerEXT)
        GL_STUB(glEdgeFlagPointerEXT, _gloffset_EdgeFlagPointerEXT)
        GL_STUB(glIndexPointerEXT, _gloffset_IndexPointerEXT)
@@ -786,10 +789,10 @@ gl_dispatch_functions_start:
        GL_STUB(glPointParameterfvEXT, _gloffset_PointParameterfvEXT)
        GL_STUB(glLockArraysEXT, _gloffset_LockArraysEXT)
        GL_STUB(glUnlockArraysEXT, _gloffset_UnlockArraysEXT)
-       GL_STUB(gl_dispatch_stub_581, _gloffset_CullParameterdvEXT)
-       HIDDEN(gl_dispatch_stub_581)
-       GL_STUB(gl_dispatch_stub_582, _gloffset_CullParameterfvEXT)
-       HIDDEN(gl_dispatch_stub_582)
+       GL_STUB(gl_dispatch_stub_584, _gloffset_CullParameterdvEXT)
+       HIDDEN(gl_dispatch_stub_584)
+       GL_STUB(gl_dispatch_stub_585, _gloffset_CullParameterfvEXT)
+       HIDDEN(gl_dispatch_stub_585)
        GL_STUB(glSecondaryColor3bEXT, _gloffset_SecondaryColor3bEXT)
        GL_STUB(glSecondaryColor3bvEXT, _gloffset_SecondaryColor3bvEXT)
        GL_STUB(glSecondaryColor3dEXT, _gloffset_SecondaryColor3dEXT)
@@ -814,8 +817,8 @@ gl_dispatch_functions_start:
        GL_STUB(glFogCoorddvEXT, _gloffset_FogCoorddvEXT)
        GL_STUB(glFogCoordfEXT, _gloffset_FogCoordfEXT)
        GL_STUB(glFogCoordfvEXT, _gloffset_FogCoordfvEXT)
-       GL_STUB(gl_dispatch_stub_607, _gloffset_PixelTexGenSGIX)
-       HIDDEN(gl_dispatch_stub_607)
+       GL_STUB(gl_dispatch_stub_610, _gloffset_PixelTexGenSGIX)
+       HIDDEN(gl_dispatch_stub_610)
        GL_STUB(glBlendFuncSeparateEXT, _gloffset_BlendFuncSeparateEXT)
        GL_STUB(glFlushVertexArrayRangeNV, _gloffset_FlushVertexArrayRangeNV)
        GL_STUB(glVertexArrayRangeNV, _gloffset_VertexArrayRangeNV)
@@ -857,24 +860,24 @@ gl_dispatch_functions_start:
        GL_STUB(glWindowPos4ivMESA, _gloffset_WindowPos4ivMESA)
        GL_STUB(glWindowPos4sMESA, _gloffset_WindowPos4sMESA)
        GL_STUB(glWindowPos4svMESA, _gloffset_WindowPos4svMESA)
-       GL_STUB(gl_dispatch_stub_649, _gloffset_MultiModeDrawArraysIBM)
-       HIDDEN(gl_dispatch_stub_649)
-       GL_STUB(gl_dispatch_stub_650, _gloffset_MultiModeDrawElementsIBM)
-       HIDDEN(gl_dispatch_stub_650)
-       GL_STUB(gl_dispatch_stub_651, _gloffset_DeleteFencesNV)
-       HIDDEN(gl_dispatch_stub_651)
-       GL_STUB(gl_dispatch_stub_652, _gloffset_FinishFenceNV)
+       GL_STUB(gl_dispatch_stub_652, _gloffset_MultiModeDrawArraysIBM)
        HIDDEN(gl_dispatch_stub_652)
-       GL_STUB(gl_dispatch_stub_653, _gloffset_GenFencesNV)
+       GL_STUB(gl_dispatch_stub_653, _gloffset_MultiModeDrawElementsIBM)
        HIDDEN(gl_dispatch_stub_653)
-       GL_STUB(gl_dispatch_stub_654, _gloffset_GetFenceivNV)
+       GL_STUB(gl_dispatch_stub_654, _gloffset_DeleteFencesNV)
        HIDDEN(gl_dispatch_stub_654)
-       GL_STUB(gl_dispatch_stub_655, _gloffset_IsFenceNV)
+       GL_STUB(gl_dispatch_stub_655, _gloffset_FinishFenceNV)
        HIDDEN(gl_dispatch_stub_655)
-       GL_STUB(gl_dispatch_stub_656, _gloffset_SetFenceNV)
+       GL_STUB(gl_dispatch_stub_656, _gloffset_GenFencesNV)
        HIDDEN(gl_dispatch_stub_656)
-       GL_STUB(gl_dispatch_stub_657, _gloffset_TestFenceNV)
+       GL_STUB(gl_dispatch_stub_657, _gloffset_GetFenceivNV)
        HIDDEN(gl_dispatch_stub_657)
+       GL_STUB(gl_dispatch_stub_658, _gloffset_IsFenceNV)
+       HIDDEN(gl_dispatch_stub_658)
+       GL_STUB(gl_dispatch_stub_659, _gloffset_SetFenceNV)
+       HIDDEN(gl_dispatch_stub_659)
+       GL_STUB(gl_dispatch_stub_660, _gloffset_TestFenceNV)
+       HIDDEN(gl_dispatch_stub_660)
        GL_STUB(glAreProgramsResidentNV, _gloffset_AreProgramsResidentNV)
        GL_STUB(glBindProgramNV, _gloffset_BindProgramNV)
        GL_STUB(glDeleteProgramsNV, _gloffset_DeleteProgramsNV)
@@ -955,26 +958,26 @@ gl_dispatch_functions_start:
        GL_STUB(glSetFragmentShaderConstantATI, _gloffset_SetFragmentShaderConstantATI)
        GL_STUB(glPointParameteriNV, _gloffset_PointParameteriNV)
        GL_STUB(glPointParameterivNV, _gloffset_PointParameterivNV)
-       GL_STUB(gl_dispatch_stub_738, _gloffset_ActiveStencilFaceEXT)
-       HIDDEN(gl_dispatch_stub_738)
-       GL_STUB(gl_dispatch_stub_739, _gloffset_BindVertexArrayAPPLE)
-       HIDDEN(gl_dispatch_stub_739)
-       GL_STUB(gl_dispatch_stub_740, _gloffset_DeleteVertexArraysAPPLE)
-       HIDDEN(gl_dispatch_stub_740)
-       GL_STUB(gl_dispatch_stub_741, _gloffset_GenVertexArraysAPPLE)
+       GL_STUB(gl_dispatch_stub_741, _gloffset_ActiveStencilFaceEXT)
        HIDDEN(gl_dispatch_stub_741)
-       GL_STUB(gl_dispatch_stub_742, _gloffset_IsVertexArrayAPPLE)
+       GL_STUB(gl_dispatch_stub_742, _gloffset_BindVertexArrayAPPLE)
        HIDDEN(gl_dispatch_stub_742)
+       GL_STUB(gl_dispatch_stub_743, _gloffset_DeleteVertexArraysAPPLE)
+       HIDDEN(gl_dispatch_stub_743)
+       GL_STUB(gl_dispatch_stub_744, _gloffset_GenVertexArraysAPPLE)
+       HIDDEN(gl_dispatch_stub_744)
+       GL_STUB(gl_dispatch_stub_745, _gloffset_IsVertexArrayAPPLE)
+       HIDDEN(gl_dispatch_stub_745)
        GL_STUB(glGetProgramNamedParameterdvNV, _gloffset_GetProgramNamedParameterdvNV)
        GL_STUB(glGetProgramNamedParameterfvNV, _gloffset_GetProgramNamedParameterfvNV)
        GL_STUB(glProgramNamedParameter4dNV, _gloffset_ProgramNamedParameter4dNV)
        GL_STUB(glProgramNamedParameter4dvNV, _gloffset_ProgramNamedParameter4dvNV)
        GL_STUB(glProgramNamedParameter4fNV, _gloffset_ProgramNamedParameter4fNV)
        GL_STUB(glProgramNamedParameter4fvNV, _gloffset_ProgramNamedParameter4fvNV)
-       GL_STUB(gl_dispatch_stub_749, _gloffset_DepthBoundsEXT)
-       HIDDEN(gl_dispatch_stub_749)
-       GL_STUB(gl_dispatch_stub_750, _gloffset_BlendEquationSeparateEXT)
-       HIDDEN(gl_dispatch_stub_750)
+       GL_STUB(gl_dispatch_stub_752, _gloffset_DepthBoundsEXT)
+       HIDDEN(gl_dispatch_stub_752)
+       GL_STUB(gl_dispatch_stub_753, _gloffset_BlendEquationSeparateEXT)
+       HIDDEN(gl_dispatch_stub_753)
        GL_STUB(glBindFramebufferEXT, _gloffset_BindFramebufferEXT)
        GL_STUB(glBindRenderbufferEXT, _gloffset_BindRenderbufferEXT)
        GL_STUB(glCheckFramebufferStatusEXT, _gloffset_CheckFramebufferStatusEXT)
@@ -992,19 +995,19 @@ gl_dispatch_functions_start:
        GL_STUB(glIsFramebufferEXT, _gloffset_IsFramebufferEXT)
        GL_STUB(glIsRenderbufferEXT, _gloffset_IsRenderbufferEXT)
        GL_STUB(glRenderbufferStorageEXT, _gloffset_RenderbufferStorageEXT)
-       GL_STUB(gl_dispatch_stub_768, _gloffset_BlitFramebufferEXT)
-       HIDDEN(gl_dispatch_stub_768)
-       GL_STUB(glFramebufferTextureLayerEXT, _gloffset_FramebufferTextureLayerEXT)
-       GL_STUB(gl_dispatch_stub_770, _gloffset_StencilFuncSeparateATI)
-       HIDDEN(gl_dispatch_stub_770)
-       GL_STUB(gl_dispatch_stub_771, _gloffset_ProgramEnvParameters4fvEXT)
+       GL_STUB(gl_dispatch_stub_771, _gloffset_BlitFramebufferEXT)
        HIDDEN(gl_dispatch_stub_771)
-       GL_STUB(gl_dispatch_stub_772, _gloffset_ProgramLocalParameters4fvEXT)
-       HIDDEN(gl_dispatch_stub_772)
-       GL_STUB(gl_dispatch_stub_773, _gloffset_GetQueryObjecti64vEXT)
+       GL_STUB(glFramebufferTextureLayerEXT, _gloffset_FramebufferTextureLayerEXT)
+       GL_STUB(gl_dispatch_stub_773, _gloffset_StencilFuncSeparateATI)
        HIDDEN(gl_dispatch_stub_773)
-       GL_STUB(gl_dispatch_stub_774, _gloffset_GetQueryObjectui64vEXT)
+       GL_STUB(gl_dispatch_stub_774, _gloffset_ProgramEnvParameters4fvEXT)
        HIDDEN(gl_dispatch_stub_774)
+       GL_STUB(gl_dispatch_stub_775, _gloffset_ProgramLocalParameters4fvEXT)
+       HIDDEN(gl_dispatch_stub_775)
+       GL_STUB(gl_dispatch_stub_776, _gloffset_GetQueryObjecti64vEXT)
+       HIDDEN(gl_dispatch_stub_776)
+       GL_STUB(gl_dispatch_stub_777, _gloffset_GetQueryObjectui64vEXT)
+       HIDDEN(gl_dispatch_stub_777)
        GL_STUB_ALIAS(glArrayElementEXT, glArrayElement)
        GL_STUB_ALIAS(glBindTextureEXT, glBindTexture)
        GL_STUB_ALIAS(glDrawArraysEXT, glDrawArrays)
index 3ba7b2692856bda0defeadf6736a7a1d869b98c6..5d4d8eee02f5f9def23e1dea8c4f127ebfb8346d 100644 (file)
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  * 
  **************************************************************************/
- /*
-  * Authors:
-  *   Keith Whitwell <keith@tungstengraphics.com>
-  *   Brian Paul
-  */
+
+/*
+ * Authors:
+ *   Keith Whitwell <keith@tungstengraphics.com>
+ *   Brian Paul
+ */
 
 #include "main/imports.h"
 #include "shader/prog_parameter.h"
 #include "st_program.h"
 #include "st_inlines.h"
 
+
 /**
  * Pass the given program parameters to the graphics pipe as a
  * constant buffer.
- * \param id  either PIPE_SHADER_VERTEX or PIPE_SHADER_FRAGMENT
+ * \param shader_type  either PIPE_SHADER_VERTEX or PIPE_SHADER_FRAGMENT
  */
 void st_upload_constants( struct st_context *st,
                           struct gl_program_parameter_list *params,
-                          unsigned id)
+                          unsigned shader_type)
 {
    struct pipe_context *pipe = st->pipe;
-   struct pipe_constant_buffer *cbuf = &st->state.constants[id];
+   struct pipe_constant_buffer *cbuf = &st->state.constants[shader_type];
 
-   assert(id == PIPE_SHADER_VERTEX || id == PIPE_SHADER_FRAGMENT);
+   assert(shader_type == PIPE_SHADER_VERTEX ||
+          shader_type == PIPE_SHADER_FRAGMENT);
 
    /* update constants */
    if (params && params->NumParameters) {
@@ -68,13 +71,14 @@ void st_upload_constants( struct st_context *st,
        * avoid gratuitous rendering synchronization.
        */
       pipe_buffer_reference(&cbuf->buffer, NULL );
-      cbuf->buffer = pipe_buffer_create(pipe->screen, 16, PIPE_BUFFER_USAGE_CONSTANT,
+      cbuf->buffer = pipe_buffer_create(pipe->screen, 16,
+                                        PIPE_BUFFER_USAGE_CONSTANT,
                                        paramBytes );
 
-      if (0)
-      {
-        printf("%s(shader=%d, numParams=%d, stateFlags=0x%x)\n", 
-                __FUNCTION__, id, params->NumParameters, params->StateFlags);
+      if (0) {
+        debug_printf("%s(shader=%d, numParams=%d, stateFlags=0x%x)\n", 
+                      __FUNCTION__, shader_type, params->NumParameters,
+                      params->StateFlags);
          _mesa_print_parameter_list(params);
       }
 
@@ -84,15 +88,16 @@ void st_upload_constants( struct st_context *st,
                                       0, paramBytes,
                                       params->ParameterValues);
 
-      st->pipe->set_constant_buffer(st->pipe, id, 0, cbuf);
+      st->pipe->set_constant_buffer(st->pipe, shader_type, 0, cbuf);
    }
    else {
-      st->constants.tracked_state[id].dirty.mesa = 0;
-      //  st->pipe->set_constant_buffer(st->pipe, id, 0, NULL);
+      st->constants.tracked_state[shader_type].dirty.mesa = 0x0;
    }
 }
 
-/* Vertex shader:
+
+/**
+ * Vertex shader:
  */
 static void update_vs_constants(struct st_context *st )
 {
@@ -102,6 +107,7 @@ static void update_vs_constants(struct st_context *st )
    st_upload_constants( st, params, PIPE_SHADER_VERTEX );
 }
 
+
 const struct st_tracked_state st_update_vs_constants = {
    "st_update_vs_constants",                           /* name */
    {                                                   /* dirty */
@@ -111,7 +117,10 @@ const struct st_tracked_state st_update_vs_constants = {
    update_vs_constants                                 /* update */
 };
 
-/* Fragment shader:
+
+
+/**
+ * Fragment shader:
  */
 static void update_fs_constants(struct st_context *st )
 {
@@ -121,6 +130,7 @@ static void update_fs_constants(struct st_context *st )
    st_upload_constants( st, params, PIPE_SHADER_FRAGMENT );
 }
 
+
 const struct st_tracked_state st_update_fs_constants = {
    "st_update_fs_constants",                           /* name */
    {                                                   /* dirty */
index 536293683e9c2e2d0ad3db83f02809dafb1e6c56..4d897b677e0a3cc0abc0927cbc9978e3fc6c13eb 100644 (file)
@@ -122,6 +122,7 @@ update_framebuffer_state( struct st_context *st )
                                    strb->surface);
             framebuffer->nr_cbufs++;
          }
+         strb->defined = GL_TRUE; /* we'll be drawing something */
       }
    }
    for (i = framebuffer->nr_cbufs; i < PIPE_MAX_COLOR_BUFS; i++) {
index 19a0e6736237b3f6fab4596442b549c0b2db4359..7021d732089507f7c37fab3cec4ad743359aaddf 100644 (file)
  **************************************************************************/
 
 
+/**
+ * Functions for pixel buffer objects and vertex/element buffer objects.
+ */
+
+
 #include "main/imports.h"
 #include "main/mtypes.h"
+#include "main/arrayobj.h"
 #include "main/bufferobj.h"
 
 #include "st_inlines.h"
 #include "pipe/p_inlines.h"
 
 
-
-/* Pixel buffers and Vertex/index buffers are handled through these
- * mesa callbacks.  Framebuffer/Renderbuffer objects are
- * created/managed elsewhere.
- */
-
-
-
 /**
  * There is some duplication between mesa's bufferobjects and our
  * bufmgr buffers.  Both have an integer handle and a hashtable to
@@ -190,7 +188,7 @@ st_bufferobj_map(GLcontext *ctx, GLenum target, GLenum access,
                  struct gl_buffer_object *obj)
 {
    struct st_buffer_object *st_obj = st_buffer_object(obj);
-   GLuint flags;
+   uint flags;
 
    switch (access) {
    case GL_WRITE_ONLY:
@@ -209,7 +207,7 @@ st_bufferobj_map(GLcontext *ctx, GLenum target, GLenum access,
    obj->Pointer = st_cond_flush_pipe_buffer_map(st_context(ctx),
                                                st_obj->buffer,
                                                flags);
-   if(obj->Pointer) {
+   if (obj->Pointer) {
       obj->Offset = 0;
       obj->Length = obj->Size;
    }
@@ -217,7 +215,6 @@ st_bufferobj_map(GLcontext *ctx, GLenum target, GLenum access,
 }
 
 
-
 /**
  * Called via glMapBufferRange().
  */
@@ -228,7 +225,7 @@ st_bufferobj_map_range(GLcontext *ctx, GLenum target,
 {
    struct pipe_context *pipe = st_context(ctx)->pipe;
    struct st_buffer_object *st_obj = st_buffer_object(obj);
-   GLuint flags = 0;
+   uint flags = 0x0;
    char *map;
 
    if (access & GL_MAP_WRITE_BIT)
@@ -294,6 +291,43 @@ st_bufferobj_unmap(GLcontext *ctx, GLenum target, struct gl_buffer_object *obj)
 }
 
 
+/**
+ * Called via glCopyBufferSubData().
+ */
+static void
+st_copy_buffer_subdata(GLcontext *ctx,
+                       struct gl_buffer_object *src,
+                       struct gl_buffer_object *dst,
+                       GLintptr readOffset, GLintptr writeOffset,
+                       GLsizeiptr size)
+{
+   struct pipe_context *pipe = st_context(ctx)->pipe;
+   struct st_buffer_object *srcObj = st_buffer_object(src);
+   struct st_buffer_object *dstObj = st_buffer_object(dst);
+   ubyte *srcPtr, *dstPtr;
+
+   /* buffer should not already be mapped */
+   assert(!src->Pointer);
+   assert(!dst->Pointer);
+
+   srcPtr = (ubyte *) pipe_buffer_map_range(pipe->screen,
+                                            srcObj->buffer,
+                                            readOffset, size,
+                                            PIPE_BUFFER_USAGE_CPU_READ);
+
+   dstPtr = (ubyte *) pipe_buffer_map_range(pipe->screen,
+                                            dstObj->buffer,
+                                            writeOffset, size,
+                                            PIPE_BUFFER_USAGE_CPU_WRITE);
+
+   if (srcPtr && dstPtr)
+      _mesa_memcpy(dstPtr + writeOffset, srcPtr + readOffset, size);
+
+   pipe_buffer_unmap(pipe->screen, srcObj->buffer);
+   pipe_buffer_unmap(pipe->screen, dstObj->buffer);
+}
+
+
 void
 st_init_bufferobject_functions(struct dd_function_table *functions)
 {
@@ -306,4 +340,9 @@ st_init_bufferobject_functions(struct dd_function_table *functions)
    functions->MapBufferRange = st_bufferobj_map_range;
    functions->FlushMappedBufferRange = st_bufferobj_flush_mapped_range;
    functions->UnmapBuffer = st_bufferobj_unmap;
+   functions->CopyBufferSubData = st_copy_buffer_subdata;
+
+   /* For GL_APPLE_vertex_array_object */
+   functions->NewArrayObject = _mesa_new_array_object;
+   functions->DeleteArrayObject = _mesa_delete_array_object;
 }
index 21ddf2fc7a28c59ebd2c0ecce4c18dad3976d5f6..ecdb988033cdff4e9e3529fffd761a38e87b9be7 100644 (file)
@@ -100,6 +100,8 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    strb->Base.Height = height;
    init_renderbuffer_bits(strb, format);
 
+   strb->defined = GL_FALSE;  /* undefined contents now */
+
    if(strb->software) {
       struct pipe_format_block block;
       size_t size;
@@ -463,6 +465,134 @@ st_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
 }
 
 
+/**
+ * Copy back color buffer to front color buffer.
+ */
+static void
+copy_back_to_front(struct st_context *st,
+                   struct gl_framebuffer *fb,
+                   gl_buffer_index frontIndex,
+                   gl_buffer_index backIndex)
+
+{
+   struct st_framebuffer *stfb = (struct st_framebuffer *) fb;
+   struct pipe_surface *surf_front, *surf_back;
+
+   (void) st_get_framebuffer_surface(stfb, frontIndex, &surf_front);
+   (void) st_get_framebuffer_surface(stfb, backIndex, &surf_back);
+
+   if (surf_front && surf_back) {
+      st->pipe->surface_copy(st->pipe,
+                             surf_front, 0, 0,  /* dest */
+                             surf_back, 0, 0,   /* src */
+                             fb->Width, fb->Height);
+   }
+}
+
+
+/**
+ * Check if we're drawing into, or read from, a front color buffer.  If the
+ * front buffer is missing, create it now.
+ *
+ * The back color buffer must exist since we'll use its format/samples info
+ * for creating the front buffer.
+ *
+ * \param frontIndex  either BUFFER_FRONT_LEFT or BUFFER_FRONT_RIGHT
+ * \param backIndex  either BUFFER_BACK_LEFT or BUFFER_BACK_RIGHT
+ */
+static void
+check_create_front_buffer(GLcontext *ctx, struct gl_framebuffer *fb,
+                          gl_buffer_index frontIndex,
+                          gl_buffer_index backIndex)
+{
+   if (fb->Attachment[frontIndex].Renderbuffer == NULL) {
+      GLboolean create = GL_FALSE;
+
+      /* check if drawing to or reading from front buffer */
+      if (fb->_ColorReadBufferIndex == frontIndex) {
+         create = GL_TRUE;
+      }
+      else {
+         GLuint b;
+         for (b = 0; b < fb->_NumColorDrawBuffers; b++) {
+            if (fb->_ColorDrawBufferIndexes[b] == frontIndex) {
+               create = GL_TRUE;
+               break;
+            }
+         }
+      }
+
+      if (create) {
+         struct st_renderbuffer *back;
+         struct gl_renderbuffer *front;
+         enum pipe_format colorFormat;
+         uint samples;
+
+         if (0)
+            _mesa_debug(ctx, "Allocate new front buffer\n");
+
+         /* get back renderbuffer info */
+         back = st_renderbuffer(fb->Attachment[backIndex].Renderbuffer);
+         colorFormat = back->format;
+         samples = back->Base.NumSamples;
+
+         /* create front renderbuffer */
+         front = st_new_renderbuffer_fb(colorFormat, samples, FALSE);
+         _mesa_add_renderbuffer(fb, frontIndex, front);
+
+         /* alloc texture/surface for new front buffer */
+         front->AllocStorage(ctx, front, front->InternalFormat,
+                             fb->Width, fb->Height);
+
+         /* initialize the front color buffer contents by copying
+          * the back buffer.
+          */
+         copy_back_to_front(ctx->st, fb, frontIndex, backIndex);
+      }
+   }
+}
+
+
+/**
+ * If front left/right color buffers are missing, create them now.
+ */
+static void
+check_create_front_buffers(GLcontext *ctx, struct gl_framebuffer *fb)
+{
+   /* check if we need to create the front left buffer now */
+   check_create_front_buffer(ctx, fb, BUFFER_FRONT_LEFT, BUFFER_BACK_LEFT);
+
+   if (fb->Visual.stereoMode) {
+      check_create_front_buffer(ctx, fb, BUFFER_FRONT_RIGHT, BUFFER_BACK_RIGHT);
+   }
+
+   st_invalidate_state(ctx, _NEW_BUFFERS);
+}
+
+
+/**
+ * Called via glDrawBuffer.
+ */
+static void
+st_DrawBuffers(GLcontext *ctx, GLsizei count, const GLenum *buffers)
+{
+   (void) count;
+   (void) buffers;
+   check_create_front_buffers(ctx, ctx->DrawBuffer);
+}
+
+
+/**
+ * Called via glReadBuffer.
+ */
+static void
+st_ReadBuffer(GLcontext *ctx, GLenum buffer)
+{
+   (void) buffer;
+   check_create_front_buffers(ctx, ctx->ReadBuffer);
+}
+
+
 void st_init_fbo_functions(struct dd_function_table *functions)
 {
    functions->NewFramebuffer = st_new_framebuffer;
@@ -475,4 +605,7 @@ void st_init_fbo_functions(struct dd_function_table *functions)
    /* no longer needed by core Mesa, drivers handle resizes...
    functions->ResizeBuffers = st_resize_buffers;
    */
+
+   functions->DrawBuffers = st_DrawBuffers;
+   functions->ReadBuffer = st_ReadBuffer;
 }
index 9a199550d9f45098879cfa93bfb4caab35988250..bea6eb89c3ecf0b7782df89757c37bc7efd7af6a 100644 (file)
@@ -40,6 +40,7 @@ struct st_renderbuffer
    struct pipe_texture *texture;
    struct pipe_surface *surface; /* temporary view into texture */
    enum pipe_format format;  /** preferred format, or PIPE_FORMAT_NONE */
+   GLboolean defined;        /**< defined contents? */
 
    /**
     * Used only when hardware accumulation buffers are not supported.
index fbaffd154f981df17f89f2644ebe90f7a1ce6e1a..8ceeeabcd37ec18418e0af1c824b6b6967779791 100644 (file)
 #include "util/u_blit.h"
 
 
+/** Check if we have a front color buffer and if it's been drawn to. */
 static INLINE GLboolean
 is_front_buffer_dirty(struct st_context *st)
 {
-   return st->frontbuffer_status == FRONT_STATUS_DIRTY;
+   if (st->frontbuffer_status == FRONT_STATUS_DIRTY) {
+      return GL_TRUE;
+   }
+   else {
+      GLframebuffer *fb = st->ctx->DrawBuffer;
+      struct st_renderbuffer *strb
+         = st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+      return strb && strb->defined;
+   }
 }
 
 
index 7dd235273998705eac5e3c00402cf3e34829ba1b..3bcccd0df46dc16da818a28e55f2317e04d2cbf2 100644 (file)
@@ -194,9 +194,10 @@ new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw)
    rs->stage.destroy = rastpos_destroy;
    rs->ctx = ctx;
 
-   for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+   for (i = 0; i < Elements(rs->array); i++) {
       rs->array[i].Size = 4;
       rs->array[i].Type = GL_FLOAT;
+      rs->array[i].Format = GL_RGBA;
       rs->array[i].Stride = 0;
       rs->array[i].StrideB = 0;
       rs->array[i].Ptr = (GLubyte *) ctx->Current.Attrib[i];
index 6ffed56d9a079d6b30eb62a86aaedf8e3661cd58..18adb35e8721403b7217450823366ad73229cf09 100644 (file)
@@ -45,6 +45,7 @@ struct blit_state;
 struct bitmap_cache;
 
 
+/** XXX we'd like to get rid of these */
 #define FRONT_STATUS_UNDEFINED    0
 #define FRONT_STATUS_DIRTY        1
 #define FRONT_STATUS_COPY_OF_BACK 2
@@ -111,7 +112,7 @@ struct st_context
       struct gl_fragment_program *fragment_program;
    } cb;
 
-   GLuint frontbuffer_status;  /**< one of FRONT_STATUS_ */
+   GLuint frontbuffer_status;  /**< one of FRONT_STATUS_ (XXX to be removed) */
 
    char vendor[100];
    char renderer[100];
index 225541a30ba2deccbde328e258bf281e33716f8b..8e036223c65a5e5dfb9fa9f9405fec7b8c954f57 100644 (file)
@@ -159,12 +159,21 @@ static GLuint fixed_types[4] = {
  * Return a PIPE_FORMAT_x for the given GL datatype and size.
  */
 GLuint
-st_pipe_vertex_format(GLenum type, GLuint size, GLboolean normalized)
+st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
+                      GLboolean normalized)
 {
    assert((type >= GL_BYTE && type <= GL_DOUBLE) ||
           type == GL_FIXED);
    assert(size >= 1);
    assert(size <= 4);
+   assert(format == GL_RGBA || format == GL_BGRA);
+
+   if (format == GL_BGRA) {
+      /* this is an odd-ball case */
+      assert(type == GL_UNSIGNED_BYTE);
+      assert(normalized);
+      return PIPE_FORMAT_B8G8R8A8_UNORM;
+   }
 
    if (normalized) {
       switch (type) {
@@ -392,6 +401,7 @@ setup_interleaved_attribs(GLcontext *ctx,
       velements[attr].src_format =
          st_pipe_vertex_format(arrays[mesaAttr]->Type,
                                arrays[mesaAttr]->Size,
+                               arrays[mesaAttr]->Format,
                                arrays[mesaAttr]->Normalized);
       assert(velements[attr].src_format);
    }
@@ -479,6 +489,7 @@ setup_non_interleaved_attribs(GLcontext *ctx,
       velements[attr].src_format
          = st_pipe_vertex_format(arrays[mesaAttr]->Type,
                                  arrays[mesaAttr]->Size,
+                                 arrays[mesaAttr]->Format,
                                  arrays[mesaAttr]->Normalized);
       assert(velements[attr].src_format);
    }
index da04fce8e24bfb832b851129a40b344c1999aa19..dcfe7e15361dba21f9355d66b77b8b386751b6cf 100644 (file)
@@ -62,7 +62,8 @@ st_feedback_draw_vbo(GLcontext *ctx,
 /* Internal function:
  */
 extern GLuint
-st_pipe_vertex_format(GLenum type, GLuint size, GLboolean normalized);
+st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
+                      GLboolean normalized);
 
 
 /**
index 32502a9cda4752951d8fc77b65477a7bfa83ef25..2712c131c0da0a99ebaa34bcf6d580447ab0c77d 100644 (file)
@@ -178,6 +178,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
       velements[attr].src_format = 
          st_pipe_vertex_format(arrays[mesaAttr]->Type,
                                arrays[mesaAttr]->Size,
+                               arrays[mesaAttr]->Format,
                                arrays[mesaAttr]->Normalized);
       assert(velements[attr].src_format);
 
index 8f6be507742fcb386bb57b4af4ccb3852e6834c1..8f63819e63767d8ba28cfabc7fd3561a2b09fdc6 100644 (file)
@@ -138,6 +138,8 @@ void st_init_extensions(struct st_context *st)
    /*
     * Extensions that are supported by all Gallium drivers:
     */
+   ctx->Extensions.ARB_copy_buffer = GL_TRUE;
+   ctx->Extensions.ARB_map_buffer_range = GL_TRUE;
    ctx->Extensions.ARB_multisample = GL_TRUE;
    ctx->Extensions.ARB_fragment_program = GL_TRUE;
    ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; /* XXX temp */
@@ -167,9 +169,13 @@ void st_init_extensions(struct st_context *st)
    ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
    ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
    ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
+   ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE;
+
+   ctx->Extensions.APPLE_vertex_array_object = GL_TRUE;
 
    ctx->Extensions.NV_blend_square = GL_TRUE;
    ctx->Extensions.NV_texgen_reflection = GL_TRUE;
+   ctx->Extensions.NV_texture_env_combine4 = GL_TRUE;
 
    ctx->Extensions.SGI_color_matrix = GL_TRUE;
    ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
index 331575660d300ad148d599327dd709aabfd1c0bd..7072cbe62c7f598604d1e75f75819b2e92738aed 100644 (file)
@@ -58,19 +58,19 @@ st_create_framebuffer( const __GLcontextModes *visual,
 
       _mesa_initialize_framebuffer(&stfb->Base, visual);
 
-      {
-         /* fake frontbuffer */
-         /* XXX allocation should only happen in the unusual case
-            it's actually needed */
+      if (visual->doubleBufferMode) {
          struct gl_renderbuffer *rb
             = st_new_renderbuffer_fb(colorFormat, samples, FALSE);
-         _mesa_add_renderbuffer(&stfb->Base, BUFFER_FRONT_LEFT, rb);
+         _mesa_add_renderbuffer(&stfb->Base, BUFFER_BACK_LEFT, rb);
       }
-
-      if (visual->doubleBufferMode) {
+      else {
+         /* Only allocate front buffer right now if we're single buffered.
+          * If double-buffered, allocate front buffer on demand later.
+          * See check_create_front_buffers().
+          */
          struct gl_renderbuffer *rb
             = st_new_renderbuffer_fb(colorFormat, samples, FALSE);
-         _mesa_add_renderbuffer(&stfb->Base, BUFFER_BACK_LEFT, rb);
+         _mesa_add_renderbuffer(&stfb->Base, BUFFER_FRONT_LEFT, rb);
       }
 
       if (depthFormat == stencilFormat && depthFormat != PIPE_FORMAT_NONE) {
@@ -294,6 +294,115 @@ st_notify_swapbuffers(struct st_framebuffer *stfb)
 }
 
 
+/**
+ * Swap the front/back color buffers.  Exchange the front/back pointers
+ * and update some derived state.
+ * No need to call st_notify_swapbuffers() first.
+ *
+ * For a single-buffered framebuffer, no swap occurs, but we still return
+ * the pointer(s) to the front color buffer(s).
+ *
+ * \param front_left  returns pointer to front-left renderbuffer after swap
+ * \param front_right  returns pointer to front-right renderbuffer after swap
+ */
+void
+st_swapbuffers(struct st_framebuffer *stfb,
+               struct pipe_surface **front_left,
+               struct pipe_surface **front_right)
+{
+   struct gl_framebuffer *fb = &stfb->Base;
+
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (ctx && ctx->DrawBuffer == &stfb->Base) {
+      st_flush( ctx->st, 
+               PIPE_FLUSH_RENDER_CACHE | 
+               PIPE_FLUSH_SWAPBUFFERS |
+               PIPE_FLUSH_FRAME,
+                NULL );
+   }
+
+   if (!fb->Visual.doubleBufferMode) {
+      /* single buffer mode - return pointers to front surfaces */
+      if (front_left) {
+         struct st_renderbuffer *strb =
+            st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+         *front_left = strb->surface;
+      }
+      if (front_right) {
+         struct st_renderbuffer *strb =
+            st_renderbuffer(fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer);
+         *front_right = strb ? strb->surface : NULL;
+      }
+      return;
+   }
+
+   /* swap left buffers */
+   if (fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer &&
+       fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer) {
+      struct gl_renderbuffer *rbTemp;
+      rbTemp = fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
+      fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer =
+         fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
+      fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer = rbTemp;
+      if (front_left) {
+         struct st_renderbuffer *strb =
+            st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+         *front_left = strb->surface;
+      }
+      /* mark back buffer contents as undefined */
+      {
+         struct st_renderbuffer *back =
+            st_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer);
+         back->defined = GL_FALSE;
+      }
+   }
+   else {
+      /* no front buffer, display the back buffer */
+      if (front_left) {
+         struct st_renderbuffer *strb =
+            st_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer);
+         *front_left = strb->surface;
+      }
+   }
+
+   /* swap right buffers (for stereo) */
+   if (fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer &&
+       fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer) {
+      struct gl_renderbuffer *rbTemp;
+      rbTemp = fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer;
+      fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer =
+         fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer;
+      fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer = rbTemp;
+      if (front_right) {
+         struct st_renderbuffer *strb =
+            st_renderbuffer(fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer);
+         *front_right = strb->surface;
+      }
+      /* mark back buffer contents as undefined */
+      {
+         struct st_renderbuffer *back =
+            st_renderbuffer(fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer);
+         back->defined = GL_FALSE;
+      }
+   }
+   else {
+      /* no front right buffer, display back right buffer (if exists) */
+      if (front_right) {
+         struct st_renderbuffer *strb =
+            st_renderbuffer(fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer);
+         *front_right = strb ? strb->surface : NULL;
+      }
+   }
+
+   /* Update the _ColorDrawBuffers[] array and _ColorReadBuffer pointer */
+   _mesa_update_framebuffer(ctx);
+
+   /* Make sure we draw into the new back surface */
+   st_invalidate_state(ctx, _NEW_BUFFERS);
+}
+
+
 void *st_framebuffer_private( struct st_framebuffer *stfb )
 {
    return stfb->Private;
index 72ca85245829cecd213ef6959e15d60c1b4e044d..263dcc03b58ee7da71d31b79458994b1eb7f4748 100644 (file)
@@ -303,6 +303,26 @@ st_translate_vertex_program(struct st_context *st,
       outputMapping = defaultOutputMapping;
    }
 
+#if 0 /* debug */
+   {
+      GLuint i;
+      printf("outputMapping? %d\n", outputMapping ? 1 : 0);
+      if (outputMapping) {
+         printf("attr -> slot\n");
+         for (i = 0; i < 16;  i++) {
+            printf(" %2d       %3d\n", i, outputMapping[i]);
+         }
+      }
+      printf("slot    sem_name  sem_index\n");
+      for (i = 0; i < vs_num_outputs; i++) {
+         printf(" %2d         %d         %d\n",
+                i,
+                vs_output_semantic_name[i],
+                vs_output_semantic_index[i]);
+      }
+   }
+#endif
+
    /* free old shader state, if any */
    if (stvp->state.tokens) {
       _mesa_free((void *) stvp->state.tokens);
index c411687bb64b03ec83ace18bd722dbc6d2bfda21..04d3a3d7c2c292d35c404ad20e81d0b9f6235f36 100644 (file)
@@ -103,6 +103,10 @@ void st_finish( struct st_context *st );
 
 void st_notify_swapbuffers(struct st_framebuffer *stfb);
 
+void st_swapbuffers(struct st_framebuffer *stfb,
+                    struct pipe_surface **front_left,
+                    struct pipe_surface **front_right);
+
 int st_set_teximage(struct pipe_texture *pt, int target);
 
 /** Redirect rendering into stfb's surface to a texture image */
index d6be3aa022e977fb9838bcef1848d11f9d8a3eb6..3578b713f61b7061fe0d0232bae504b864efe781 100644 (file)
@@ -60,7 +60,7 @@ _swrast_CopyColorTable( GLcontext *ctx,
 
    /* save PBO binding */
    bufferSave = ctx->Unpack.BufferObj;
-   ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
+   ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj;
 
    _mesa_ColorTable(target, internalformat, width, GL_RGBA, CHAN_TYPE, data);
 
@@ -94,7 +94,7 @@ _swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start,
 
    /* save PBO binding */
    bufferSave = ctx->Unpack.BufferObj;
-   ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
+   ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj;
 
    _mesa_ColorSubTable(target, start, width, GL_RGBA, CHAN_TYPE, data);
 
@@ -126,7 +126,7 @@ _swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target,
 
    /* save PBO binding */
    bufferSave = ctx->Unpack.BufferObj;
-   ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
+   ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj;
 
    /* store as convolution filter */
    _mesa_ConvolutionFilter1D(target, internalFormat, width,
@@ -178,12 +178,12 @@ _swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target,
    ctx->Unpack.SkipImages = 0;
    ctx->Unpack.SwapBytes = GL_FALSE;
    ctx->Unpack.LsbFirst = GL_FALSE;
-   ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
+   ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj;
    ctx->NewState |= _NEW_PACKUNPACK;
 
    /* save PBO binding */
    bufferSave = ctx->Unpack.BufferObj;
-   ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
+   ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj;
 
    _mesa_ConvolutionFilter2D(target, internalFormat, width, height,
                              GL_RGBA, CHAN_TYPE, rgba);
index fa8ca1d0e26cefc96fa88d50e538423c7a68e637..0e2793b47403fde0cc50484320a1d91d2e7afdb6 100644 (file)
@@ -1297,7 +1297,6 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
           span->primitive == GL_LINE ||
          span->primitive == GL_POLYGON ||
           span->primitive == GL_BITMAP);
-   ASSERT(span->end <= MAX_WIDTH);
 
    /* Fragment write masks */
    if (span->arrayMask & SPAN_MASK) {
@@ -1310,12 +1309,12 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
    }
 
    /* Clip to window/scissor box */
-   if ((swrast->_RasterMask & CLIP_BIT) || (span->primitive != GL_POLYGON)) {
-      if (!clip_span(ctx, span)) {
-        return;
-      }
+   if (!clip_span(ctx, span)) {
+      return;
    }
 
+   ASSERT(span->end <= MAX_WIDTH);
+
 #ifdef DEBUG
    /* Make sure all fragments are within window bounds */
    if (span->arrayMask & SPAN_XY) {
@@ -1356,15 +1355,6 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
    if (ctx->Stencil._Enabled || ctx->Depth.Test) {
       if (!(span->arrayMask & SPAN_Z))
          _swrast_span_interpolate_z(ctx, span);
-
-      if ((span->arrayMask & SPAN_XY) == 0) {
-         if (span->x < fb->_Xmin || span->x + span->end > fb->_Xmax ||
-             span->y < fb->_Ymin || span->y >= fb->_Ymax) {
-            printf("Bad span clipping at %d, %d\n", span->x, span->y);
-            return;
-         }
-      }
-
       if (ctx->Stencil._Enabled) {
          /* Combined Z/stencil tests */
          if (!_swrast_stencil_and_ztest_span(ctx, span)) {
index dd59314cd9671a5d90ea5a5ac251b1b386135bcb..6b1f934647540df1afb5f040ca9527ed0ff69b68 100644 (file)
@@ -1329,7 +1329,7 @@ static void
 opt_sample_rgb_2d(GLcontext *ctx,
                   const struct gl_texture_object *tObj,
                   GLuint n, const GLfloat texcoords[][4],
-                  const GLfloat lambda[], GLchan rgba[][4])
+                  const GLfloat lambda[], GLfloat rgba[][4])
 {
    const struct gl_texture_image *img = tObj->Image[0][tObj->BaseLevel];
    const GLfloat width = (GLfloat) img->Width;
@@ -1351,9 +1351,9 @@ opt_sample_rgb_2d(GLcontext *ctx,
       GLint j = IFLOOR(texcoords[k][1] * height) & rowMask;
       GLint pos = (j << shift) | i;
       GLchan *texel = ((GLchan *) img->Data) + 3*pos;
-      rgba[k][RCOMP] = texel[0];
-      rgba[k][GCOMP] = texel[1];
-      rgba[k][BCOMP] = texel[2];
+      rgba[k][RCOMP] = CHAN_TO_FLOAT(texel[0]);
+      rgba[k][GCOMP] = CHAN_TO_FLOAT(texel[1]);
+      rgba[k][BCOMP] = CHAN_TO_FLOAT(texel[2]);
    }
 }
 
@@ -1370,7 +1370,7 @@ static void
 opt_sample_rgba_2d(GLcontext *ctx,
                    const struct gl_texture_object *tObj,
                    GLuint n, const GLfloat texcoords[][4],
-                   const GLfloat lambda[], GLchan rgba[][4])
+                   const GLfloat lambda[], GLfloat rgba[][4])
 {
    const struct gl_texture_image *img = tObj->Image[0][tObj->BaseLevel];
    const GLfloat width = (GLfloat) img->Width;
@@ -1392,7 +1392,10 @@ opt_sample_rgba_2d(GLcontext *ctx,
       const GLint row = IFLOOR(texcoords[i][1] * height) & rowMask;
       const GLint pos = (row << shift) | col;
       const GLchan *texel = ((GLchan *) img->Data) + (pos << 2);    /* pos*4 */
-      COPY_4V(rgba[i], texel);
+      rgba[i][RCOMP] = CHAN_TO_FLOAT(texel[0]);
+      rgba[i][GCOMP] = CHAN_TO_FLOAT(texel[1]);
+      rgba[i][BCOMP] = CHAN_TO_FLOAT(texel[2]);
+      rgba[i][ACOMP] = CHAN_TO_FLOAT(texel[3]);
    }
 }
 
@@ -1425,7 +1428,6 @@ sample_lambda_2d(GLcontext *ctx,
       case GL_NEAREST:
          if (repeatNoBorderPOT) {
             switch (tImg->TexFormat->MesaFormat) {
-#if 0
             case MESA_FORMAT_RGB:
                opt_sample_rgb_2d(ctx, tObj, m, texcoords + minStart,
                                  NULL, rgba + minStart);
@@ -1434,7 +1436,6 @@ sample_lambda_2d(GLcontext *ctx,
               opt_sample_rgba_2d(ctx, tObj, m, texcoords + minStart,
                                   NULL, rgba + minStart);
                break;
-#endif
             default:
                sample_nearest_2d(ctx, tObj, m, texcoords + minStart,
                                  NULL, rgba + minStart );
@@ -1484,7 +1485,6 @@ sample_lambda_2d(GLcontext *ctx,
       case GL_NEAREST:
          if (repeatNoBorderPOT) {
             switch (tImg->TexFormat->MesaFormat) {
-#if 0
             case MESA_FORMAT_RGB:
                opt_sample_rgb_2d(ctx, tObj, m, texcoords + magStart,
                                  NULL, rgba + magStart);
@@ -1493,7 +1493,6 @@ sample_lambda_2d(GLcontext *ctx,
               opt_sample_rgba_2d(ctx, tObj, m, texcoords + magStart,
                                   NULL, rgba + magStart);
                break;
-#endif
             default:
                sample_nearest_2d(ctx, tObj, m, texcoords + magStart,
                                  NULL, rgba + magStart );
@@ -3180,7 +3179,6 @@ _swrast_choose_texture_sample_func( GLcontext *ctx,
          }
          else {
             /* check for a few optimized cases */
-#if 0
             const struct gl_texture_image *img = t->Image[0][t->BaseLevel];
             ASSERT(t->MinFilter == GL_NEAREST);
             if (t->WrapS == GL_REPEAT &&
@@ -3197,10 +3195,6 @@ _swrast_choose_texture_sample_func( GLcontext *ctx,
                      img->TexFormat->MesaFormat == MESA_FORMAT_RGBA) {
                return &opt_sample_rgba_2d;
             }
-#else
-            if (0)
-               ;
-#endif
             else {
                return &sample_nearest_2d;
             }
index 788fe329ed85bfad46db06ef91c52ef2659986f4..618b8b31304f0e2351d0fa03636d941a1db925f7 100644 (file)
@@ -127,7 +127,7 @@ TAG(clip_line)( GLcontext *ctx, GLuint v0, GLuint v1, GLubyte mask )
    GLuint p;
    const GLuint v0_orig = v0;
 
-   if (mask & 0x3f) {
+   if (mask & CLIP_FRUSTUM_BITS) {
       LINE_CLIP( CLIP_RIGHT_BIT,  -1,  0,  0, 1 );
       LINE_CLIP( CLIP_LEFT_BIT,    1,  0,  0, 1 );
       LINE_CLIP( CLIP_TOP_BIT,     0, -1,  0, 1 );
@@ -199,7 +199,24 @@ TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask )
 
    ASSIGN_3V(inlist, v2, v0, v1 ); /* pv rotated to slot zero */
 
-   if (mask & 0x3f) {
+   if (0) {
+      /* print pre-clip vertex coords */
+      GLuint i, j;
+      _mesa_printf("pre clip:\n");
+      for (i = 0; i < n; i++) {
+         j = inlist[i];
+         _mesa_printf("  %u: %u: %f, %f, %f, %f\n",
+                      i, j,
+                      coord[j][0], coord[j][1], coord[j][2], coord[j][3]);
+         assert(!IS_INF_OR_NAN(coord[j][0]));
+         assert(!IS_INF_OR_NAN(coord[j][1]));
+         assert(!IS_INF_OR_NAN(coord[j][2]));
+         assert(!IS_INF_OR_NAN(coord[j][3]));
+      }
+   }
+
+
+   if (mask & CLIP_FRUSTUM_BITS) {
       POLY_CLIP( CLIP_RIGHT_BIT,  -1,  0,  0, 1 );
       POLY_CLIP( CLIP_LEFT_BIT,    1,  0,  0, 1 );
       POLY_CLIP( CLIP_TOP_BIT,     0, -1,  0, 1 );
@@ -227,6 +244,18 @@ TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask )
       }
    }
 
+   if (0) {
+      /* print post-clip vertex coords */
+      GLuint i, j;
+      _mesa_printf("post clip:\n");
+      for (i = 0; i < n; i++) {
+         j = inlist[i];
+         _mesa_printf("  %u: %u: %f, %f, %f, %f\n",
+                      i, j,
+                      coord[j][0], coord[j][1], coord[j][2], coord[j][3]);
+      }
+   }
+
    tnl->Driver.Render.ClippedPolygon( ctx, inlist, n );
 }
 
@@ -250,7 +279,7 @@ TAG(clip_quad)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3,
 
    ASSIGN_4V(inlist, v3, v0, v1, v2 ); /* pv rotated to slot zero */
 
-   if (mask & 0x3f) {
+   if (mask & CLIP_FRUSTUM_BITS) {
       POLY_CLIP( CLIP_RIGHT_BIT,  -1,  0,  0, 1 );
       POLY_CLIP( CLIP_LEFT_BIT,    1,  0,  0, 1 );
       POLY_CLIP( CLIP_TOP_BIT,     0, -1,  0, 1 );
index 1795f62c3233a1e2fc4bcc06973f716c31e5463a..66c5e13729c1c1dc0ebb42da7cfa54fca34dd508 100644 (file)
@@ -1,8 +1,9 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.1
+ * Version:  7.6
  *
- * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ * Copyright (C) 2009  VMware, 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"),
 #include "tnl/t_pipeline.h"
 
 
+#ifdef NAN_CHECK
+/** Check for NaNs and very large values */
+static INLINE void
+check_float(float x)
+{
+   assert(!IS_INF_OR_NAN(x));
+   assert(1.0e-15 <= x && x <= 1.0e15);
+}
+#endif
+
 
 /*!
  * Private storage for the vertex program pipeline stage.
@@ -207,7 +218,7 @@ init_machine(GLcontext *ctx, struct gl_program_machine *machine)
 {
    /* Input registers get initialized from the current vertex attribs */
    MEMCPY(machine->VertAttribs, ctx->Current.Attrib,
-          MAX_VERTEX_PROGRAM_ATTRIBS * 4 * sizeof(GLfloat));
+          MAX_VERTEX_GENERIC_ATTRIBS * 4 * sizeof(GLfloat));
 
    if (ctx->VertexProgram._Current->IsNVProgram) {
       GLuint i;
@@ -351,6 +362,12 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
            const GLuint size = VB->AttribPtr[attr]->size;
            const GLuint stride = VB->AttribPtr[attr]->stride;
            const GLfloat *data = (GLfloat *) (ptr + stride * i);
+#ifdef NAN_CHECK
+            check_float(data[0]);
+            check_float(data[1]);
+            check_float(data[2]);
+            check_float(data[3]);
+#endif
            COPY_CLEAN_4V(machine.VertAttribs[attr], size, data);
         }
       }
@@ -361,6 +378,12 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
       /* copy the output registers into the VB->attribs arrays */
       for (j = 0; j < numOutputs; j++) {
          const GLuint attr = outputs[j];
+#ifdef NAN_CHECK
+         check_float(machine.Outputs[attr][0]);
+         check_float(machine.Outputs[attr][1]);
+         check_float(machine.Outputs[attr][2]);
+         check_float(machine.Outputs[attr][3]);
+#endif
          COPY_4V(store->results[attr].data[i], machine.Outputs[attr]);
       }
 #if 0
index ff11c7d59a775b589a85127a396b417e9607a32c..7a889b8e2f856d65881946e0cf398993b3bf74ad 100644 (file)
@@ -265,7 +265,7 @@ static void GLAPIENTRY TAG(VertexAttrib1fARB)( GLuint index, GLfloat x )
    GET_CURRENT_CONTEXT( ctx );
    if (index == 0) 
       ATTR1F(0, x);
-   else if (index < MAX_VERTEX_ATTRIBS)
+   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
       ATTR1F(VBO_ATTRIB_GENERIC0 + index, x);
    else
       ERROR();
@@ -277,7 +277,7 @@ static void GLAPIENTRY TAG(VertexAttrib1fvARB)( GLuint index,
    GET_CURRENT_CONTEXT( ctx );
    if (index == 0) 
       ATTR1FV(0, v);
-   else if (index < MAX_VERTEX_ATTRIBS)
+   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
       ATTR1FV(VBO_ATTRIB_GENERIC0 + index, v);
    else
       ERROR();
@@ -289,7 +289,7 @@ static void GLAPIENTRY TAG(VertexAttrib2fARB)( GLuint index, GLfloat x,
    GET_CURRENT_CONTEXT( ctx );
    if (index == 0) 
       ATTR2F(0, x, y);
-   else if (index < MAX_VERTEX_ATTRIBS)
+   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
       ATTR2F(VBO_ATTRIB_GENERIC0 + index, x, y);
    else
       ERROR();
@@ -301,7 +301,7 @@ static void GLAPIENTRY TAG(VertexAttrib2fvARB)( GLuint index,
    GET_CURRENT_CONTEXT( ctx );
    if (index == 0) 
       ATTR2FV(0, v);
-   else if (index < MAX_VERTEX_ATTRIBS)
+   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
       ATTR2FV(VBO_ATTRIB_GENERIC0 + index, v);
    else
       ERROR();
@@ -313,7 +313,7 @@ static void GLAPIENTRY TAG(VertexAttrib3fARB)( GLuint index, GLfloat x,
    GET_CURRENT_CONTEXT( ctx );
    if (index == 0) 
       ATTR3F(0, x, y, z);
-   else if (index < MAX_VERTEX_ATTRIBS)
+   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
       ATTR3F(VBO_ATTRIB_GENERIC0 + index, x, y, z);
    else
       ERROR();
@@ -325,7 +325,7 @@ static void GLAPIENTRY TAG(VertexAttrib3fvARB)( GLuint index,
    GET_CURRENT_CONTEXT( ctx );
    if (index == 0) 
       ATTR3FV(0, v);
-   else if (index < MAX_VERTEX_ATTRIBS)
+   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
       ATTR3FV(VBO_ATTRIB_GENERIC0 + index, v);
    else
       ERROR();
@@ -338,7 +338,7 @@ static void GLAPIENTRY TAG(VertexAttrib4fARB)( GLuint index, GLfloat x,
    GET_CURRENT_CONTEXT( ctx );
    if (index == 0) 
       ATTR4F(0, x, y, z, w);
-   else if (index < MAX_VERTEX_ATTRIBS)
+   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
       ATTR4F(VBO_ATTRIB_GENERIC0 + index, x, y, z, w);
    else
       ERROR();
@@ -350,7 +350,7 @@ static void GLAPIENTRY TAG(VertexAttrib4fvARB)( GLuint index,
    GET_CURRENT_CONTEXT( ctx );
    if (index == 0) 
       ATTR4FV(0, v);
-   else if (index < MAX_VERTEX_ATTRIBS)
+   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
       ATTR4FV(VBO_ATTRIB_GENERIC0 + index, v);
    else
       ERROR();
index ca8190fd059fc637b014302efc8e5f976a8dc9bb..75c32e0b9bedb89c58454ee0984986804af66998 100644 (file)
@@ -28,6 +28,7 @@
 #include "main/imports.h"
 #include "main/mtypes.h"
 #include "main/api_arrayelt.h"
+#include "main/bufferobj.h"
 #include "math/m_eval.h"
 #include "vbo.h"
 #include "vbo_context.h"
@@ -81,7 +82,8 @@ static void init_legacy_currval(GLcontext *ctx)
       cl->Type = GL_FLOAT;
       cl->Format = GL_RGBA;
       cl->Ptr = (const void *)ctx->Current.Attrib[i];
-      cl->BufferObj = ctx->Array.NullBufferObj;
+      _mesa_reference_buffer_object(ctx, &cl->BufferObj,
+                                    ctx->Shared->NullBufferObj);
    }
 }
 
@@ -106,7 +108,8 @@ static void init_generic_currval(GLcontext *ctx)
       cl->Stride = 0;
       cl->StrideB = 0;
       cl->Enabled = 1;
-      cl->BufferObj = ctx->Array.NullBufferObj;
+      _mesa_reference_buffer_object(ctx, &cl->BufferObj,
+                                    ctx->Shared->NullBufferObj);
    }
 }
 
@@ -150,7 +153,8 @@ static void init_mat_currval(GLcontext *ctx)
       cl->Stride = 0;
       cl->StrideB = 0;
       cl->Enabled = 1;
-      cl->BufferObj = ctx->Array.NullBufferObj;
+      _mesa_reference_buffer_object(ctx, &cl->BufferObj,
+                                    ctx->Shared->NullBufferObj);
    }
 }
 
@@ -211,7 +215,7 @@ GLboolean _vbo_CreateContext( GLcontext *ctx )
       for (i = 0; i < 4; i++)
         vbo->map_vp_none[28+i] = i;    
       
-      for (i = 0; i < VERT_ATTRIB_MAX; i++)
+      for (i = 0; i < Elements(vbo->map_vp_arb); i++)
         vbo->map_vp_arb[i] = i;
    }
 
index bf405eb69338fb44851b7111d1c77fc3a8b723f3..8b726dc8ac5bfd0e63669c3311d264b496cdd530 100644 (file)
@@ -68,8 +68,8 @@ struct vbo_context {
    struct gl_client_array *generic_currval;
    struct gl_client_array *mat_currval;
 
-   GLuint map_vp_none[32];
-   GLuint map_vp_arb[32];
+   GLuint map_vp_none[VERT_ATTRIB_MAX];
+   GLuint map_vp_arb[VERT_ATTRIB_MAX];
 
    GLfloat *current[VBO_ATTRIB_MAX]; /* points into ctx->Current, ctx->Light.Material */
    GLfloat CurrentFloatEdgeFlag;
@@ -92,16 +92,18 @@ static INLINE struct vbo_context *vbo_context(GLcontext *ctx)
    return (struct vbo_context *)(ctx->swtnl_im);
 }
 
-enum {
-   VP_NONE = 1,
-   VP_NV,
-   VP_ARB
-};
 
-static INLINE GLuint get_program_mode( GLcontext *ctx )
+/**
+ * Return VP_x token to indicate whether we're running fixed-function
+ * vertex transformation, an NV vertex program or ARB vertex program/shader.
+ */
+static INLINE enum vp_mode
+get_program_mode( GLcontext *ctx )
 {
    if (!ctx->VertexProgram._Current)
       return VP_NONE;
+   else if (ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram)
+      return VP_NONE;
    else if (ctx->VertexProgram._Current->IsNVProgram)
       return VP_NV;
    else
index 100bb8a5decbe1c268200d8d970c3d73976659d3..e0f44892cff7a8c5861393365a310729c0bd7621 100644 (file)
@@ -48,6 +48,12 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define ERROR_ATTRIB 16
 
 
+/** Current vertex program mode */
+enum vp_mode {
+   VP_NONE,   /**< fixed function */
+   VP_NV,     /**< NV vertex program */
+   VP_ARB     /**< ARB vertex program or GLSL vertex shader */
+};
 
 
 struct vbo_exec_eval1_map {
@@ -103,7 +109,7 @@ struct vbo_exec_context
        * values are squashed down to the 32 attributes passed to the
        * vertex program below:
        */
-      GLuint program_mode;
+      enum vp_mode program_mode;
       GLuint enabled_flags;
       const struct gl_client_array *inputs[VERT_ATTRIB_MAX];
    } vtx;
@@ -116,7 +122,7 @@ struct vbo_exec_context
    } eval;
 
    struct {
-      GLuint program_mode;
+      enum vp_mode program_mode;
       GLuint enabled_flags;
       GLuint array_obj;
 
index 34e849aaab7c497528950dae81cfaf069e480fc0..b746a77bc1974c04339a34aaf7ca13a8fa98cf9b 100644 (file)
@@ -675,7 +675,7 @@ void vbo_use_buffer_objects(GLcontext *ctx)
    GLsizei size = VBO_VERT_BUFFER_SIZE;
 
    /* Make sure this func is only used once */
-   assert(exec->vtx.bufferobj == ctx->Array.NullBufferObj);
+   assert(exec->vtx.bufferobj == ctx->Shared->NullBufferObj);
    if (exec->vtx.buffer_map) {
       _mesa_align_free(exec->vtx.buffer_map);
       exec->vtx.buffer_map = NULL;
@@ -701,7 +701,7 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec )
     */
    _mesa_reference_buffer_object(ctx,
                                  &exec->vtx.bufferobj,
-                                 ctx->Array.NullBufferObj);
+                                 ctx->Shared->NullBufferObj);
 
    ASSERT(!exec->vtx.buffer_map);
    exec->vtx.buffer_map = (GLfloat *)ALIGN_MALLOC(VBO_VERT_BUFFER_SIZE, 64);
index 65fe197a4d7d79f1f1fe7bd14b4e890f6c6ad57b..f4b9b2f744335f8bab79ec68ae68f7b483bca440 100644 (file)
@@ -1,6 +1,7 @@
 /**************************************************************************
  * 
  * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009 VMware, Inc.
  * All Rights Reserved.
  * 
  * Permission is hereby granted, free of charge, to any person obtaining a
 
 #include "vbo_context.h"
 
-/* Compute min and max elements for drawelements calls.
+
+/**
+ * Compute min and max elements for glDraw[Range]Elements() calls.
  */
-static void get_minmax_index( GLuint count, GLuint type, 
-                             const GLvoid *indices,
-                             GLuint *min_index,
-                             GLuint *max_index)
+static void
+get_minmax_index(GLuint count, GLuint type, const GLvoid *indices,
+                 GLuint *min_index, GLuint *max_index)
 {
    GLuint i;
 
@@ -89,9 +91,199 @@ static void get_minmax_index( GLuint count, GLuint type,
 }
 
 
-/* Just translate the arrayobj into a sane layout.
+/**
+ * Check that element 'j' of the array has reasonable data.
+ * Map VBO if needed.
+ */
+static void
+check_array_data(GLcontext *ctx, struct gl_client_array *array,
+                 GLuint attrib, GLuint j)
+{
+   if (array->Enabled) {
+      const void *data = array->Ptr;
+      if (array->BufferObj->Name) {
+         if (!array->BufferObj->Pointer) {
+            /* need to map now */
+            array->BufferObj->Pointer = ctx->Driver.MapBuffer(ctx,
+                                                              GL_ARRAY_BUFFER_ARB,
+                                                              GL_READ_ONLY,
+                                                              array->BufferObj);
+         }
+         data = ADD_POINTERS(data, array->BufferObj->Pointer);
+      }
+      switch (array->Type) {
+      case GL_FLOAT:
+         {
+            GLfloat *f = (GLfloat *) ((GLubyte *) data + array->StrideB * j);
+            GLuint k;
+            for (k = 0; k < array->Size; k++) {
+               if (IS_INF_OR_NAN(f[k]) ||
+                   f[k] >= 1.0e20 || f[k] <= -1.0e10) {
+                  _mesa_printf("Bad array data:\n");
+                  _mesa_printf("  Element[%u].%u = %f\n", j, k, f[k]);
+                  _mesa_printf("  Array %u at %p\n", attrib, (void* ) array);
+                  _mesa_printf("  Type 0x%x, Size %d, Stride %d\n",
+                               array->Type, array->Size, array->Stride);
+                  _mesa_printf("  Address/offset %p in Buffer Object %u\n",
+                               array->Ptr, array->BufferObj->Name);
+                  f[k] = 1.0; /* XXX replace the bad value! */
+               }
+               //assert(!IS_INF_OR_NAN(f[k]));
+            }
+         }
+         break;
+      default:
+         ;
+      }
+   }
+}
+
+
+/**
+ * Unmap the buffer object referenced by given array, if mapped.
+ */
+static void
+unmap_array_buffer(GLcontext *ctx, struct gl_client_array *array)
+{
+   if (array->Enabled &&
+       array->BufferObj->Name &&
+       array->BufferObj->Pointer) {
+      ctx->Driver.UnmapBuffer(ctx,
+                              GL_ARRAY_BUFFER_ARB,
+                              array->BufferObj);
+   }
+}
+
+
+/**
+ * Examine the array's data for NaNs, etc.
+ */
+static void
+check_draw_elements_data(GLcontext *ctx, GLsizei count, GLenum elemType,
+                         const void *elements)
+{
+   struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
+   const void *elemMap;
+   GLint i, k;
+
+   if (ctx->Array.ElementArrayBufferObj->Name) {
+      elemMap = ctx->Driver.MapBuffer(ctx,
+                                      GL_ELEMENT_ARRAY_BUFFER_ARB,
+                                      GL_READ_ONLY,
+                                      ctx->Array.ElementArrayBufferObj);
+      elements = ADD_POINTERS(elements, elemMap);
+   }
+
+   for (i = 0; i < count; i++) {
+      GLuint j;
+
+      /* j = element[i] */
+      switch (elemType) {
+      case GL_UNSIGNED_BYTE:
+         j = ((const GLubyte *) elements)[i];
+         break;
+      case GL_UNSIGNED_SHORT:
+         j = ((const GLushort *) elements)[i];
+         break;
+      case GL_UNSIGNED_INT:
+         j = ((const GLuint *) elements)[i];
+         break;
+      default:
+         assert(0);
+      }
+
+      /* check element j of each enabled array */
+      check_array_data(ctx, &arrayObj->Vertex, VERT_ATTRIB_POS, j);
+      check_array_data(ctx, &arrayObj->Normal, VERT_ATTRIB_NORMAL, j);
+      check_array_data(ctx, &arrayObj->Color, VERT_ATTRIB_COLOR0, j);
+      check_array_data(ctx, &arrayObj->SecondaryColor, VERT_ATTRIB_COLOR1, j);
+      for (k = 0; k < Elements(arrayObj->TexCoord); k++) {
+         check_array_data(ctx, &arrayObj->TexCoord[k], VERT_ATTRIB_TEX0 + k, j);
+      }
+      for (k = 0; k < Elements(arrayObj->VertexAttrib); k++) {
+         check_array_data(ctx, &arrayObj->VertexAttrib[k], VERT_ATTRIB_GENERIC0 + k, j);
+      }
+   }
+
+   if (ctx->Array.ElementArrayBufferObj->Name) {
+      ctx->Driver.UnmapBuffer(ctx,
+                             GL_ELEMENT_ARRAY_BUFFER_ARB,
+                             ctx->Array.ElementArrayBufferObj);
+   }
+
+   unmap_array_buffer(ctx, &arrayObj->Vertex);
+   unmap_array_buffer(ctx, &arrayObj->Normal);
+   unmap_array_buffer(ctx, &arrayObj->Color);
+   for (k = 0; k < Elements(arrayObj->TexCoord); k++) {
+      unmap_array_buffer(ctx, &arrayObj->TexCoord[k]);
+   }
+   for (k = 0; k < Elements(arrayObj->VertexAttrib); k++) {
+      unmap_array_buffer(ctx, &arrayObj->VertexAttrib[k]);
+   }
+}
+
+
+/**
+ * Check array data, looking for NaNs, etc.
+ */
+static void
+check_draw_arrays_data(GLcontext *ctx, GLint start, GLsizei count)
+{
+   /* TO DO */
+}
+
+
+/**
+ * Print info/data for glDrawArrays().
+ */
+static void
+print_draw_arrays(GLcontext *ctx, struct vbo_exec_context *exec,
+                  GLenum mode, GLint start, GLsizei count)
+{
+   int i;
+
+   _mesa_printf("vbo_exec_DrawArrays(mode 0x%x, start %d, count %d):\n",
+                mode, start, count);
+
+   for (i = 0; i < 32; i++) {
+      GLuint bufName = exec->array.inputs[i]->BufferObj->Name;
+      GLint stride = exec->array.inputs[i]->Stride;
+      _mesa_printf("attr %2d: size %d stride %d  enabled %d  "
+                   "ptr %p  Bufobj %u\n",
+                   i,
+                   exec->array.inputs[i]->Size,
+                   stride,
+                   /*exec->array.inputs[i]->Enabled,*/
+                   exec->array.legacy_array[i]->Enabled,
+                   exec->array.inputs[i]->Ptr,
+                   bufName);
+
+      if (bufName) {
+         struct gl_buffer_object *buf = _mesa_lookup_bufferobj(ctx, bufName);
+         GLubyte *p = ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER_ARB,
+                                            GL_READ_ONLY_ARB, buf);
+         int offset = (int) (GLintptr) exec->array.inputs[i]->Ptr;
+         float *f = (float *) (p + offset);
+         int *k = (int *) f;
+         int i;
+         int n = (count * stride) / 4;
+         if (n > 32)
+            n = 32;
+         _mesa_printf("  Data at offset %d:\n", offset);
+         for (i = 0; i < n; i++) {
+            _mesa_printf("    float[%d] = 0x%08x %f\n", i, k[i], f[i]);
+         }
+         ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER_ARB, buf);
+      }
+   }
+}
+
+
+/**
+ * Just translate the arrayobj into a sane layout.
  */
-static void bind_array_obj( GLcontext *ctx )
+static void
+bind_array_obj(GLcontext *ctx)
 {
    struct vbo_context *vbo = vbo_context(ctx);
    struct vbo_exec_context *exec = &vbo->exec;
@@ -103,7 +295,7 @@ static void bind_array_obj( GLcontext *ctx )
     * go away.
     */
    exec->array.legacy_array[VERT_ATTRIB_POS] = &arrayObj->Vertex;
-   exec->array.legacy_array[VERT_ATTRIB_WEIGHT] = &vbo->legacy_currval[VERT_ATTRIB_WEIGHT];
+   exec->array.legacy_array[VERT_ATTRIB_WEIGHT] = &arrayObj->Weight;
    exec->array.legacy_array[VERT_ATTRIB_NORMAL] = &arrayObj->Normal;
    exec->array.legacy_array[VERT_ATTRIB_COLOR0] = &arrayObj->Color;
    exec->array.legacy_array[VERT_ATTRIB_COLOR1] = &arrayObj->SecondaryColor;
@@ -115,11 +307,10 @@ static void bind_array_obj( GLcontext *ctx )
    }
    exec->array.legacy_array[VERT_ATTRIB_EDGEFLAG] = &arrayObj->EdgeFlag;
 
-   for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++)
+   for (i = 0; i < Elements(arrayObj->TexCoord); i++)
       exec->array.legacy_array[VERT_ATTRIB_TEX0 + i] = &arrayObj->TexCoord[i];
 
-   for (i = 0; i < MAX_VERTEX_ATTRIBS; i++) {
-      assert(i < Elements(arrayObj->VertexAttrib));
+   for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) {
       assert(i < Elements(exec->array.generic_array));
       exec->array.generic_array[i] = &arrayObj->VertexAttrib[i];
    }
@@ -127,7 +318,9 @@ static void bind_array_obj( GLcontext *ctx )
    exec->array.array_obj = arrayObj->Name;
 }
 
-static void recalculate_input_bindings( GLcontext *ctx )
+
+static void
+recalculate_input_bindings(GLcontext *ctx)
 {
    struct vbo_context *vbo = vbo_context(ctx);
    struct vbo_exec_context *exec = &vbo->exec;
@@ -140,9 +333,10 @@ static void recalculate_input_bindings( GLcontext *ctx )
 
    switch (exec->array.program_mode) {
    case VP_NONE:
-      /* When no vertex program is active, we put the material values
-       * into the generic slots.  This is the only situation where
-       * material values are available as per-vertex attributes.
+      /* When no vertex program is active (or the vertex program is generated
+       * from fixed-function state).  We put the material values into the
+       * generic slots.  This is the only situation where material values
+       * are available as per-vertex attributes.
        */
       for (i = 0; i <= VERT_ATTRIB_TEX7; i++) {
         if (exec->array.legacy_array[i]->Enabled)
@@ -165,8 +359,8 @@ static void recalculate_input_bindings( GLcontext *ctx )
         inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i];
          const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i);
       }
-
       break;
+
    case VP_NV:
       /* NV_vertex_program - attribute arrays alias and override
        * conventional, legacy arrays.  No materials, and the generic
@@ -190,11 +384,11 @@ static void recalculate_input_bindings( GLcontext *ctx )
         inputs[i] = &vbo->generic_currval[i - VERT_ATTRIB_GENERIC0];
          const_inputs |= 1 << i;
       }
-
       break;
+
    case VP_ARB:
-      /* ARB_vertex_program - Only the attribute zero (position) array
-       * aliases and overrides the legacy position array.  
+      /* GL_ARB_vertex_program or GLSL vertex shader - Only the generic[0]
+       * attribute array aliases and overrides the legacy position array.  
        *
        * Otherwise, legacy attributes available in the legacy slots,
        * generic attributes in the generic slots and materials are not
@@ -209,7 +403,6 @@ static void recalculate_input_bindings( GLcontext *ctx )
          const_inputs |= 1 << 0;
       }
 
-
       for (i = 1; i <= VERT_ATTRIB_TEX7; i++) {
         if (exec->array.legacy_array[i]->Enabled)
            inputs[i] = exec->array.legacy_array[i];
@@ -219,7 +412,7 @@ static void recalculate_input_bindings( GLcontext *ctx )
          }
       }
 
-      for (i = 0; i < MAX_VERTEX_ATTRIBS; i++) {
+      for (i = 0; i < MAX_VERTEX_GENERIC_ATTRIBS; i++) {
         if (exec->array.generic_array[i]->Enabled)
            inputs[VERT_ATTRIB_GENERIC0 + i] = exec->array.generic_array[i];
         else {
@@ -234,7 +427,9 @@ static void recalculate_input_bindings( GLcontext *ctx )
    _mesa_set_varying_vp_inputs( ctx, ~const_inputs );
 }
 
-static void bind_arrays( GLcontext *ctx )
+
+static void
+bind_arrays(GLcontext *ctx)
 {
 #if 0
    if (ctx->Array.ArrayObj.Name != exec->array.array_obj) {
@@ -279,9 +474,18 @@ vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count)
       return;
    }
 
+#if 0
+   check_draw_arrays_data(ctx, start, count);
+#else
+   (void) check_draw_arrays_data;
+#endif
+
    bind_arrays( ctx );
 
-   /* Again...
+   /* Again... because we may have changed the bitmask of per-vertex varying
+    * attributes.  If we regenerate the fixed-function vertex program now
+    * we may be able to prune down the number of vertex attributes which we
+    * need in the shader.
     */
    if (ctx->NewState)
       _mesa_update_state( ctx );
@@ -295,50 +499,72 @@ vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count)
    prim[0].count = count;
    prim[0].indexed = 0;
 
-   vbo->draw_prims( ctx, exec->array.inputs, prim, 1, NULL, start, start + count - 1 );
+   vbo->draw_prims( ctx, exec->array.inputs, prim, 1, NULL,
+                    start, start + count - 1 );
 
 #if 0
-   {
-      int i;
-
-      _mesa_printf("vbo_exec_DrawArrays(mode 0x%x, start %d, count %d):\n",
-                   mode, start, count);
-
-      for (i = 0; i < 32; i++) {
-         GLuint bufName = exec->array.inputs[i]->BufferObj->Name;
-         GLint stride = exec->array.inputs[i]->Stride;
-         _mesa_printf("attr %2d: size %d stride %d  enabled %d  "
-                      "ptr %p  Bufobj %u\n",
-                      i,
-                      exec->array.inputs[i]->Size,
-                      stride,
-                      /*exec->array.inputs[i]->Enabled,*/
-                      exec->array.legacy_array[i]->Enabled,
-                      exec->array.inputs[i]->Ptr,
-                      bufName);
-         
-         if (bufName) {
-            struct gl_buffer_object *buf = _mesa_lookup_bufferobj(ctx, bufName);
-            GLubyte *p = ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER_ARB,
-                                            GL_READ_ONLY_ARB, buf);
-            int offset = (int) exec->array.inputs[i]->Ptr;
-            float *f = (float *) (p + offset);
-            int *k = (int *) f;
-            int i;
-            int n = (count * stride) / 4;
-            if (n > 32)
-               n = 32;
-            _mesa_printf("  Data at offset %d:\n", offset);
-            for (i = 0; i < n; i++) {
-               _mesa_printf("    float[%d] = 0x%08x %f\n", i, k[i], f[i]);
-            }
-            ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER_ARB, buf);
+   print_draw_arrays(ctx, exec, mode, start, count);
+#else
+   (void) print_draw_arrays;
+#endif
+}
+
+
+/**
+ * Map GL_ELEMENT_ARRAY_BUFFER and print contents.
+ */
+static void
+dump_element_buffer(GLcontext *ctx, GLenum type)
+{
+   const GLvoid *map = ctx->Driver.MapBuffer(ctx,
+                                             GL_ELEMENT_ARRAY_BUFFER_ARB,
+                                             GL_READ_ONLY,
+                                             ctx->Array.ElementArrayBufferObj);
+   switch (type) {
+   case GL_UNSIGNED_BYTE:
+      {
+         const GLubyte *us = (const GLubyte *) map;
+         GLuint i;
+         for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size; i++) {
+            _mesa_printf("%02x ", us[i]);
+            if (i % 32 == 31)
+               _mesa_printf("\n");
          }
+         _mesa_printf("\n");
       }
+      break;
+   case GL_UNSIGNED_SHORT:
+      {
+         const GLushort *us = (const GLushort *) map;
+         GLuint i;
+         for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size / 2; i++) {
+            _mesa_printf("%04x ", us[i]);
+            if (i % 16 == 15)
+               _mesa_printf("\n");
+         }
+         _mesa_printf("\n");
+      }
+      break;
+   case GL_UNSIGNED_INT:
+      {
+         const GLuint *us = (const GLuint *) map;
+         GLuint i;
+         for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size / 4; i++) {
+            _mesa_printf("%08x ", us[i]);
+            if (i % 8 == 7)
+               _mesa_printf("\n");
+         }
+         _mesa_printf("\n");
+      }
+      break;
+   default:
+      ;
    }
-#endif
-}
 
+   ctx->Driver.UnmapBuffer(ctx,
+                           GL_ELEMENT_ARRAY_BUFFER_ARB,
+                           ctx->Array.ElementArrayBufferObj);
+}
 
 
 static void GLAPIENTRY
@@ -352,9 +578,41 @@ vbo_exec_DrawRangeElements(GLenum mode,
    struct _mesa_index_buffer ib;
    struct _mesa_prim prim[1];
 
-   if (!_mesa_validate_DrawRangeElements( ctx, mode, start, end, count, type, indices ))
+   if (!_mesa_validate_DrawRangeElements( ctx, mode, start, end, count,
+                                          type, indices ))
       return;
 
+   if (end >= ctx->Array.ArrayObj->_MaxElement) {
+      /* the max element is out of bounds of one or more enabled arrays */
+      _mesa_warning(ctx, "glDraw[Range]Elements(start %u, end %u, count %d, "
+                    "type 0x%x, indices=%p)\n"
+                    "\tindex=%u is out of bounds (max=%u)  "
+                    "Element Buffer %u (size %d)",
+                    start, end, count, type, indices, end,
+                    ctx->Array.ArrayObj->_MaxElement - 1,
+                    ctx->Array.ElementArrayBufferObj->Name,
+                    ctx->Array.ElementArrayBufferObj->Size);
+
+      if (0)
+         dump_element_buffer(ctx, type);
+
+      if (0)
+         _mesa_print_arrays(ctx);
+      return;
+   }
+   else if (0) {
+      _mesa_printf("glDraw[Range]Elements"
+                   "(start %u, end %u, type 0x%x, count %d) ElemBuf %u\n",
+                   start, end, type, count,
+                   ctx->Array.ElementArrayBufferObj->Name);
+   }
+
+#if 0
+   check_draw_elements_data(ctx, count, type, indices);
+#else
+   (void) check_draw_elements_data;
+#endif
+
    FLUSH_CURRENT( ctx, 0 );
 
    if (ctx->NewState)
@@ -418,8 +676,10 @@ vbo_exec_DrawRangeElements(GLenum mode,
    vbo->draw_prims( ctx, exec->array.inputs, prim, 1, &ib, start, end );
 }
 
+
 static void GLAPIENTRY
-vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
+vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type,
+                      const GLvoid *indices)
 {
    GET_CURRENT_CONTEXT(ctx);
    GLuint min_index = 0;
@@ -435,11 +695,12 @@ vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *ind
 
    if (ctx->Array.ElementArrayBufferObj->Name) {
       const GLvoid *map = ctx->Driver.MapBuffer(ctx,
-                                                GL_ELEMENT_ARRAY_BUFFER_ARB,
-                                                GL_READ_ONLY,
-                                                ctx->Array.ElementArrayBufferObj);
+                                                GL_ELEMENT_ARRAY_BUFFER_ARB,
+                                                GL_READ_ONLY,
+                                                ctx->Array.ElementArrayBufferObj);
 
-      get_minmax_index(count, type, ADD_POINTERS(map, indices), &min_index, &max_index);
+      get_minmax_index(count, type, ADD_POINTERS(map, indices),
+                       &min_index, &max_index);
 
       ctx->Driver.UnmapBuffer(ctx,
                              GL_ELEMENT_ARRAY_BUFFER_ARB,
@@ -457,10 +718,8 @@ vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *ind
  * Initialization
  */
 
-
-
-
-void vbo_exec_array_init( struct vbo_exec_context *exec )
+void
+vbo_exec_array_init( struct vbo_exec_context *exec )
 {
 #if 1
    exec->vtxfmt.DrawArrays = vbo_exec_DrawArrays;
@@ -474,7 +733,8 @@ void vbo_exec_array_init( struct vbo_exec_context *exec )
 }
 
 
-void vbo_exec_array_destroy( struct vbo_exec_context *exec )
+void
+vbo_exec_array_destroy( struct vbo_exec_context *exec )
 {
    /* nothing to do */
 }
index da2d849ded70d4276baf84032a328657ea08e6d2..c939b7b63359bbb3ab11c0c703135921d4b44ca5 100644 (file)
@@ -35,7 +35,8 @@
 #include "vbo_context.h"
 
 
-static void vbo_exec_debug_verts( struct vbo_exec_context *exec )
+static void
+vbo_exec_debug_verts( struct vbo_exec_context *exec )
 {
    GLuint count = exec->vtx.vert_count;
    GLuint i;
@@ -64,19 +65,19 @@ static void vbo_exec_debug_verts( struct vbo_exec_context *exec )
  * NOTE: Need to have calculated primitives by this point -- do it on the fly.
  * NOTE: Old 'parity' issue is gone.
  */
-static GLuint vbo_copy_vertices( struct vbo_exec_context *exec )
+static GLuint
+vbo_copy_vertices( struct vbo_exec_context *exec )
 {
    GLuint nr = exec->vtx.prim[exec->vtx.prim_count-1].count;
    GLuint ovf, i;
    GLuint sz = exec->vtx.vertex_size;
    GLfloat *dst = exec->vtx.copied.buffer;
-   GLfloat *src = (exec->vtx.buffer_map + 
-                  exec->vtx.prim[exec->vtx.prim_count-1].start * 
-                  exec->vtx.vertex_size);
+   const GLfloat *src = (exec->vtx.buffer_map + 
+                         exec->vtx.prim[exec->vtx.prim_count-1].start * 
+                         exec->vtx.vertex_size);
 
 
-   switch( exec->ctx->Driver.CurrentExecPrimitive )
-   {
+   switch (exec->ctx->Driver.CurrentExecPrimitive) {
    case GL_POINTS:
       return 0;
    case GL_LINES:
@@ -95,8 +96,9 @@ static GLuint vbo_copy_vertices( struct vbo_exec_context *exec )
         _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) );
       return i;
    case GL_LINE_STRIP:
-      if (nr == 0) 
+      if (nr == 0) {
         return 0;
+      }
       else {
         _mesa_memcpy( dst, src+(nr-1)*sz, sz * sizeof(GLfloat) );
         return 1;
@@ -104,12 +106,14 @@ static GLuint vbo_copy_vertices( struct vbo_exec_context *exec )
    case GL_LINE_LOOP:
    case GL_TRIANGLE_FAN:
    case GL_POLYGON:
-      if (nr == 0) 
+      if (nr == 0) {
         return 0;
+      }
       else if (nr == 1) {
         _mesa_memcpy( dst, src+0, sz * sizeof(GLfloat) );
         return 1;
-      } else {
+      }
+      else {
         _mesa_memcpy( dst, src+0, sz * sizeof(GLfloat) );
         _mesa_memcpy( dst+sz, src+(nr-1)*sz, sz * sizeof(GLfloat) );
         return 2;
@@ -122,9 +126,15 @@ static GLuint vbo_copy_vertices( struct vbo_exec_context *exec )
       /* fallthrough */
    case GL_QUAD_STRIP:
       switch (nr) {
-      case 0: ovf = 0; break;
-      case 1: ovf = 1; break;
-      default: ovf = 2 + (nr&1); break;
+      case 0:
+         ovf = 0;
+         break;
+      case 1:
+         ovf = 1;
+         break;
+      default:
+         ovf = 2 + (nr & 1);
+         break;
       }
       for (i = 0 ; i < ovf ; i++)
         _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) );
@@ -141,13 +151,14 @@ static GLuint vbo_copy_vertices( struct vbo_exec_context *exec )
 
 /* TODO: populate these as the vertex is defined:
  */
-static void vbo_exec_bind_arrays( GLcontext *ctx )
+static void
+vbo_exec_bind_arrays( GLcontext *ctx )
 {
    struct vbo_context *vbo = vbo_context(ctx);
    struct vbo_exec_context *exec = &vbo->exec;
    struct gl_client_array *arrays = exec->vtx.arrays;
-   GLuint count = exec->vtx.vert_count;
-   GLubyte *data = (GLubyte *)exec->vtx.buffer_map;
+   const GLuint count = exec->vtx.vert_count;
+   const GLubyte *data = (GLubyte *) exec->vtx.buffer_map;
    const GLuint *map;
    GLuint attr;
    GLbitfield varying_inputs = 0x0;
@@ -227,7 +238,7 @@ static void vbo_exec_bind_arrays( GLcontext *ctx )
         arrays[attr]._MaxElement = count; /* ??? */
 
         data += exec->vtx.attrsz[src] * sizeof(GLfloat);
-         varying_inputs |= 1<<attr;
+         varying_inputs |= 1 << attr;
       }
    }
 
@@ -235,18 +246,19 @@ static void vbo_exec_bind_arrays( GLcontext *ctx )
 }
 
 
-static void vbo_exec_vtx_unmap( struct vbo_exec_context *exec )
+static void
+vbo_exec_vtx_unmap( struct vbo_exec_context *exec )
 {
    GLenum target = GL_ARRAY_BUFFER_ARB;
 
    if (exec->vtx.bufferobj->Name) {
       GLcontext *ctx = exec->ctx;
       
-      if(ctx->Driver.FlushMappedBufferRange) {
+      if (ctx->Driver.FlushMappedBufferRange) {
          GLintptr offset = exec->vtx.buffer_used - exec->vtx.bufferobj->Offset;
          GLsizeiptr length = (exec->vtx.buffer_ptr - exec->vtx.buffer_map) * sizeof(float);
 
-         if(length)
+         if (length)
             ctx->Driver.FlushMappedBufferRange(ctx, target,
                                                offset, length,
                                                exec->vtx.bufferobj);
@@ -265,7 +277,9 @@ static void vbo_exec_vtx_unmap( struct vbo_exec_context *exec )
    }
 }
 
-void vbo_exec_vtx_map( struct vbo_exec_context *exec )
+
+void
+vbo_exec_vtx_map( struct vbo_exec_context *exec )
 {
    GLcontext *ctx = exec->ctx;
    GLenum target = GL_ARRAY_BUFFER_ARB;
@@ -282,8 +296,7 @@ void vbo_exec_vtx_map( struct vbo_exec_context *exec )
    }
 
    if (VBO_VERT_BUFFER_SIZE > exec->vtx.buffer_used + 1024 &&
-       ctx->Driver.MapBufferRange)
-   {
+       ctx->Driver.MapBufferRange) {
       exec->vtx.buffer_map = 
          (GLfloat *)ctx->Driver.MapBufferRange(ctx, 
                                                target, 
@@ -305,12 +318,13 @@ void vbo_exec_vtx_map( struct vbo_exec_context *exec )
                              VBO_VERT_BUFFER_SIZE, 
                              NULL, usage, exec->vtx.bufferobj);
 
-      exec->vtx.buffer_map = 
-         (GLfloat *)ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj);
+      exec->vtx.buffer_map = (GLfloat *)
+         ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj);
       exec->vtx.buffer_ptr = exec->vtx.buffer_map;
    }
 
-   if (0) _mesa_printf("map %d..\n", exec->vtx.buffer_used);
+   if (0)
+      _mesa_printf("map %d..\n", exec->vtx.buffer_used);
 }
 
 
@@ -318,13 +332,12 @@ void vbo_exec_vtx_map( struct vbo_exec_context *exec )
 /**
  * Execute the buffer and save copied verts.
  */
-void vbo_exec_vtx_flush( struct vbo_exec_context *exec,
-                         GLboolean unmap )
+void
+vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap )
 {
    if (0)
       vbo_exec_debug_verts( exec );
 
-
    if (exec->vtx.prim_count && 
        exec->vtx.vert_count) {
 
@@ -345,8 +358,9 @@ void vbo_exec_vtx_flush( struct vbo_exec_context *exec,
             vbo_exec_vtx_unmap( exec );
          }
 
-         if (0) _mesa_printf("%s %d %d\n", __FUNCTION__, exec->vtx.prim_count,
-                      exec->vtx.vert_count);
+         if (0)
+            _mesa_printf("%s %d %d\n", __FUNCTION__, exec->vtx.prim_count,
+                         exec->vtx.vert_count);
 
         vbo_context(ctx)->draw_prims( ctx, 
                                       exec->vtx.inputs, 
@@ -360,7 +374,7 @@ void vbo_exec_vtx_flush( struct vbo_exec_context *exec,
           */
          if (exec->vtx.bufferobj->Name && !unmap) {
             vbo_exec_vtx_map( exec );
-          }
+         }
       }
    }
 
@@ -372,14 +386,12 @@ void vbo_exec_vtx_flush( struct vbo_exec_context *exec,
       vbo_exec_vtx_unmap( exec );
    }
 
-
    if (unmap) 
       exec->vtx.max_vert = 0;
    else
       exec->vtx.max_vert = ((VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used) / 
                             (exec->vtx.vertex_size * sizeof(GLfloat)));
 
-
    exec->vtx.buffer_ptr = exec->vtx.buffer_map;
    exec->vtx.prim_count = 0;
    exec->vtx.vert_count = 0;
index dae778e741ee02f91fba9f42eab0eb28cf8489e6..ea87dede64627566052a5de2c0a0d18ca55a11f3 100644 (file)
@@ -161,7 +161,7 @@ void vbo_rebase_prims( GLcontext *ctx,
                                 GL_ELEMENT_ARRAY_BUFFER,
                                 ib->obj);
 
-      tmp_ib.obj = ctx->Array.NullBufferObj;
+      tmp_ib.obj = ctx->Shared->NullBufferObj;
       tmp_ib.ptr = tmp_indices;
       tmp_ib.count = ib->count;
       tmp_ib.type = ib->type;
index 5fb66d3318f6c77878c1ac14cfff3d9f0582d9ac..dcb14c868b854b7f06929c3539fdc5823e74deee 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "main/glheader.h"
 #include "main/imports.h"
+#include "main/image.h"
 #include "main/macros.h"
 #include "main/enums.h"
 #include "main/mtypes.h"
@@ -41,7 +42,8 @@
 
 #define ELT_TABLE_SIZE 16
 
-/* Used for vertex-level splitting of indexed buffers.  Note that
+/**
+ * Used for vertex-level splitting of indexed buffers.  Note that
  * non-indexed primitives may be converted to indexed in some cases
  * (eg loops, fans) in order to use this splitting path.
  */
@@ -73,23 +75,21 @@ struct copy_context {
    GLuint *translated_elt_buf;
    const GLuint *srcelt;
 
-   /* A baby hash table to avoid re-emitting (some) duplicate
+   /** A baby hash table to avoid re-emitting (some) duplicate
     * vertices when splitting indexed primitives.
     */
    struct { 
       GLuint in;
       GLuint out;
    } vert_cache[ELT_TABLE_SIZE];
-      
 
    GLuint vertex_size;
    GLubyte *dstbuf;
-   GLubyte *dstptr;            /* dstptr == dstbuf + dstelt_max * vertsize */
-   GLuint dstbuf_size; /* in vertices */
-   GLuint dstbuf_nr;           /* count of emitted vertices, also the
-                                * largest value in dstelt.  Our
-                                * MaxIndex.
-                                */
+   GLubyte *dstptr;     /**< dstptr == dstbuf + dstelt_max * vertsize */
+   GLuint dstbuf_size;  /**< in vertices */
+   GLuint dstbuf_nr;    /**< count of emitted vertices, also the largest value
+                         * in dstelt.  Our MaxIndex.
+                         */
 
    GLuint *dstelt;
    GLuint dstelt_nr;
@@ -102,32 +102,19 @@ struct copy_context {
 };
 
 
-static GLuint type_size( GLenum type )
-{
-   switch(type) {
-   case GL_BYTE: return sizeof(GLbyte);
-   case GL_UNSIGNED_BYTE: return sizeof(GLubyte);
-   case GL_SHORT: return sizeof(GLshort);
-   case GL_UNSIGNED_SHORT: return sizeof(GLushort);
-   case GL_INT: return sizeof(GLint);
-   case GL_UNSIGNED_INT: return sizeof(GLuint);
-   case GL_FLOAT: return sizeof(GLfloat);
-   case GL_DOUBLE: return sizeof(GLdouble);
-   default: return 0;
-   }
-}
-
 static GLuint attr_size( const struct gl_client_array *array )
 {
-   return array->Size * type_size(array->Type);
+   return array->Size * _mesa_sizeof_type(array->Type);
 }
 
 
-/* Starts returning true slightly before the buffer fills, to ensure
+/**
+ * Starts returning true slightly before the buffer fills, to ensure
  * that there is sufficient room for any remaining vertices to finish
  * off the prim:
  */
-static GLboolean check_flush( struct copy_context *copy )
+static GLboolean
+check_flush( struct copy_context *copy )
 {
    GLenum mode = copy->dstprim[copy->dstprim_nr].mode; 
 
@@ -145,7 +132,44 @@ static GLboolean check_flush( struct copy_context *copy )
    return GL_FALSE;
 }
 
-static void flush( struct copy_context *copy )
+
+/**
+ * Dump the parameters/info for a vbo->draw() call.
+ */
+static void
+dump_draw_info(GLcontext *ctx,
+               const struct gl_client_array **arrays,
+               const struct _mesa_prim *prims,
+               GLuint nr_prims,
+               const struct _mesa_index_buffer *ib,
+               GLuint min_index,
+               GLuint max_index)
+{
+   GLuint i, j;
+
+   _mesa_printf("VBO Draw:\n");
+   for (i = 0; i < nr_prims; i++) {
+      _mesa_printf("Prim %u of %u\n", i, nr_prims);
+      _mesa_printf("  Prim mode 0x%x\n", prims[i].mode);
+      _mesa_printf("  IB: %p\n", (void*) ib);
+      for (j = 0; j < VERT_ATTRIB_MAX; j++) {
+         _mesa_printf("    array %d at %p:\n", j, (void*) arrays[j]);
+         _mesa_printf("      enabled %d, ptr %p, size %d, type 0x%x, stride %d\n",
+                      arrays[j]->Enabled, arrays[j]->Ptr,
+                      arrays[j]->Size, arrays[j]->Type, arrays[j]->StrideB);
+         if (0) {
+            GLint k = prims[i].start + prims[i].count - 1;
+            GLfloat *last = (GLfloat *) (arrays[j]->Ptr + arrays[j]->Stride * k);
+            _mesa_printf("        last: %f %f %f\n",
+                         last[0], last[1], last[2]);
+         }
+      }
+   }
+}
+
+
+static void
+flush( struct copy_context *copy )
 {
    GLuint i;
 
@@ -153,6 +177,18 @@ static void flush( struct copy_context *copy )
     */
    copy->dstib.count = copy->dstelt_nr;
 
+#if 0
+   dump_draw_info(copy->ctx,
+                  copy->dstarray_ptr,
+                  copy->dstprim,
+                  copy->dstprim_nr,
+                  &copy->dstib,
+                  0,
+                  copy->dstbuf_nr);
+#else
+   (void) dump_draw_info;
+#endif
+
    copy->draw( copy->ctx,
               copy->dstarray_ptr,
               copy->dstprim,
@@ -175,8 +211,11 @@ static void flush( struct copy_context *copy )
 }
 
 
-
-static void begin( struct copy_context *copy, GLenum mode, GLboolean begin_flag )
+/**
+ * Called at begin of each primitive during replay.
+ */
+static void
+begin( struct copy_context *copy, GLenum mode, GLboolean begin_flag )
 {
    struct _mesa_prim *prim = &copy->dstprim[copy->dstprim_nr];
 
@@ -187,10 +226,12 @@ static void begin( struct copy_context *copy, GLenum mode, GLboolean begin_flag
 }
 
 
-/* Use a hashtable to attempt to identify recently-emitted vertices
+/**
+ * Use a hashtable to attempt to identify recently-emitted vertices
  * and avoid re-emitting them.
  */
-static GLuint elt(struct copy_context *copy, GLuint elt_idx)
+static GLuint
+elt(struct copy_context *copy, GLuint elt_idx)
 {
    GLuint elt = copy->srcelt[elt_idx];
    GLuint slot = elt & (ELT_TABLE_SIZE-1);
@@ -213,6 +254,17 @@ static GLuint elt(struct copy_context *copy, GLuint elt_idx)
         memcpy(csr, srcptr, copy->varying[i].size);
         csr += copy->varying[i].size;
 
+#ifdef NAN_CHECK
+         if (srcarray->Type == GL_FLOAT) {
+            GLuint k;
+            GLfloat *f = (GLfloat *) srcptr;
+            for (k = 0; k < srcarray->Size; k++) {
+               assert(!IS_INF_OR_NAN(f[k]));
+               assert(f[k] <= 1.0e20 && f[k] >= -1.0e20);
+            }
+         }
+#endif
+
         if (0) 
         {
            const GLuint *f = (const GLuint *)srcptr;
@@ -222,7 +274,6 @@ static GLuint elt(struct copy_context *copy, GLuint elt_idx)
               _mesa_printf("%x ", f[j]);
            _mesa_printf("\n");
         }
-              
       }
 
       copy->vert_cache[slot].in = elt;
@@ -230,9 +281,8 @@ static GLuint elt(struct copy_context *copy, GLuint elt_idx)
       copy->dstptr += copy->vertex_size;
 
       assert(csr == copy->dstptr);
-      assert(copy->dstptr == (copy->dstbuf + 
-                                   copy->dstbuf_nr * 
-                                   copy->vertex_size));
+      assert(copy->dstptr == (copy->dstbuf +
+                              copy->dstbuf_nr * copy->vertex_size));
    }
 /*    else */
 /*       _mesa_printf("  --> reuse vertex\n"); */
@@ -242,7 +292,12 @@ static GLuint elt(struct copy_context *copy, GLuint elt_idx)
    return check_flush(copy);
 }
 
-static void end( struct copy_context *copy, GLboolean end_flag )
+
+/**
+ * Called at end of each primitive during replay.
+ */
+static void
+end( struct copy_context *copy, GLboolean end_flag )
 {
    struct _mesa_prim *prim = &copy->dstprim[copy->dstprim_nr];
 
@@ -257,8 +312,8 @@ static void end( struct copy_context *copy, GLboolean end_flag )
 }
 
 
-
-static void replay_elts( struct copy_context *copy )
+static void
+replay_elts( struct copy_context *copy )
 {
    GLuint i, j, k;
    GLboolean split;
@@ -362,7 +417,8 @@ static void replay_elts( struct copy_context *copy )
 }
 
 
-static void replay_init( struct copy_context *copy )
+static void
+replay_init( struct copy_context *copy )
 {
    GLcontext *ctx = copy->ctx;
    GLuint i;
@@ -388,10 +444,7 @@ static void replay_init( struct copy_context *copy )
         copy->vertex_size += attr_size(copy->array[i]);
       
         if (vbo->Name && !vbo->Pointer) 
-           ctx->Driver.MapBuffer(ctx,
-                                 GL_ARRAY_BUFFER_ARB, 
-                                 GL_WRITE_ONLY, /* XXX */
-                                 vbo);
+           ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER, GL_READ_ONLY, vbo);
 
         copy->varying[j].src_ptr = ADD_POINTERS(vbo->Pointer,
                                                 copy->array[i]->Ptr);
@@ -405,12 +458,11 @@ static void replay_init( struct copy_context *copy )
     * do it internally.
     */
    if (copy->ib->obj->Name && !copy->ib->obj->Pointer) 
-      ctx->Driver.MapBuffer(ctx, 
-                           GL_ARRAY_BUFFER_ARB, /* XXX */
-                           GL_WRITE_ONLY, /* XXX */
+      ctx->Driver.MapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER, GL_READ_ONLY,
                            copy->ib->obj);
 
-   srcptr = (const GLubyte *)ADD_POINTERS(copy->ib->obj->Pointer, copy->ib->ptr);
+   srcptr = (const GLubyte *) ADD_POINTERS(copy->ib->obj->Pointer,
+                                           copy->ib->ptr);
 
    switch (copy->ib->type) {
    case GL_UNSIGNED_BYTE:
@@ -434,7 +486,6 @@ static void replay_init( struct copy_context *copy )
       copy->srcelt = (const GLuint *)srcptr;
       break;
    }
-   
 
    /* Figure out the maximum allowed vertex buffer size:
     */
@@ -449,8 +500,7 @@ static void replay_init( struct copy_context *copy )
     *
     * XXX:  This should be a VBO!
     */
-   copy->dstbuf = _mesa_malloc(copy->dstbuf_size * 
-                              copy->vertex_size);   
+   copy->dstbuf = _mesa_malloc(copy->dstbuf_size * copy->vertex_size);   
    copy->dstptr = copy->dstbuf;
 
    /* Setup new vertex arrays to point into the output buffer: 
@@ -467,7 +517,7 @@ static void replay_init( struct copy_context *copy )
       dst->Ptr = copy->dstbuf + offset;
       dst->Enabled = GL_TRUE;
       dst->Normalized = src->Normalized; 
-      dst->BufferObj = ctx->Array.NullBufferObj;
+      dst->BufferObj = ctx->Shared->NullBufferObj;
       dst->_MaxElement = copy->dstbuf_size; /* may be less! */
 
       offset += copy->varying[i].size;
@@ -487,12 +537,16 @@ static void replay_init( struct copy_context *copy )
     */
    copy->dstib.count = 0;      /* duplicates dstelt_nr */
    copy->dstib.type = GL_UNSIGNED_INT;
-   copy->dstib.obj = ctx->Array.NullBufferObj;
+   copy->dstib.obj = ctx->Shared->NullBufferObj;
    copy->dstib.ptr = copy->dstelt;
 }
 
 
-static void replay_finish( struct copy_context *copy )
+/**
+ * Free up everything allocated during split/replay.
+ */
+static void
+replay_finish( struct copy_context *copy )
 {
    GLcontext *ctx = copy->ctx;
    GLuint i;
@@ -502,25 +556,26 @@ static void replay_finish( struct copy_context *copy )
    _mesa_free(copy->translated_elt_buf);
    _mesa_free(copy->dstbuf);
    _mesa_free(copy->dstelt);
-   
+
    /* Unmap VBO's 
     */
    for (i = 0; i < copy->nr_varying; i++) {
       struct gl_buffer_object *vbo = copy->varying[i].array->BufferObj;
-
       if (vbo->Name && vbo->Pointer) 
-        ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER_ARB, vbo);
+        ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER, vbo);
    }
 
    /* Unmap index buffer:
     */
    if (copy->ib->obj->Name && copy->ib->obj->Pointer) {
-      ctx->Driver.UnmapBuffer(ctx, 
-                             GL_ARRAY_BUFFER_ARB, /* XXX */
-                             copy->ib->obj);
+      ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER, copy->ib->obj);
    }
 }
 
+
+/**
+ * Split VBO into smaller pieces, draw the pieces.
+ */
 void vbo_split_copy( GLcontext *ctx,
                     const struct gl_client_array *arrays[],
                     const struct _mesa_prim *prim,
@@ -546,13 +601,11 @@ void vbo_split_copy( GLcontext *ctx,
    copy.draw = draw;
    copy.limits = limits;
 
-
    /* Clear the vertex cache:
     */
    for (i = 0; i < ELT_TABLE_SIZE; i++)
       copy.vert_cache[i].in = ~0;
 
-
    replay_init(&copy);
    replay_elts(&copy);
    replay_finish(&copy);
index fbc856e93b0f8b5aa308d781e8a628edf3f1dbb0..3ed6b34fbf079686654597de86b619db66dd492f 100644 (file)
@@ -221,7 +221,7 @@ static void split_prims( struct split_context *split)
 
         ib.count = count;
         ib.type = GL_UNSIGNED_INT;
-        ib.obj = split->ctx->Array.NullBufferObj;
+        ib.obj = split->ctx->Shared->NullBufferObj;
         ib.ptr = elts;
            
         tmpprim = *prim;
index fe05549c1d5797386cd3d7cc053f399c8d20b9ef..dc6cfa72f79157f6678f19f6d159b7f714539aa3 100644 (file)
@@ -21157,21 +21157,21 @@ GL_PREFIX(RenderbufferStorageMultisample):
        .size   GL_PREFIX(RenderbufferStorageMultisample), .-GL_PREFIX(RenderbufferStorageMultisample)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(PolygonOffsetEXT)
-       .type   GL_PREFIX(PolygonOffsetEXT), @function
-GL_PREFIX(PolygonOffsetEXT):
+       .globl  GL_PREFIX(FlushMappedBufferRange)
+       .type   GL_PREFIX(FlushMappedBufferRange), @function
+GL_PREFIX(FlushMappedBufferRange):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
        movq    4496(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
-       subq    $24, %rsp
-       movq    %xmm0, (%rsp)
-       movq    %xmm1, 8(%rsp)
+       pushq   %rdi
+       pushq   %rsi
+       pushq   %rdx
        call    _x86_64_get_dispatch@PLT
-       movq    8(%rsp), %xmm1
-       movq    (%rsp), %xmm0
-       addq    $24, %rsp
+       popq    %rdx
+       popq    %rsi
+       popq    %rdi
        movq    4496(%rax), %r11
        jmp     *%r11
 #else
@@ -21181,23 +21181,22 @@ GL_PREFIX(PolygonOffsetEXT):
        movq    4496(%rax), %r11
        jmp     *%r11
 1:
-       subq    $24, %rsp
-       movq    %xmm0, (%rsp)
-       movq    %xmm1, 8(%rsp)
+       pushq   %rdi
+       pushq   %rsi
+       pushq   %rdx
        call    _glapi_get_dispatch
-       movq    8(%rsp), %xmm1
-       movq    (%rsp), %xmm0
-       addq    $24, %rsp
+       popq    %rdx
+       popq    %rsi
+       popq    %rdi
        movq    4496(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(PolygonOffsetEXT), .-GL_PREFIX(PolygonOffsetEXT)
+       .size   GL_PREFIX(FlushMappedBufferRange), .-GL_PREFIX(FlushMappedBufferRange)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_563)
-       .type   GL_PREFIX(_dispatch_stub_563), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_563))
-GL_PREFIX(_dispatch_stub_563):
+       .globl  GL_PREFIX(MapBufferRange)
+       .type   GL_PREFIX(MapBufferRange), @function
+GL_PREFIX(MapBufferRange):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
        movq    4504(%rax), %r11
@@ -21205,9 +21204,13 @@ GL_PREFIX(_dispatch_stub_563):
 #elif defined(PTHREADS)
        pushq   %rdi
        pushq   %rsi
+       pushq   %rdx
+       pushq   %rcx
        pushq   %rbp
        call    _x86_64_get_dispatch@PLT
        popq    %rbp
+       popq    %rcx
+       popq    %rdx
        popq    %rsi
        popq    %rdi
        movq    4504(%rax), %r11
@@ -21221,21 +21224,24 @@ GL_PREFIX(_dispatch_stub_563):
 1:
        pushq   %rdi
        pushq   %rsi
+       pushq   %rdx
+       pushq   %rcx
        pushq   %rbp
        call    _glapi_get_dispatch
        popq    %rbp
+       popq    %rcx
+       popq    %rdx
        popq    %rsi
        popq    %rdi
        movq    4504(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_563), .-GL_PREFIX(_dispatch_stub_563)
+       .size   GL_PREFIX(MapBufferRange), .-GL_PREFIX(MapBufferRange)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_564)
-       .type   GL_PREFIX(_dispatch_stub_564), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_564))
-GL_PREFIX(_dispatch_stub_564):
+       .globl  GL_PREFIX(CopyBufferSubData)
+       .type   GL_PREFIX(CopyBufferSubData), @function
+GL_PREFIX(CopyBufferSubData):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
        movq    4512(%rax), %r11
@@ -21243,9 +21249,13 @@ GL_PREFIX(_dispatch_stub_564):
 #elif defined(PTHREADS)
        pushq   %rdi
        pushq   %rsi
-       pushq   %rbp
+       pushq   %rdx
+       pushq   %rcx
+       pushq   %r8
        call    _x86_64_get_dispatch@PLT
-       popq    %rbp
+       popq    %r8
+       popq    %rcx
+       popq    %rdx
        popq    %rsi
        popq    %rdi
        movq    4512(%rax), %r11
@@ -21259,32 +21269,35 @@ GL_PREFIX(_dispatch_stub_564):
 1:
        pushq   %rdi
        pushq   %rsi
-       pushq   %rbp
+       pushq   %rdx
+       pushq   %rcx
+       pushq   %r8
        call    _glapi_get_dispatch
-       popq    %rbp
+       popq    %r8
+       popq    %rcx
+       popq    %rdx
        popq    %rsi
        popq    %rdi
        movq    4512(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_564), .-GL_PREFIX(_dispatch_stub_564)
+       .size   GL_PREFIX(CopyBufferSubData), .-GL_PREFIX(CopyBufferSubData)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_565)
-       .type   GL_PREFIX(_dispatch_stub_565), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_565))
-GL_PREFIX(_dispatch_stub_565):
+       .globl  GL_PREFIX(PolygonOffsetEXT)
+       .type   GL_PREFIX(PolygonOffsetEXT), @function
+GL_PREFIX(PolygonOffsetEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
        movq    4520(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $24, %rsp
-       movq    %rdi, (%rsp)
-       movq    %xmm0, 8(%rsp)
+       movq    %xmm0, (%rsp)
+       movq    %xmm1, 8(%rsp)
        call    _x86_64_get_dispatch@PLT
-       movq    8(%rsp), %xmm0
-       movq    (%rsp), %rdi
+       movq    8(%rsp), %xmm1
+       movq    (%rsp), %xmm0
        addq    $24, %rsp
        movq    4520(%rax), %r11
        jmp     *%r11
@@ -21296,16 +21309,16 @@ GL_PREFIX(_dispatch_stub_565):
        jmp     *%r11
 1:
        subq    $24, %rsp
-       movq    %rdi, (%rsp)
-       movq    %xmm0, 8(%rsp)
+       movq    %xmm0, (%rsp)
+       movq    %xmm1, 8(%rsp)
        call    _glapi_get_dispatch
-       movq    8(%rsp), %xmm0
-       movq    (%rsp), %rdi
+       movq    8(%rsp), %xmm1
+       movq    (%rsp), %xmm0
        addq    $24, %rsp
        movq    4520(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_565), .-GL_PREFIX(_dispatch_stub_565)
+       .size   GL_PREFIX(PolygonOffsetEXT), .-GL_PREFIX(PolygonOffsetEXT)
 
        .p2align        4,,15
        .globl  GL_PREFIX(_dispatch_stub_566)
@@ -21393,13 +21406,13 @@ GL_PREFIX(_dispatch_stub_568):
        movq    4544(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
-       pushq   %rdi
-       pushq   %rsi
-       pushq   %rbp
+       subq    $24, %rsp
+       movq    %rdi, (%rsp)
+       movq    %xmm0, 8(%rsp)
        call    _x86_64_get_dispatch@PLT
-       popq    %rbp
-       popq    %rsi
-       popq    %rdi
+       movq    8(%rsp), %xmm0
+       movq    (%rsp), %rdi
+       addq    $24, %rsp
        movq    4544(%rax), %r11
        jmp     *%r11
 #else
@@ -21409,13 +21422,13 @@ GL_PREFIX(_dispatch_stub_568):
        movq    4544(%rax), %r11
        jmp     *%r11
 1:
-       pushq   %rdi
-       pushq   %rsi
-       pushq   %rbp
+       subq    $24, %rsp
+       movq    %rdi, (%rsp)
+       movq    %xmm0, 8(%rsp)
        call    _glapi_get_dispatch
-       popq    %rbp
-       popq    %rsi
-       popq    %rdi
+       movq    8(%rsp), %xmm0
+       movq    (%rsp), %rdi
+       addq    $24, %rsp
        movq    4544(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
@@ -21470,7 +21483,11 @@ GL_PREFIX(_dispatch_stub_570):
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
+       pushq   %rsi
+       pushq   %rbp
        call    _x86_64_get_dispatch@PLT
+       popq    %rbp
+       popq    %rsi
        popq    %rdi
        movq    4560(%rax), %r11
        jmp     *%r11
@@ -21482,20 +21499,130 @@ GL_PREFIX(_dispatch_stub_570):
        jmp     *%r11
 1:
        pushq   %rdi
+       pushq   %rsi
+       pushq   %rbp
        call    _glapi_get_dispatch
+       popq    %rbp
+       popq    %rsi
        popq    %rdi
        movq    4560(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(_dispatch_stub_570), .-GL_PREFIX(_dispatch_stub_570)
 
+       .p2align        4,,15
+       .globl  GL_PREFIX(_dispatch_stub_571)
+       .type   GL_PREFIX(_dispatch_stub_571), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_571))
+GL_PREFIX(_dispatch_stub_571):
+#if defined(GLX_USE_TLS)
+       call    _x86_64_get_dispatch@PLT
+       movq    4568(%rax), %r11
+       jmp     *%r11
+#elif defined(PTHREADS)
+       pushq   %rdi
+       pushq   %rsi
+       pushq   %rbp
+       call    _x86_64_get_dispatch@PLT
+       popq    %rbp
+       popq    %rsi
+       popq    %rdi
+       movq    4568(%rax), %r11
+       jmp     *%r11
+#else
+       movq    _glapi_Dispatch(%rip), %rax
+       testq   %rax, %rax
+       je      1f
+       movq    4568(%rax), %r11
+       jmp     *%r11
+1:
+       pushq   %rdi
+       pushq   %rsi
+       pushq   %rbp
+       call    _glapi_get_dispatch
+       popq    %rbp
+       popq    %rsi
+       popq    %rdi
+       movq    4568(%rax), %r11
+       jmp     *%r11
+#endif /* defined(GLX_USE_TLS) */
+       .size   GL_PREFIX(_dispatch_stub_571), .-GL_PREFIX(_dispatch_stub_571)
+
+       .p2align        4,,15
+       .globl  GL_PREFIX(_dispatch_stub_572)
+       .type   GL_PREFIX(_dispatch_stub_572), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_572))
+GL_PREFIX(_dispatch_stub_572):
+#if defined(GLX_USE_TLS)
+       call    _x86_64_get_dispatch@PLT
+       movq    4576(%rax), %r11
+       jmp     *%r11
+#elif defined(PTHREADS)
+       pushq   %rdi
+       pushq   %rsi
+       pushq   %rbp
+       call    _x86_64_get_dispatch@PLT
+       popq    %rbp
+       popq    %rsi
+       popq    %rdi
+       movq    4576(%rax), %r11
+       jmp     *%r11
+#else
+       movq    _glapi_Dispatch(%rip), %rax
+       testq   %rax, %rax
+       je      1f
+       movq    4576(%rax), %r11
+       jmp     *%r11
+1:
+       pushq   %rdi
+       pushq   %rsi
+       pushq   %rbp
+       call    _glapi_get_dispatch
+       popq    %rbp
+       popq    %rsi
+       popq    %rdi
+       movq    4576(%rax), %r11
+       jmp     *%r11
+#endif /* defined(GLX_USE_TLS) */
+       .size   GL_PREFIX(_dispatch_stub_572), .-GL_PREFIX(_dispatch_stub_572)
+
+       .p2align        4,,15
+       .globl  GL_PREFIX(_dispatch_stub_573)
+       .type   GL_PREFIX(_dispatch_stub_573), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_573))
+GL_PREFIX(_dispatch_stub_573):
+#if defined(GLX_USE_TLS)
+       call    _x86_64_get_dispatch@PLT
+       movq    4584(%rax), %r11
+       jmp     *%r11
+#elif defined(PTHREADS)
+       pushq   %rdi
+       call    _x86_64_get_dispatch@PLT
+       popq    %rdi
+       movq    4584(%rax), %r11
+       jmp     *%r11
+#else
+       movq    _glapi_Dispatch(%rip), %rax
+       testq   %rax, %rax
+       je      1f
+       movq    4584(%rax), %r11
+       jmp     *%r11
+1:
+       pushq   %rdi
+       call    _glapi_get_dispatch
+       popq    %rdi
+       movq    4584(%rax), %r11
+       jmp     *%r11
+#endif /* defined(GLX_USE_TLS) */
+       .size   GL_PREFIX(_dispatch_stub_573), .-GL_PREFIX(_dispatch_stub_573)
+
        .p2align        4,,15
        .globl  GL_PREFIX(ColorPointerEXT)
        .type   GL_PREFIX(ColorPointerEXT), @function
 GL_PREFIX(ColorPointerEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4568(%rax), %r11
+       movq    4592(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -21509,13 +21636,13 @@ GL_PREFIX(ColorPointerEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4568(%rax), %r11
+       movq    4592(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4568(%rax), %r11
+       movq    4592(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -21529,7 +21656,7 @@ GL_PREFIX(ColorPointerEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4568(%rax), %r11
+       movq    4592(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(ColorPointerEXT), .-GL_PREFIX(ColorPointerEXT)
@@ -21540,7 +21667,7 @@ GL_PREFIX(ColorPointerEXT):
 GL_PREFIX(EdgeFlagPointerEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4576(%rax), %r11
+       movq    4600(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -21550,13 +21677,13 @@ GL_PREFIX(EdgeFlagPointerEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4576(%rax), %r11
+       movq    4600(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4576(%rax), %r11
+       movq    4600(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -21566,7 +21693,7 @@ GL_PREFIX(EdgeFlagPointerEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4576(%rax), %r11
+       movq    4600(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(EdgeFlagPointerEXT), .-GL_PREFIX(EdgeFlagPointerEXT)
@@ -21577,7 +21704,7 @@ GL_PREFIX(EdgeFlagPointerEXT):
 GL_PREFIX(IndexPointerEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4584(%rax), %r11
+       movq    4608(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -21591,13 +21718,13 @@ GL_PREFIX(IndexPointerEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4584(%rax), %r11
+       movq    4608(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4584(%rax), %r11
+       movq    4608(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -21611,7 +21738,7 @@ GL_PREFIX(IndexPointerEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4584(%rax), %r11
+       movq    4608(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(IndexPointerEXT), .-GL_PREFIX(IndexPointerEXT)
@@ -21622,7 +21749,7 @@ GL_PREFIX(IndexPointerEXT):
 GL_PREFIX(NormalPointerEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4592(%rax), %r11
+       movq    4616(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -21636,13 +21763,13 @@ GL_PREFIX(NormalPointerEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4592(%rax), %r11
+       movq    4616(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4592(%rax), %r11
+       movq    4616(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -21656,7 +21783,7 @@ GL_PREFIX(NormalPointerEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4592(%rax), %r11
+       movq    4616(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(NormalPointerEXT), .-GL_PREFIX(NormalPointerEXT)
@@ -21667,7 +21794,7 @@ GL_PREFIX(NormalPointerEXT):
 GL_PREFIX(TexCoordPointerEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4600(%rax), %r11
+       movq    4624(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -21681,13 +21808,13 @@ GL_PREFIX(TexCoordPointerEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4600(%rax), %r11
+       movq    4624(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4600(%rax), %r11
+       movq    4624(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -21701,7 +21828,7 @@ GL_PREFIX(TexCoordPointerEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4600(%rax), %r11
+       movq    4624(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(TexCoordPointerEXT), .-GL_PREFIX(TexCoordPointerEXT)
@@ -21712,7 +21839,7 @@ GL_PREFIX(TexCoordPointerEXT):
 GL_PREFIX(VertexPointerEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4608(%rax), %r11
+       movq    4632(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -21726,13 +21853,13 @@ GL_PREFIX(VertexPointerEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4608(%rax), %r11
+       movq    4632(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4608(%rax), %r11
+       movq    4632(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -21746,7 +21873,7 @@ GL_PREFIX(VertexPointerEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4608(%rax), %r11
+       movq    4632(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexPointerEXT), .-GL_PREFIX(VertexPointerEXT)
@@ -21757,7 +21884,7 @@ GL_PREFIX(VertexPointerEXT):
 GL_PREFIX(PointParameterfEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4616(%rax), %r11
+       movq    4640(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $24, %rsp
@@ -21767,13 +21894,13 @@ GL_PREFIX(PointParameterfEXT):
        movq    8(%rsp), %xmm0
        movq    (%rsp), %rdi
        addq    $24, %rsp
-       movq    4616(%rax), %r11
+       movq    4640(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4616(%rax), %r11
+       movq    4640(%rax), %r11
        jmp     *%r11
 1:
        subq    $24, %rsp
@@ -21783,7 +21910,7 @@ GL_PREFIX(PointParameterfEXT):
        movq    8(%rsp), %xmm0
        movq    (%rsp), %rdi
        addq    $24, %rsp
-       movq    4616(%rax), %r11
+       movq    4640(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(PointParameterfEXT), .-GL_PREFIX(PointParameterfEXT)
@@ -21794,7 +21921,7 @@ GL_PREFIX(PointParameterfEXT):
 GL_PREFIX(PointParameterfvEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4624(%rax), %r11
+       movq    4648(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -21804,13 +21931,13 @@ GL_PREFIX(PointParameterfvEXT):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    4624(%rax), %r11
+       movq    4648(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4624(%rax), %r11
+       movq    4648(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -21820,7 +21947,7 @@ GL_PREFIX(PointParameterfvEXT):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    4624(%rax), %r11
+       movq    4648(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(PointParameterfvEXT), .-GL_PREFIX(PointParameterfvEXT)
@@ -21831,7 +21958,7 @@ GL_PREFIX(PointParameterfvEXT):
 GL_PREFIX(LockArraysEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4632(%rax), %r11
+       movq    4656(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -21841,13 +21968,13 @@ GL_PREFIX(LockArraysEXT):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    4632(%rax), %r11
+       movq    4656(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4632(%rax), %r11
+       movq    4656(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -21857,7 +21984,7 @@ GL_PREFIX(LockArraysEXT):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    4632(%rax), %r11
+       movq    4656(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(LockArraysEXT), .-GL_PREFIX(LockArraysEXT)
@@ -21868,37 +21995,37 @@ GL_PREFIX(LockArraysEXT):
 GL_PREFIX(UnlockArraysEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4640(%rax), %r11
+       movq    4664(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rbp
        call    _x86_64_get_dispatch@PLT
        popq    %rbp
-       movq    4640(%rax), %r11
+       movq    4664(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4640(%rax), %r11
+       movq    4664(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rbp
        call    _glapi_get_dispatch
        popq    %rbp
-       movq    4640(%rax), %r11
+       movq    4664(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(UnlockArraysEXT), .-GL_PREFIX(UnlockArraysEXT)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_581)
-       .type   GL_PREFIX(_dispatch_stub_581), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_581))
-GL_PREFIX(_dispatch_stub_581):
+       .globl  GL_PREFIX(_dispatch_stub_584)
+       .type   GL_PREFIX(_dispatch_stub_584), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_584))
+GL_PREFIX(_dispatch_stub_584):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4648(%rax), %r11
+       movq    4672(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -21908,13 +22035,13 @@ GL_PREFIX(_dispatch_stub_581):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    4648(%rax), %r11
+       movq    4672(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4648(%rax), %r11
+       movq    4672(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -21924,19 +22051,19 @@ GL_PREFIX(_dispatch_stub_581):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    4648(%rax), %r11
+       movq    4672(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_581), .-GL_PREFIX(_dispatch_stub_581)
+       .size   GL_PREFIX(_dispatch_stub_584), .-GL_PREFIX(_dispatch_stub_584)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_582)
-       .type   GL_PREFIX(_dispatch_stub_582), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_582))
-GL_PREFIX(_dispatch_stub_582):
+       .globl  GL_PREFIX(_dispatch_stub_585)
+       .type   GL_PREFIX(_dispatch_stub_585), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_585))
+GL_PREFIX(_dispatch_stub_585):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4656(%rax), %r11
+       movq    4680(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -21946,13 +22073,13 @@ GL_PREFIX(_dispatch_stub_582):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    4656(%rax), %r11
+       movq    4680(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4656(%rax), %r11
+       movq    4680(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -21962,10 +22089,10 @@ GL_PREFIX(_dispatch_stub_582):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    4656(%rax), %r11
+       movq    4680(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_582), .-GL_PREFIX(_dispatch_stub_582)
+       .size   GL_PREFIX(_dispatch_stub_585), .-GL_PREFIX(_dispatch_stub_585)
 
        .p2align        4,,15
        .globl  GL_PREFIX(SecondaryColor3bEXT)
@@ -21973,7 +22100,7 @@ GL_PREFIX(_dispatch_stub_582):
 GL_PREFIX(SecondaryColor3bEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4664(%rax), %r11
+       movq    4688(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -21983,13 +22110,13 @@ GL_PREFIX(SecondaryColor3bEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4664(%rax), %r11
+       movq    4688(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4664(%rax), %r11
+       movq    4688(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -21999,7 +22126,7 @@ GL_PREFIX(SecondaryColor3bEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4664(%rax), %r11
+       movq    4688(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(SecondaryColor3bEXT), .-GL_PREFIX(SecondaryColor3bEXT)
@@ -22010,25 +22137,25 @@ GL_PREFIX(SecondaryColor3bEXT):
 GL_PREFIX(SecondaryColor3bvEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4672(%rax), %r11
+       movq    4696(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    4672(%rax), %r11
+       movq    4696(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4672(%rax), %r11
+       movq    4696(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    4672(%rax), %r11
+       movq    4696(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(SecondaryColor3bvEXT), .-GL_PREFIX(SecondaryColor3bvEXT)
@@ -22039,7 +22166,7 @@ GL_PREFIX(SecondaryColor3bvEXT):
 GL_PREFIX(SecondaryColor3dEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4680(%rax), %r11
+       movq    4704(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $24, %rsp
@@ -22051,13 +22178,13 @@ GL_PREFIX(SecondaryColor3dEXT):
        movq    8(%rsp), %xmm1
        movq    (%rsp), %xmm0
        addq    $24, %rsp
-       movq    4680(%rax), %r11
+       movq    4704(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4680(%rax), %r11
+       movq    4704(%rax), %r11
        jmp     *%r11
 1:
        subq    $24, %rsp
@@ -22069,7 +22196,7 @@ GL_PREFIX(SecondaryColor3dEXT):
        movq    8(%rsp), %xmm1
        movq    (%rsp), %xmm0
        addq    $24, %rsp
-       movq    4680(%rax), %r11
+       movq    4704(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(SecondaryColor3dEXT), .-GL_PREFIX(SecondaryColor3dEXT)
@@ -22080,25 +22207,25 @@ GL_PREFIX(SecondaryColor3dEXT):
 GL_PREFIX(SecondaryColor3dvEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4688(%rax), %r11
+       movq    4712(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    4688(%rax), %r11
+       movq    4712(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4688(%rax), %r11
+       movq    4712(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    4688(%rax), %r11
+       movq    4712(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(SecondaryColor3dvEXT), .-GL_PREFIX(SecondaryColor3dvEXT)
@@ -22109,7 +22236,7 @@ GL_PREFIX(SecondaryColor3dvEXT):
 GL_PREFIX(SecondaryColor3fEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4696(%rax), %r11
+       movq    4720(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $24, %rsp
@@ -22121,13 +22248,13 @@ GL_PREFIX(SecondaryColor3fEXT):
        movq    8(%rsp), %xmm1
        movq    (%rsp), %xmm0
        addq    $24, %rsp
-       movq    4696(%rax), %r11
+       movq    4720(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4696(%rax), %r11
+       movq    4720(%rax), %r11
        jmp     *%r11
 1:
        subq    $24, %rsp
@@ -22139,7 +22266,7 @@ GL_PREFIX(SecondaryColor3fEXT):
        movq    8(%rsp), %xmm1
        movq    (%rsp), %xmm0
        addq    $24, %rsp
-       movq    4696(%rax), %r11
+       movq    4720(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(SecondaryColor3fEXT), .-GL_PREFIX(SecondaryColor3fEXT)
@@ -22150,25 +22277,25 @@ GL_PREFIX(SecondaryColor3fEXT):
 GL_PREFIX(SecondaryColor3fvEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4704(%rax), %r11
+       movq    4728(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    4704(%rax), %r11
+       movq    4728(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4704(%rax), %r11
+       movq    4728(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    4704(%rax), %r11
+       movq    4728(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(SecondaryColor3fvEXT), .-GL_PREFIX(SecondaryColor3fvEXT)
@@ -22179,7 +22306,7 @@ GL_PREFIX(SecondaryColor3fvEXT):
 GL_PREFIX(SecondaryColor3iEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4712(%rax), %r11
+       movq    4736(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -22189,13 +22316,13 @@ GL_PREFIX(SecondaryColor3iEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4712(%rax), %r11
+       movq    4736(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4712(%rax), %r11
+       movq    4736(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -22205,7 +22332,7 @@ GL_PREFIX(SecondaryColor3iEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4712(%rax), %r11
+       movq    4736(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(SecondaryColor3iEXT), .-GL_PREFIX(SecondaryColor3iEXT)
@@ -22216,25 +22343,25 @@ GL_PREFIX(SecondaryColor3iEXT):
 GL_PREFIX(SecondaryColor3ivEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4720(%rax), %r11
+       movq    4744(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    4720(%rax), %r11
+       movq    4744(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4720(%rax), %r11
+       movq    4744(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    4720(%rax), %r11
+       movq    4744(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(SecondaryColor3ivEXT), .-GL_PREFIX(SecondaryColor3ivEXT)
@@ -22245,7 +22372,7 @@ GL_PREFIX(SecondaryColor3ivEXT):
 GL_PREFIX(SecondaryColor3sEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4728(%rax), %r11
+       movq    4752(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -22255,13 +22382,13 @@ GL_PREFIX(SecondaryColor3sEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4728(%rax), %r11
+       movq    4752(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4728(%rax), %r11
+       movq    4752(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -22271,7 +22398,7 @@ GL_PREFIX(SecondaryColor3sEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4728(%rax), %r11
+       movq    4752(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(SecondaryColor3sEXT), .-GL_PREFIX(SecondaryColor3sEXT)
@@ -22282,25 +22409,25 @@ GL_PREFIX(SecondaryColor3sEXT):
 GL_PREFIX(SecondaryColor3svEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4736(%rax), %r11
+       movq    4760(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    4736(%rax), %r11
+       movq    4760(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4736(%rax), %r11
+       movq    4760(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    4736(%rax), %r11
+       movq    4760(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(SecondaryColor3svEXT), .-GL_PREFIX(SecondaryColor3svEXT)
@@ -22311,7 +22438,7 @@ GL_PREFIX(SecondaryColor3svEXT):
 GL_PREFIX(SecondaryColor3ubEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4744(%rax), %r11
+       movq    4768(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -22321,13 +22448,13 @@ GL_PREFIX(SecondaryColor3ubEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4744(%rax), %r11
+       movq    4768(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4744(%rax), %r11
+       movq    4768(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -22337,7 +22464,7 @@ GL_PREFIX(SecondaryColor3ubEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4744(%rax), %r11
+       movq    4768(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(SecondaryColor3ubEXT), .-GL_PREFIX(SecondaryColor3ubEXT)
@@ -22348,25 +22475,25 @@ GL_PREFIX(SecondaryColor3ubEXT):
 GL_PREFIX(SecondaryColor3ubvEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4752(%rax), %r11
+       movq    4776(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    4752(%rax), %r11
+       movq    4776(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4752(%rax), %r11
+       movq    4776(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    4752(%rax), %r11
+       movq    4776(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(SecondaryColor3ubvEXT), .-GL_PREFIX(SecondaryColor3ubvEXT)
@@ -22377,7 +22504,7 @@ GL_PREFIX(SecondaryColor3ubvEXT):
 GL_PREFIX(SecondaryColor3uiEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4760(%rax), %r11
+       movq    4784(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -22387,13 +22514,13 @@ GL_PREFIX(SecondaryColor3uiEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4760(%rax), %r11
+       movq    4784(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4760(%rax), %r11
+       movq    4784(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -22403,7 +22530,7 @@ GL_PREFIX(SecondaryColor3uiEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4760(%rax), %r11
+       movq    4784(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(SecondaryColor3uiEXT), .-GL_PREFIX(SecondaryColor3uiEXT)
@@ -22414,25 +22541,25 @@ GL_PREFIX(SecondaryColor3uiEXT):
 GL_PREFIX(SecondaryColor3uivEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4768(%rax), %r11
+       movq    4792(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    4768(%rax), %r11
+       movq    4792(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4768(%rax), %r11
+       movq    4792(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    4768(%rax), %r11
+       movq    4792(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(SecondaryColor3uivEXT), .-GL_PREFIX(SecondaryColor3uivEXT)
@@ -22443,7 +22570,7 @@ GL_PREFIX(SecondaryColor3uivEXT):
 GL_PREFIX(SecondaryColor3usEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4776(%rax), %r11
+       movq    4800(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -22453,13 +22580,13 @@ GL_PREFIX(SecondaryColor3usEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4776(%rax), %r11
+       movq    4800(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4776(%rax), %r11
+       movq    4800(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -22469,7 +22596,7 @@ GL_PREFIX(SecondaryColor3usEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4776(%rax), %r11
+       movq    4800(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(SecondaryColor3usEXT), .-GL_PREFIX(SecondaryColor3usEXT)
@@ -22480,25 +22607,25 @@ GL_PREFIX(SecondaryColor3usEXT):
 GL_PREFIX(SecondaryColor3usvEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4784(%rax), %r11
+       movq    4808(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    4784(%rax), %r11
+       movq    4808(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4784(%rax), %r11
+       movq    4808(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    4784(%rax), %r11
+       movq    4808(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(SecondaryColor3usvEXT), .-GL_PREFIX(SecondaryColor3usvEXT)
@@ -22509,7 +22636,7 @@ GL_PREFIX(SecondaryColor3usvEXT):
 GL_PREFIX(SecondaryColorPointerEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4792(%rax), %r11
+       movq    4816(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -22523,13 +22650,13 @@ GL_PREFIX(SecondaryColorPointerEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4792(%rax), %r11
+       movq    4816(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4792(%rax), %r11
+       movq    4816(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -22543,7 +22670,7 @@ GL_PREFIX(SecondaryColorPointerEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4792(%rax), %r11
+       movq    4816(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(SecondaryColorPointerEXT), .-GL_PREFIX(SecondaryColorPointerEXT)
@@ -22554,7 +22681,7 @@ GL_PREFIX(SecondaryColorPointerEXT):
 GL_PREFIX(MultiDrawArraysEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4800(%rax), %r11
+       movq    4824(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -22568,13 +22695,13 @@ GL_PREFIX(MultiDrawArraysEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4800(%rax), %r11
+       movq    4824(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4800(%rax), %r11
+       movq    4824(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -22588,7 +22715,7 @@ GL_PREFIX(MultiDrawArraysEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4800(%rax), %r11
+       movq    4824(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(MultiDrawArraysEXT), .-GL_PREFIX(MultiDrawArraysEXT)
@@ -22599,7 +22726,7 @@ GL_PREFIX(MultiDrawArraysEXT):
 GL_PREFIX(MultiDrawElementsEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4808(%rax), %r11
+       movq    4832(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -22613,13 +22740,13 @@ GL_PREFIX(MultiDrawElementsEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4808(%rax), %r11
+       movq    4832(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4808(%rax), %r11
+       movq    4832(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -22633,7 +22760,7 @@ GL_PREFIX(MultiDrawElementsEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4808(%rax), %r11
+       movq    4832(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(MultiDrawElementsEXT), .-GL_PREFIX(MultiDrawElementsEXT)
@@ -22644,7 +22771,7 @@ GL_PREFIX(MultiDrawElementsEXT):
 GL_PREFIX(FogCoordPointerEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4816(%rax), %r11
+       movq    4840(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -22654,13 +22781,13 @@ GL_PREFIX(FogCoordPointerEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4816(%rax), %r11
+       movq    4840(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4816(%rax), %r11
+       movq    4840(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -22670,7 +22797,7 @@ GL_PREFIX(FogCoordPointerEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4816(%rax), %r11
+       movq    4840(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(FogCoordPointerEXT), .-GL_PREFIX(FogCoordPointerEXT)
@@ -22681,7 +22808,7 @@ GL_PREFIX(FogCoordPointerEXT):
 GL_PREFIX(FogCoorddEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4824(%rax), %r11
+       movq    4848(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $8, %rsp
@@ -22689,13 +22816,13 @@ GL_PREFIX(FogCoorddEXT):
        call    _x86_64_get_dispatch@PLT
        movq    (%rsp), %xmm0
        addq    $8, %rsp
-       movq    4824(%rax), %r11
+       movq    4848(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4824(%rax), %r11
+       movq    4848(%rax), %r11
        jmp     *%r11
 1:
        subq    $8, %rsp
@@ -22703,7 +22830,7 @@ GL_PREFIX(FogCoorddEXT):
        call    _glapi_get_dispatch
        movq    (%rsp), %xmm0
        addq    $8, %rsp
-       movq    4824(%rax), %r11
+       movq    4848(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(FogCoorddEXT), .-GL_PREFIX(FogCoorddEXT)
@@ -22714,25 +22841,25 @@ GL_PREFIX(FogCoorddEXT):
 GL_PREFIX(FogCoorddvEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4832(%rax), %r11
+       movq    4856(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    4832(%rax), %r11
+       movq    4856(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4832(%rax), %r11
+       movq    4856(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    4832(%rax), %r11
+       movq    4856(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(FogCoorddvEXT), .-GL_PREFIX(FogCoorddvEXT)
@@ -22743,7 +22870,7 @@ GL_PREFIX(FogCoorddvEXT):
 GL_PREFIX(FogCoordfEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4840(%rax), %r11
+       movq    4864(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $8, %rsp
@@ -22751,13 +22878,13 @@ GL_PREFIX(FogCoordfEXT):
        call    _x86_64_get_dispatch@PLT
        movq    (%rsp), %xmm0
        addq    $8, %rsp
-       movq    4840(%rax), %r11
+       movq    4864(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4840(%rax), %r11
+       movq    4864(%rax), %r11
        jmp     *%r11
 1:
        subq    $8, %rsp
@@ -22765,7 +22892,7 @@ GL_PREFIX(FogCoordfEXT):
        call    _glapi_get_dispatch
        movq    (%rsp), %xmm0
        addq    $8, %rsp
-       movq    4840(%rax), %r11
+       movq    4864(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(FogCoordfEXT), .-GL_PREFIX(FogCoordfEXT)
@@ -22776,58 +22903,58 @@ GL_PREFIX(FogCoordfEXT):
 GL_PREFIX(FogCoordfvEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4848(%rax), %r11
+       movq    4872(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    4848(%rax), %r11
+       movq    4872(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4848(%rax), %r11
+       movq    4872(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    4848(%rax), %r11
+       movq    4872(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(FogCoordfvEXT), .-GL_PREFIX(FogCoordfvEXT)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_607)
-       .type   GL_PREFIX(_dispatch_stub_607), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_607))
-GL_PREFIX(_dispatch_stub_607):
+       .globl  GL_PREFIX(_dispatch_stub_610)
+       .type   GL_PREFIX(_dispatch_stub_610), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_610))
+GL_PREFIX(_dispatch_stub_610):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4856(%rax), %r11
+       movq    4880(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    4856(%rax), %r11
+       movq    4880(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4856(%rax), %r11
+       movq    4880(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    4856(%rax), %r11
+       movq    4880(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_607), .-GL_PREFIX(_dispatch_stub_607)
+       .size   GL_PREFIX(_dispatch_stub_610), .-GL_PREFIX(_dispatch_stub_610)
 
        .p2align        4,,15
        .globl  GL_PREFIX(BlendFuncSeparateEXT)
@@ -22835,7 +22962,7 @@ GL_PREFIX(_dispatch_stub_607):
 GL_PREFIX(BlendFuncSeparateEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4864(%rax), %r11
+       movq    4888(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -22849,13 +22976,13 @@ GL_PREFIX(BlendFuncSeparateEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4864(%rax), %r11
+       movq    4888(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4864(%rax), %r11
+       movq    4888(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -22869,7 +22996,7 @@ GL_PREFIX(BlendFuncSeparateEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4864(%rax), %r11
+       movq    4888(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(BlendFuncSeparateEXT), .-GL_PREFIX(BlendFuncSeparateEXT)
@@ -22880,25 +23007,25 @@ GL_PREFIX(BlendFuncSeparateEXT):
 GL_PREFIX(FlushVertexArrayRangeNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4872(%rax), %r11
+       movq    4896(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rbp
        call    _x86_64_get_dispatch@PLT
        popq    %rbp
-       movq    4872(%rax), %r11
+       movq    4896(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4872(%rax), %r11
+       movq    4896(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rbp
        call    _glapi_get_dispatch
        popq    %rbp
-       movq    4872(%rax), %r11
+       movq    4896(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(FlushVertexArrayRangeNV), .-GL_PREFIX(FlushVertexArrayRangeNV)
@@ -22909,7 +23036,7 @@ GL_PREFIX(FlushVertexArrayRangeNV):
 GL_PREFIX(VertexArrayRangeNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4880(%rax), %r11
+       movq    4904(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -22919,13 +23046,13 @@ GL_PREFIX(VertexArrayRangeNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    4880(%rax), %r11
+       movq    4904(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4880(%rax), %r11
+       movq    4904(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -22935,7 +23062,7 @@ GL_PREFIX(VertexArrayRangeNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    4880(%rax), %r11
+       movq    4904(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexArrayRangeNV), .-GL_PREFIX(VertexArrayRangeNV)
@@ -22946,7 +23073,7 @@ GL_PREFIX(VertexArrayRangeNV):
 GL_PREFIX(CombinerInputNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4888(%rax), %r11
+       movq    4912(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -22964,13 +23091,13 @@ GL_PREFIX(CombinerInputNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4888(%rax), %r11
+       movq    4912(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4888(%rax), %r11
+       movq    4912(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -22988,7 +23115,7 @@ GL_PREFIX(CombinerInputNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4888(%rax), %r11
+       movq    4912(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(CombinerInputNV), .-GL_PREFIX(CombinerInputNV)
@@ -22999,7 +23126,7 @@ GL_PREFIX(CombinerInputNV):
 GL_PREFIX(CombinerOutputNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4896(%rax), %r11
+       movq    4920(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -23017,13 +23144,13 @@ GL_PREFIX(CombinerOutputNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4896(%rax), %r11
+       movq    4920(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4896(%rax), %r11
+       movq    4920(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -23041,7 +23168,7 @@ GL_PREFIX(CombinerOutputNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4896(%rax), %r11
+       movq    4920(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(CombinerOutputNV), .-GL_PREFIX(CombinerOutputNV)
@@ -23052,7 +23179,7 @@ GL_PREFIX(CombinerOutputNV):
 GL_PREFIX(CombinerParameterfNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4904(%rax), %r11
+       movq    4928(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $24, %rsp
@@ -23062,13 +23189,13 @@ GL_PREFIX(CombinerParameterfNV):
        movq    8(%rsp), %xmm0
        movq    (%rsp), %rdi
        addq    $24, %rsp
-       movq    4904(%rax), %r11
+       movq    4928(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4904(%rax), %r11
+       movq    4928(%rax), %r11
        jmp     *%r11
 1:
        subq    $24, %rsp
@@ -23078,7 +23205,7 @@ GL_PREFIX(CombinerParameterfNV):
        movq    8(%rsp), %xmm0
        movq    (%rsp), %rdi
        addq    $24, %rsp
-       movq    4904(%rax), %r11
+       movq    4928(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(CombinerParameterfNV), .-GL_PREFIX(CombinerParameterfNV)
@@ -23089,7 +23216,7 @@ GL_PREFIX(CombinerParameterfNV):
 GL_PREFIX(CombinerParameterfvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4912(%rax), %r11
+       movq    4936(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -23099,13 +23226,13 @@ GL_PREFIX(CombinerParameterfvNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    4912(%rax), %r11
+       movq    4936(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4912(%rax), %r11
+       movq    4936(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -23115,7 +23242,7 @@ GL_PREFIX(CombinerParameterfvNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    4912(%rax), %r11
+       movq    4936(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(CombinerParameterfvNV), .-GL_PREFIX(CombinerParameterfvNV)
@@ -23126,7 +23253,7 @@ GL_PREFIX(CombinerParameterfvNV):
 GL_PREFIX(CombinerParameteriNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4920(%rax), %r11
+       movq    4944(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -23136,13 +23263,13 @@ GL_PREFIX(CombinerParameteriNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    4920(%rax), %r11
+       movq    4944(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4920(%rax), %r11
+       movq    4944(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -23152,7 +23279,7 @@ GL_PREFIX(CombinerParameteriNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    4920(%rax), %r11
+       movq    4944(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(CombinerParameteriNV), .-GL_PREFIX(CombinerParameteriNV)
@@ -23163,7 +23290,7 @@ GL_PREFIX(CombinerParameteriNV):
 GL_PREFIX(CombinerParameterivNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4928(%rax), %r11
+       movq    4952(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -23173,13 +23300,13 @@ GL_PREFIX(CombinerParameterivNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    4928(%rax), %r11
+       movq    4952(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4928(%rax), %r11
+       movq    4952(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -23189,7 +23316,7 @@ GL_PREFIX(CombinerParameterivNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    4928(%rax), %r11
+       movq    4952(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(CombinerParameterivNV), .-GL_PREFIX(CombinerParameterivNV)
@@ -23200,7 +23327,7 @@ GL_PREFIX(CombinerParameterivNV):
 GL_PREFIX(FinalCombinerInputNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4936(%rax), %r11
+       movq    4960(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -23214,13 +23341,13 @@ GL_PREFIX(FinalCombinerInputNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4936(%rax), %r11
+       movq    4960(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4936(%rax), %r11
+       movq    4960(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -23234,7 +23361,7 @@ GL_PREFIX(FinalCombinerInputNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4936(%rax), %r11
+       movq    4960(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(FinalCombinerInputNV), .-GL_PREFIX(FinalCombinerInputNV)
@@ -23245,7 +23372,7 @@ GL_PREFIX(FinalCombinerInputNV):
 GL_PREFIX(GetCombinerInputParameterfvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4944(%rax), %r11
+       movq    4968(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -23259,13 +23386,13 @@ GL_PREFIX(GetCombinerInputParameterfvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4944(%rax), %r11
+       movq    4968(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4944(%rax), %r11
+       movq    4968(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -23279,7 +23406,7 @@ GL_PREFIX(GetCombinerInputParameterfvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4944(%rax), %r11
+       movq    4968(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetCombinerInputParameterfvNV), .-GL_PREFIX(GetCombinerInputParameterfvNV)
@@ -23290,7 +23417,7 @@ GL_PREFIX(GetCombinerInputParameterfvNV):
 GL_PREFIX(GetCombinerInputParameterivNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4952(%rax), %r11
+       movq    4976(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -23304,13 +23431,13 @@ GL_PREFIX(GetCombinerInputParameterivNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4952(%rax), %r11
+       movq    4976(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4952(%rax), %r11
+       movq    4976(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -23324,7 +23451,7 @@ GL_PREFIX(GetCombinerInputParameterivNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4952(%rax), %r11
+       movq    4976(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetCombinerInputParameterivNV), .-GL_PREFIX(GetCombinerInputParameterivNV)
@@ -23335,7 +23462,7 @@ GL_PREFIX(GetCombinerInputParameterivNV):
 GL_PREFIX(GetCombinerOutputParameterfvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4960(%rax), %r11
+       movq    4984(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -23349,13 +23476,13 @@ GL_PREFIX(GetCombinerOutputParameterfvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4960(%rax), %r11
+       movq    4984(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4960(%rax), %r11
+       movq    4984(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -23369,7 +23496,7 @@ GL_PREFIX(GetCombinerOutputParameterfvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4960(%rax), %r11
+       movq    4984(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetCombinerOutputParameterfvNV), .-GL_PREFIX(GetCombinerOutputParameterfvNV)
@@ -23380,7 +23507,7 @@ GL_PREFIX(GetCombinerOutputParameterfvNV):
 GL_PREFIX(GetCombinerOutputParameterivNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4968(%rax), %r11
+       movq    4992(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -23394,13 +23521,13 @@ GL_PREFIX(GetCombinerOutputParameterivNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4968(%rax), %r11
+       movq    4992(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4968(%rax), %r11
+       movq    4992(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -23414,7 +23541,7 @@ GL_PREFIX(GetCombinerOutputParameterivNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4968(%rax), %r11
+       movq    4992(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetCombinerOutputParameterivNV), .-GL_PREFIX(GetCombinerOutputParameterivNV)
@@ -23425,7 +23552,7 @@ GL_PREFIX(GetCombinerOutputParameterivNV):
 GL_PREFIX(GetFinalCombinerInputParameterfvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4976(%rax), %r11
+       movq    5000(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -23435,13 +23562,13 @@ GL_PREFIX(GetFinalCombinerInputParameterfvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4976(%rax), %r11
+       movq    5000(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4976(%rax), %r11
+       movq    5000(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -23451,7 +23578,7 @@ GL_PREFIX(GetFinalCombinerInputParameterfvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4976(%rax), %r11
+       movq    5000(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetFinalCombinerInputParameterfvNV), .-GL_PREFIX(GetFinalCombinerInputParameterfvNV)
@@ -23462,7 +23589,7 @@ GL_PREFIX(GetFinalCombinerInputParameterfvNV):
 GL_PREFIX(GetFinalCombinerInputParameterivNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4984(%rax), %r11
+       movq    5008(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -23472,13 +23599,13 @@ GL_PREFIX(GetFinalCombinerInputParameterivNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4984(%rax), %r11
+       movq    5008(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4984(%rax), %r11
+       movq    5008(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -23488,7 +23615,7 @@ GL_PREFIX(GetFinalCombinerInputParameterivNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    4984(%rax), %r11
+       movq    5008(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetFinalCombinerInputParameterivNV), .-GL_PREFIX(GetFinalCombinerInputParameterivNV)
@@ -23499,25 +23626,25 @@ GL_PREFIX(GetFinalCombinerInputParameterivNV):
 GL_PREFIX(ResizeBuffersMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    4992(%rax), %r11
+       movq    5016(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rbp
        call    _x86_64_get_dispatch@PLT
        popq    %rbp
-       movq    4992(%rax), %r11
+       movq    5016(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    4992(%rax), %r11
+       movq    5016(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rbp
        call    _glapi_get_dispatch
        popq    %rbp
-       movq    4992(%rax), %r11
+       movq    5016(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(ResizeBuffersMESA), .-GL_PREFIX(ResizeBuffersMESA)
@@ -23528,7 +23655,7 @@ GL_PREFIX(ResizeBuffersMESA):
 GL_PREFIX(WindowPos2dMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5000(%rax), %r11
+       movq    5024(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $24, %rsp
@@ -23538,13 +23665,13 @@ GL_PREFIX(WindowPos2dMESA):
        movq    8(%rsp), %xmm1
        movq    (%rsp), %xmm0
        addq    $24, %rsp
-       movq    5000(%rax), %r11
+       movq    5024(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5000(%rax), %r11
+       movq    5024(%rax), %r11
        jmp     *%r11
 1:
        subq    $24, %rsp
@@ -23554,7 +23681,7 @@ GL_PREFIX(WindowPos2dMESA):
        movq    8(%rsp), %xmm1
        movq    (%rsp), %xmm0
        addq    $24, %rsp
-       movq    5000(%rax), %r11
+       movq    5024(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos2dMESA), .-GL_PREFIX(WindowPos2dMESA)
@@ -23565,25 +23692,25 @@ GL_PREFIX(WindowPos2dMESA):
 GL_PREFIX(WindowPos2dvMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5008(%rax), %r11
+       movq    5032(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5008(%rax), %r11
+       movq    5032(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5008(%rax), %r11
+       movq    5032(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5008(%rax), %r11
+       movq    5032(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos2dvMESA), .-GL_PREFIX(WindowPos2dvMESA)
@@ -23594,7 +23721,7 @@ GL_PREFIX(WindowPos2dvMESA):
 GL_PREFIX(WindowPos2fMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5016(%rax), %r11
+       movq    5040(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $24, %rsp
@@ -23604,13 +23731,13 @@ GL_PREFIX(WindowPos2fMESA):
        movq    8(%rsp), %xmm1
        movq    (%rsp), %xmm0
        addq    $24, %rsp
-       movq    5016(%rax), %r11
+       movq    5040(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5016(%rax), %r11
+       movq    5040(%rax), %r11
        jmp     *%r11
 1:
        subq    $24, %rsp
@@ -23620,7 +23747,7 @@ GL_PREFIX(WindowPos2fMESA):
        movq    8(%rsp), %xmm1
        movq    (%rsp), %xmm0
        addq    $24, %rsp
-       movq    5016(%rax), %r11
+       movq    5040(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos2fMESA), .-GL_PREFIX(WindowPos2fMESA)
@@ -23631,25 +23758,25 @@ GL_PREFIX(WindowPos2fMESA):
 GL_PREFIX(WindowPos2fvMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5024(%rax), %r11
+       movq    5048(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5024(%rax), %r11
+       movq    5048(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5024(%rax), %r11
+       movq    5048(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5024(%rax), %r11
+       movq    5048(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos2fvMESA), .-GL_PREFIX(WindowPos2fvMESA)
@@ -23660,7 +23787,7 @@ GL_PREFIX(WindowPos2fvMESA):
 GL_PREFIX(WindowPos2iMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5032(%rax), %r11
+       movq    5056(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -23670,13 +23797,13 @@ GL_PREFIX(WindowPos2iMESA):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5032(%rax), %r11
+       movq    5056(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5032(%rax), %r11
+       movq    5056(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -23686,7 +23813,7 @@ GL_PREFIX(WindowPos2iMESA):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5032(%rax), %r11
+       movq    5056(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos2iMESA), .-GL_PREFIX(WindowPos2iMESA)
@@ -23697,25 +23824,25 @@ GL_PREFIX(WindowPos2iMESA):
 GL_PREFIX(WindowPos2ivMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5040(%rax), %r11
+       movq    5064(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5040(%rax), %r11
+       movq    5064(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5040(%rax), %r11
+       movq    5064(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5040(%rax), %r11
+       movq    5064(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos2ivMESA), .-GL_PREFIX(WindowPos2ivMESA)
@@ -23726,7 +23853,7 @@ GL_PREFIX(WindowPos2ivMESA):
 GL_PREFIX(WindowPos2sMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5048(%rax), %r11
+       movq    5072(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -23736,13 +23863,13 @@ GL_PREFIX(WindowPos2sMESA):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5048(%rax), %r11
+       movq    5072(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5048(%rax), %r11
+       movq    5072(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -23752,7 +23879,7 @@ GL_PREFIX(WindowPos2sMESA):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5048(%rax), %r11
+       movq    5072(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos2sMESA), .-GL_PREFIX(WindowPos2sMESA)
@@ -23763,25 +23890,25 @@ GL_PREFIX(WindowPos2sMESA):
 GL_PREFIX(WindowPos2svMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5056(%rax), %r11
+       movq    5080(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5056(%rax), %r11
+       movq    5080(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5056(%rax), %r11
+       movq    5080(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5056(%rax), %r11
+       movq    5080(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos2svMESA), .-GL_PREFIX(WindowPos2svMESA)
@@ -23792,7 +23919,7 @@ GL_PREFIX(WindowPos2svMESA):
 GL_PREFIX(WindowPos3dMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5064(%rax), %r11
+       movq    5088(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $24, %rsp
@@ -23804,13 +23931,13 @@ GL_PREFIX(WindowPos3dMESA):
        movq    8(%rsp), %xmm1
        movq    (%rsp), %xmm0
        addq    $24, %rsp
-       movq    5064(%rax), %r11
+       movq    5088(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5064(%rax), %r11
+       movq    5088(%rax), %r11
        jmp     *%r11
 1:
        subq    $24, %rsp
@@ -23822,7 +23949,7 @@ GL_PREFIX(WindowPos3dMESA):
        movq    8(%rsp), %xmm1
        movq    (%rsp), %xmm0
        addq    $24, %rsp
-       movq    5064(%rax), %r11
+       movq    5088(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos3dMESA), .-GL_PREFIX(WindowPos3dMESA)
@@ -23833,25 +23960,25 @@ GL_PREFIX(WindowPos3dMESA):
 GL_PREFIX(WindowPos3dvMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5072(%rax), %r11
+       movq    5096(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5072(%rax), %r11
+       movq    5096(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5072(%rax), %r11
+       movq    5096(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5072(%rax), %r11
+       movq    5096(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos3dvMESA), .-GL_PREFIX(WindowPos3dvMESA)
@@ -23862,7 +23989,7 @@ GL_PREFIX(WindowPos3dvMESA):
 GL_PREFIX(WindowPos3fMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5080(%rax), %r11
+       movq    5104(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $24, %rsp
@@ -23874,13 +24001,13 @@ GL_PREFIX(WindowPos3fMESA):
        movq    8(%rsp), %xmm1
        movq    (%rsp), %xmm0
        addq    $24, %rsp
-       movq    5080(%rax), %r11
+       movq    5104(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5080(%rax), %r11
+       movq    5104(%rax), %r11
        jmp     *%r11
 1:
        subq    $24, %rsp
@@ -23892,7 +24019,7 @@ GL_PREFIX(WindowPos3fMESA):
        movq    8(%rsp), %xmm1
        movq    (%rsp), %xmm0
        addq    $24, %rsp
-       movq    5080(%rax), %r11
+       movq    5104(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos3fMESA), .-GL_PREFIX(WindowPos3fMESA)
@@ -23903,25 +24030,25 @@ GL_PREFIX(WindowPos3fMESA):
 GL_PREFIX(WindowPos3fvMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5088(%rax), %r11
+       movq    5112(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5088(%rax), %r11
+       movq    5112(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5088(%rax), %r11
+       movq    5112(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5088(%rax), %r11
+       movq    5112(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos3fvMESA), .-GL_PREFIX(WindowPos3fvMESA)
@@ -23932,7 +24059,7 @@ GL_PREFIX(WindowPos3fvMESA):
 GL_PREFIX(WindowPos3iMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5096(%rax), %r11
+       movq    5120(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -23942,13 +24069,13 @@ GL_PREFIX(WindowPos3iMESA):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5096(%rax), %r11
+       movq    5120(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5096(%rax), %r11
+       movq    5120(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -23958,7 +24085,7 @@ GL_PREFIX(WindowPos3iMESA):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5096(%rax), %r11
+       movq    5120(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos3iMESA), .-GL_PREFIX(WindowPos3iMESA)
@@ -23969,25 +24096,25 @@ GL_PREFIX(WindowPos3iMESA):
 GL_PREFIX(WindowPos3ivMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5104(%rax), %r11
+       movq    5128(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5104(%rax), %r11
+       movq    5128(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5104(%rax), %r11
+       movq    5128(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5104(%rax), %r11
+       movq    5128(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos3ivMESA), .-GL_PREFIX(WindowPos3ivMESA)
@@ -23998,7 +24125,7 @@ GL_PREFIX(WindowPos3ivMESA):
 GL_PREFIX(WindowPos3sMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5112(%rax), %r11
+       movq    5136(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -24008,13 +24135,13 @@ GL_PREFIX(WindowPos3sMESA):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5112(%rax), %r11
+       movq    5136(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5112(%rax), %r11
+       movq    5136(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -24024,7 +24151,7 @@ GL_PREFIX(WindowPos3sMESA):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5112(%rax), %r11
+       movq    5136(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos3sMESA), .-GL_PREFIX(WindowPos3sMESA)
@@ -24035,25 +24162,25 @@ GL_PREFIX(WindowPos3sMESA):
 GL_PREFIX(WindowPos3svMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5120(%rax), %r11
+       movq    5144(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5120(%rax), %r11
+       movq    5144(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5120(%rax), %r11
+       movq    5144(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5120(%rax), %r11
+       movq    5144(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos3svMESA), .-GL_PREFIX(WindowPos3svMESA)
@@ -24064,7 +24191,7 @@ GL_PREFIX(WindowPos3svMESA):
 GL_PREFIX(WindowPos4dMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5128(%rax), %r11
+       movq    5152(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $40, %rsp
@@ -24078,13 +24205,13 @@ GL_PREFIX(WindowPos4dMESA):
        movq    8(%rsp), %xmm1
        movq    (%rsp), %xmm0
        addq    $40, %rsp
-       movq    5128(%rax), %r11
+       movq    5152(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5128(%rax), %r11
+       movq    5152(%rax), %r11
        jmp     *%r11
 1:
        subq    $40, %rsp
@@ -24098,7 +24225,7 @@ GL_PREFIX(WindowPos4dMESA):
        movq    8(%rsp), %xmm1
        movq    (%rsp), %xmm0
        addq    $40, %rsp
-       movq    5128(%rax), %r11
+       movq    5152(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos4dMESA), .-GL_PREFIX(WindowPos4dMESA)
@@ -24109,25 +24236,25 @@ GL_PREFIX(WindowPos4dMESA):
 GL_PREFIX(WindowPos4dvMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5136(%rax), %r11
+       movq    5160(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5136(%rax), %r11
+       movq    5160(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5136(%rax), %r11
+       movq    5160(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5136(%rax), %r11
+       movq    5160(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos4dvMESA), .-GL_PREFIX(WindowPos4dvMESA)
@@ -24138,7 +24265,7 @@ GL_PREFIX(WindowPos4dvMESA):
 GL_PREFIX(WindowPos4fMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5144(%rax), %r11
+       movq    5168(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $40, %rsp
@@ -24152,13 +24279,13 @@ GL_PREFIX(WindowPos4fMESA):
        movq    8(%rsp), %xmm1
        movq    (%rsp), %xmm0
        addq    $40, %rsp
-       movq    5144(%rax), %r11
+       movq    5168(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5144(%rax), %r11
+       movq    5168(%rax), %r11
        jmp     *%r11
 1:
        subq    $40, %rsp
@@ -24172,7 +24299,7 @@ GL_PREFIX(WindowPos4fMESA):
        movq    8(%rsp), %xmm1
        movq    (%rsp), %xmm0
        addq    $40, %rsp
-       movq    5144(%rax), %r11
+       movq    5168(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos4fMESA), .-GL_PREFIX(WindowPos4fMESA)
@@ -24183,25 +24310,25 @@ GL_PREFIX(WindowPos4fMESA):
 GL_PREFIX(WindowPos4fvMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5152(%rax), %r11
+       movq    5176(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5152(%rax), %r11
+       movq    5176(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5152(%rax), %r11
+       movq    5176(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5152(%rax), %r11
+       movq    5176(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos4fvMESA), .-GL_PREFIX(WindowPos4fvMESA)
@@ -24212,7 +24339,7 @@ GL_PREFIX(WindowPos4fvMESA):
 GL_PREFIX(WindowPos4iMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5160(%rax), %r11
+       movq    5184(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -24226,13 +24353,13 @@ GL_PREFIX(WindowPos4iMESA):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5160(%rax), %r11
+       movq    5184(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5160(%rax), %r11
+       movq    5184(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -24246,7 +24373,7 @@ GL_PREFIX(WindowPos4iMESA):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5160(%rax), %r11
+       movq    5184(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos4iMESA), .-GL_PREFIX(WindowPos4iMESA)
@@ -24257,25 +24384,25 @@ GL_PREFIX(WindowPos4iMESA):
 GL_PREFIX(WindowPos4ivMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5168(%rax), %r11
+       movq    5192(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5168(%rax), %r11
+       movq    5192(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5168(%rax), %r11
+       movq    5192(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5168(%rax), %r11
+       movq    5192(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos4ivMESA), .-GL_PREFIX(WindowPos4ivMESA)
@@ -24286,7 +24413,7 @@ GL_PREFIX(WindowPos4ivMESA):
 GL_PREFIX(WindowPos4sMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5176(%rax), %r11
+       movq    5200(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -24300,13 +24427,13 @@ GL_PREFIX(WindowPos4sMESA):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5176(%rax), %r11
+       movq    5200(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5176(%rax), %r11
+       movq    5200(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -24320,7 +24447,7 @@ GL_PREFIX(WindowPos4sMESA):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5176(%rax), %r11
+       movq    5200(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos4sMESA), .-GL_PREFIX(WindowPos4sMESA)
@@ -24331,37 +24458,37 @@ GL_PREFIX(WindowPos4sMESA):
 GL_PREFIX(WindowPos4svMESA):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5184(%rax), %r11
+       movq    5208(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5184(%rax), %r11
+       movq    5208(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5184(%rax), %r11
+       movq    5208(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5184(%rax), %r11
+       movq    5208(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(WindowPos4svMESA), .-GL_PREFIX(WindowPos4svMESA)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_649)
-       .type   GL_PREFIX(_dispatch_stub_649), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_649))
-GL_PREFIX(_dispatch_stub_649):
+       .globl  GL_PREFIX(_dispatch_stub_652)
+       .type   GL_PREFIX(_dispatch_stub_652), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_652))
+GL_PREFIX(_dispatch_stub_652):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5192(%rax), %r11
+       movq    5216(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -24375,13 +24502,13 @@ GL_PREFIX(_dispatch_stub_649):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5192(%rax), %r11
+       movq    5216(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5192(%rax), %r11
+       movq    5216(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -24395,19 +24522,19 @@ GL_PREFIX(_dispatch_stub_649):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5192(%rax), %r11
+       movq    5216(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_649), .-GL_PREFIX(_dispatch_stub_649)
+       .size   GL_PREFIX(_dispatch_stub_652), .-GL_PREFIX(_dispatch_stub_652)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_650)
-       .type   GL_PREFIX(_dispatch_stub_650), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_650))
-GL_PREFIX(_dispatch_stub_650):
+       .globl  GL_PREFIX(_dispatch_stub_653)
+       .type   GL_PREFIX(_dispatch_stub_653), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_653))
+GL_PREFIX(_dispatch_stub_653):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5200(%rax), %r11
+       movq    5224(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -24425,13 +24552,13 @@ GL_PREFIX(_dispatch_stub_650):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5200(%rax), %r11
+       movq    5224(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5200(%rax), %r11
+       movq    5224(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -24449,19 +24576,19 @@ GL_PREFIX(_dispatch_stub_650):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5200(%rax), %r11
+       movq    5224(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_650), .-GL_PREFIX(_dispatch_stub_650)
+       .size   GL_PREFIX(_dispatch_stub_653), .-GL_PREFIX(_dispatch_stub_653)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_651)
-       .type   GL_PREFIX(_dispatch_stub_651), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_651))
-GL_PREFIX(_dispatch_stub_651):
+       .globl  GL_PREFIX(_dispatch_stub_654)
+       .type   GL_PREFIX(_dispatch_stub_654), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_654))
+GL_PREFIX(_dispatch_stub_654):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5208(%rax), %r11
+       movq    5232(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -24471,13 +24598,13 @@ GL_PREFIX(_dispatch_stub_651):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5208(%rax), %r11
+       movq    5232(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5208(%rax), %r11
+       movq    5232(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -24487,49 +24614,49 @@ GL_PREFIX(_dispatch_stub_651):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5208(%rax), %r11
+       movq    5232(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_651), .-GL_PREFIX(_dispatch_stub_651)
+       .size   GL_PREFIX(_dispatch_stub_654), .-GL_PREFIX(_dispatch_stub_654)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_652)
-       .type   GL_PREFIX(_dispatch_stub_652), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_652))
-GL_PREFIX(_dispatch_stub_652):
+       .globl  GL_PREFIX(_dispatch_stub_655)
+       .type   GL_PREFIX(_dispatch_stub_655), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_655))
+GL_PREFIX(_dispatch_stub_655):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5216(%rax), %r11
+       movq    5240(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5216(%rax), %r11
+       movq    5240(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5216(%rax), %r11
+       movq    5240(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5216(%rax), %r11
+       movq    5240(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_652), .-GL_PREFIX(_dispatch_stub_652)
+       .size   GL_PREFIX(_dispatch_stub_655), .-GL_PREFIX(_dispatch_stub_655)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_653)
-       .type   GL_PREFIX(_dispatch_stub_653), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_653))
-GL_PREFIX(_dispatch_stub_653):
+       .globl  GL_PREFIX(_dispatch_stub_656)
+       .type   GL_PREFIX(_dispatch_stub_656), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_656))
+GL_PREFIX(_dispatch_stub_656):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5224(%rax), %r11
+       movq    5248(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -24539,13 +24666,13 @@ GL_PREFIX(_dispatch_stub_653):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5224(%rax), %r11
+       movq    5248(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5224(%rax), %r11
+       movq    5248(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -24555,19 +24682,19 @@ GL_PREFIX(_dispatch_stub_653):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5224(%rax), %r11
+       movq    5248(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_653), .-GL_PREFIX(_dispatch_stub_653)
+       .size   GL_PREFIX(_dispatch_stub_656), .-GL_PREFIX(_dispatch_stub_656)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_654)
-       .type   GL_PREFIX(_dispatch_stub_654), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_654))
-GL_PREFIX(_dispatch_stub_654):
+       .globl  GL_PREFIX(_dispatch_stub_657)
+       .type   GL_PREFIX(_dispatch_stub_657), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_657))
+GL_PREFIX(_dispatch_stub_657):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5232(%rax), %r11
+       movq    5256(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -24577,13 +24704,13 @@ GL_PREFIX(_dispatch_stub_654):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5232(%rax), %r11
+       movq    5256(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5232(%rax), %r11
+       movq    5256(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -24593,49 +24720,49 @@ GL_PREFIX(_dispatch_stub_654):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5232(%rax), %r11
+       movq    5256(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_654), .-GL_PREFIX(_dispatch_stub_654)
+       .size   GL_PREFIX(_dispatch_stub_657), .-GL_PREFIX(_dispatch_stub_657)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_655)
-       .type   GL_PREFIX(_dispatch_stub_655), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_655))
-GL_PREFIX(_dispatch_stub_655):
+       .globl  GL_PREFIX(_dispatch_stub_658)
+       .type   GL_PREFIX(_dispatch_stub_658), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_658))
+GL_PREFIX(_dispatch_stub_658):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5240(%rax), %r11
+       movq    5264(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5240(%rax), %r11
+       movq    5264(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5240(%rax), %r11
+       movq    5264(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5240(%rax), %r11
+       movq    5264(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_655), .-GL_PREFIX(_dispatch_stub_655)
+       .size   GL_PREFIX(_dispatch_stub_658), .-GL_PREFIX(_dispatch_stub_658)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_656)
-       .type   GL_PREFIX(_dispatch_stub_656), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_656))
-GL_PREFIX(_dispatch_stub_656):
+       .globl  GL_PREFIX(_dispatch_stub_659)
+       .type   GL_PREFIX(_dispatch_stub_659), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_659))
+GL_PREFIX(_dispatch_stub_659):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5248(%rax), %r11
+       movq    5272(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -24645,13 +24772,13 @@ GL_PREFIX(_dispatch_stub_656):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5248(%rax), %r11
+       movq    5272(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5248(%rax), %r11
+       movq    5272(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -24661,40 +24788,40 @@ GL_PREFIX(_dispatch_stub_656):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5248(%rax), %r11
+       movq    5272(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_656), .-GL_PREFIX(_dispatch_stub_656)
+       .size   GL_PREFIX(_dispatch_stub_659), .-GL_PREFIX(_dispatch_stub_659)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_657)
-       .type   GL_PREFIX(_dispatch_stub_657), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_657))
-GL_PREFIX(_dispatch_stub_657):
+       .globl  GL_PREFIX(_dispatch_stub_660)
+       .type   GL_PREFIX(_dispatch_stub_660), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_660))
+GL_PREFIX(_dispatch_stub_660):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5256(%rax), %r11
+       movq    5280(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5256(%rax), %r11
+       movq    5280(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5256(%rax), %r11
+       movq    5280(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5256(%rax), %r11
+       movq    5280(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_657), .-GL_PREFIX(_dispatch_stub_657)
+       .size   GL_PREFIX(_dispatch_stub_660), .-GL_PREFIX(_dispatch_stub_660)
 
        .p2align        4,,15
        .globl  GL_PREFIX(AreProgramsResidentNV)
@@ -24702,7 +24829,7 @@ GL_PREFIX(_dispatch_stub_657):
 GL_PREFIX(AreProgramsResidentNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5264(%rax), %r11
+       movq    5288(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -24712,13 +24839,13 @@ GL_PREFIX(AreProgramsResidentNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5264(%rax), %r11
+       movq    5288(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5264(%rax), %r11
+       movq    5288(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -24728,7 +24855,7 @@ GL_PREFIX(AreProgramsResidentNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5264(%rax), %r11
+       movq    5288(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(AreProgramsResidentNV), .-GL_PREFIX(AreProgramsResidentNV)
@@ -24739,7 +24866,7 @@ GL_PREFIX(AreProgramsResidentNV):
 GL_PREFIX(BindProgramNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5272(%rax), %r11
+       movq    5296(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -24749,13 +24876,13 @@ GL_PREFIX(BindProgramNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5272(%rax), %r11
+       movq    5296(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5272(%rax), %r11
+       movq    5296(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -24765,7 +24892,7 @@ GL_PREFIX(BindProgramNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5272(%rax), %r11
+       movq    5296(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(BindProgramNV), .-GL_PREFIX(BindProgramNV)
@@ -24776,7 +24903,7 @@ GL_PREFIX(BindProgramNV):
 GL_PREFIX(DeleteProgramsNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5280(%rax), %r11
+       movq    5304(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -24786,13 +24913,13 @@ GL_PREFIX(DeleteProgramsNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5280(%rax), %r11
+       movq    5304(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5280(%rax), %r11
+       movq    5304(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -24802,7 +24929,7 @@ GL_PREFIX(DeleteProgramsNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5280(%rax), %r11
+       movq    5304(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(DeleteProgramsNV), .-GL_PREFIX(DeleteProgramsNV)
@@ -24813,7 +24940,7 @@ GL_PREFIX(DeleteProgramsNV):
 GL_PREFIX(ExecuteProgramNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5288(%rax), %r11
+       movq    5312(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -24823,13 +24950,13 @@ GL_PREFIX(ExecuteProgramNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5288(%rax), %r11
+       movq    5312(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5288(%rax), %r11
+       movq    5312(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -24839,7 +24966,7 @@ GL_PREFIX(ExecuteProgramNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5288(%rax), %r11
+       movq    5312(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(ExecuteProgramNV), .-GL_PREFIX(ExecuteProgramNV)
@@ -24850,7 +24977,7 @@ GL_PREFIX(ExecuteProgramNV):
 GL_PREFIX(GenProgramsNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5296(%rax), %r11
+       movq    5320(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -24860,13 +24987,13 @@ GL_PREFIX(GenProgramsNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5296(%rax), %r11
+       movq    5320(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5296(%rax), %r11
+       movq    5320(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -24876,7 +25003,7 @@ GL_PREFIX(GenProgramsNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5296(%rax), %r11
+       movq    5320(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GenProgramsNV), .-GL_PREFIX(GenProgramsNV)
@@ -24887,7 +25014,7 @@ GL_PREFIX(GenProgramsNV):
 GL_PREFIX(GetProgramParameterdvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5304(%rax), %r11
+       movq    5328(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -24901,13 +25028,13 @@ GL_PREFIX(GetProgramParameterdvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5304(%rax), %r11
+       movq    5328(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5304(%rax), %r11
+       movq    5328(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -24921,7 +25048,7 @@ GL_PREFIX(GetProgramParameterdvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5304(%rax), %r11
+       movq    5328(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetProgramParameterdvNV), .-GL_PREFIX(GetProgramParameterdvNV)
@@ -24932,7 +25059,7 @@ GL_PREFIX(GetProgramParameterdvNV):
 GL_PREFIX(GetProgramParameterfvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5312(%rax), %r11
+       movq    5336(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -24946,13 +25073,13 @@ GL_PREFIX(GetProgramParameterfvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5312(%rax), %r11
+       movq    5336(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5312(%rax), %r11
+       movq    5336(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -24966,7 +25093,7 @@ GL_PREFIX(GetProgramParameterfvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5312(%rax), %r11
+       movq    5336(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetProgramParameterfvNV), .-GL_PREFIX(GetProgramParameterfvNV)
@@ -24977,7 +25104,7 @@ GL_PREFIX(GetProgramParameterfvNV):
 GL_PREFIX(GetProgramStringNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5320(%rax), %r11
+       movq    5344(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -24987,13 +25114,13 @@ GL_PREFIX(GetProgramStringNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5320(%rax), %r11
+       movq    5344(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5320(%rax), %r11
+       movq    5344(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -25003,7 +25130,7 @@ GL_PREFIX(GetProgramStringNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5320(%rax), %r11
+       movq    5344(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetProgramStringNV), .-GL_PREFIX(GetProgramStringNV)
@@ -25014,7 +25141,7 @@ GL_PREFIX(GetProgramStringNV):
 GL_PREFIX(GetProgramivNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5328(%rax), %r11
+       movq    5352(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -25024,13 +25151,13 @@ GL_PREFIX(GetProgramivNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5328(%rax), %r11
+       movq    5352(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5328(%rax), %r11
+       movq    5352(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -25040,7 +25167,7 @@ GL_PREFIX(GetProgramivNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5328(%rax), %r11
+       movq    5352(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetProgramivNV), .-GL_PREFIX(GetProgramivNV)
@@ -25051,7 +25178,7 @@ GL_PREFIX(GetProgramivNV):
 GL_PREFIX(GetTrackMatrixivNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5336(%rax), %r11
+       movq    5360(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -25065,13 +25192,13 @@ GL_PREFIX(GetTrackMatrixivNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5336(%rax), %r11
+       movq    5360(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5336(%rax), %r11
+       movq    5360(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -25085,7 +25212,7 @@ GL_PREFIX(GetTrackMatrixivNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5336(%rax), %r11
+       movq    5360(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetTrackMatrixivNV), .-GL_PREFIX(GetTrackMatrixivNV)
@@ -25096,7 +25223,7 @@ GL_PREFIX(GetTrackMatrixivNV):
 GL_PREFIX(GetVertexAttribPointervNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5344(%rax), %r11
+       movq    5368(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -25106,13 +25233,13 @@ GL_PREFIX(GetVertexAttribPointervNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5344(%rax), %r11
+       movq    5368(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5344(%rax), %r11
+       movq    5368(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -25122,7 +25249,7 @@ GL_PREFIX(GetVertexAttribPointervNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5344(%rax), %r11
+       movq    5368(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetVertexAttribPointervNV), .-GL_PREFIX(GetVertexAttribPointervNV)
@@ -25133,7 +25260,7 @@ GL_PREFIX(GetVertexAttribPointervNV):
 GL_PREFIX(GetVertexAttribdvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5352(%rax), %r11
+       movq    5376(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -25143,13 +25270,13 @@ GL_PREFIX(GetVertexAttribdvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5352(%rax), %r11
+       movq    5376(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5352(%rax), %r11
+       movq    5376(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -25159,7 +25286,7 @@ GL_PREFIX(GetVertexAttribdvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5352(%rax), %r11
+       movq    5376(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetVertexAttribdvNV), .-GL_PREFIX(GetVertexAttribdvNV)
@@ -25170,7 +25297,7 @@ GL_PREFIX(GetVertexAttribdvNV):
 GL_PREFIX(GetVertexAttribfvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5360(%rax), %r11
+       movq    5384(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -25180,13 +25307,13 @@ GL_PREFIX(GetVertexAttribfvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5360(%rax), %r11
+       movq    5384(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5360(%rax), %r11
+       movq    5384(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -25196,7 +25323,7 @@ GL_PREFIX(GetVertexAttribfvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5360(%rax), %r11
+       movq    5384(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetVertexAttribfvNV), .-GL_PREFIX(GetVertexAttribfvNV)
@@ -25207,7 +25334,7 @@ GL_PREFIX(GetVertexAttribfvNV):
 GL_PREFIX(GetVertexAttribivNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5368(%rax), %r11
+       movq    5392(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -25217,13 +25344,13 @@ GL_PREFIX(GetVertexAttribivNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5368(%rax), %r11
+       movq    5392(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5368(%rax), %r11
+       movq    5392(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -25233,7 +25360,7 @@ GL_PREFIX(GetVertexAttribivNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5368(%rax), %r11
+       movq    5392(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetVertexAttribivNV), .-GL_PREFIX(GetVertexAttribivNV)
@@ -25244,25 +25371,25 @@ GL_PREFIX(GetVertexAttribivNV):
 GL_PREFIX(IsProgramNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5376(%rax), %r11
+       movq    5400(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5376(%rax), %r11
+       movq    5400(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5376(%rax), %r11
+       movq    5400(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5376(%rax), %r11
+       movq    5400(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(IsProgramNV), .-GL_PREFIX(IsProgramNV)
@@ -25273,7 +25400,7 @@ GL_PREFIX(IsProgramNV):
 GL_PREFIX(LoadProgramNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5384(%rax), %r11
+       movq    5408(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -25287,13 +25414,13 @@ GL_PREFIX(LoadProgramNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5384(%rax), %r11
+       movq    5408(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5384(%rax), %r11
+       movq    5408(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -25307,7 +25434,7 @@ GL_PREFIX(LoadProgramNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5384(%rax), %r11
+       movq    5408(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(LoadProgramNV), .-GL_PREFIX(LoadProgramNV)
@@ -25318,7 +25445,7 @@ GL_PREFIX(LoadProgramNV):
 GL_PREFIX(ProgramParameters4dvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5392(%rax), %r11
+       movq    5416(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -25332,13 +25459,13 @@ GL_PREFIX(ProgramParameters4dvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5392(%rax), %r11
+       movq    5416(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5392(%rax), %r11
+       movq    5416(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -25352,7 +25479,7 @@ GL_PREFIX(ProgramParameters4dvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5392(%rax), %r11
+       movq    5416(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(ProgramParameters4dvNV), .-GL_PREFIX(ProgramParameters4dvNV)
@@ -25363,7 +25490,7 @@ GL_PREFIX(ProgramParameters4dvNV):
 GL_PREFIX(ProgramParameters4fvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5400(%rax), %r11
+       movq    5424(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -25377,13 +25504,13 @@ GL_PREFIX(ProgramParameters4fvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5400(%rax), %r11
+       movq    5424(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5400(%rax), %r11
+       movq    5424(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -25397,7 +25524,7 @@ GL_PREFIX(ProgramParameters4fvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5400(%rax), %r11
+       movq    5424(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(ProgramParameters4fvNV), .-GL_PREFIX(ProgramParameters4fvNV)
@@ -25408,7 +25535,7 @@ GL_PREFIX(ProgramParameters4fvNV):
 GL_PREFIX(RequestResidentProgramsNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5408(%rax), %r11
+       movq    5432(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -25418,13 +25545,13 @@ GL_PREFIX(RequestResidentProgramsNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5408(%rax), %r11
+       movq    5432(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5408(%rax), %r11
+       movq    5432(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -25434,7 +25561,7 @@ GL_PREFIX(RequestResidentProgramsNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5408(%rax), %r11
+       movq    5432(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(RequestResidentProgramsNV), .-GL_PREFIX(RequestResidentProgramsNV)
@@ -25445,7 +25572,7 @@ GL_PREFIX(RequestResidentProgramsNV):
 GL_PREFIX(TrackMatrixNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5416(%rax), %r11
+       movq    5440(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -25459,13 +25586,13 @@ GL_PREFIX(TrackMatrixNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5416(%rax), %r11
+       movq    5440(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5416(%rax), %r11
+       movq    5440(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -25479,7 +25606,7 @@ GL_PREFIX(TrackMatrixNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5416(%rax), %r11
+       movq    5440(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(TrackMatrixNV), .-GL_PREFIX(TrackMatrixNV)
@@ -25490,7 +25617,7 @@ GL_PREFIX(TrackMatrixNV):
 GL_PREFIX(VertexAttrib1dNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5424(%rax), %r11
+       movq    5448(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $24, %rsp
@@ -25500,13 +25627,13 @@ GL_PREFIX(VertexAttrib1dNV):
        movq    8(%rsp), %xmm0
        movq    (%rsp), %rdi
        addq    $24, %rsp
-       movq    5424(%rax), %r11
+       movq    5448(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5424(%rax), %r11
+       movq    5448(%rax), %r11
        jmp     *%r11
 1:
        subq    $24, %rsp
@@ -25516,7 +25643,7 @@ GL_PREFIX(VertexAttrib1dNV):
        movq    8(%rsp), %xmm0
        movq    (%rsp), %rdi
        addq    $24, %rsp
-       movq    5424(%rax), %r11
+       movq    5448(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib1dNV), .-GL_PREFIX(VertexAttrib1dNV)
@@ -25527,7 +25654,7 @@ GL_PREFIX(VertexAttrib1dNV):
 GL_PREFIX(VertexAttrib1dvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5432(%rax), %r11
+       movq    5456(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -25537,13 +25664,13 @@ GL_PREFIX(VertexAttrib1dvNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5432(%rax), %r11
+       movq    5456(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5432(%rax), %r11
+       movq    5456(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -25553,7 +25680,7 @@ GL_PREFIX(VertexAttrib1dvNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5432(%rax), %r11
+       movq    5456(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib1dvNV), .-GL_PREFIX(VertexAttrib1dvNV)
@@ -25564,7 +25691,7 @@ GL_PREFIX(VertexAttrib1dvNV):
 GL_PREFIX(VertexAttrib1fNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5440(%rax), %r11
+       movq    5464(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $24, %rsp
@@ -25574,13 +25701,13 @@ GL_PREFIX(VertexAttrib1fNV):
        movq    8(%rsp), %xmm0
        movq    (%rsp), %rdi
        addq    $24, %rsp
-       movq    5440(%rax), %r11
+       movq    5464(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5440(%rax), %r11
+       movq    5464(%rax), %r11
        jmp     *%r11
 1:
        subq    $24, %rsp
@@ -25590,7 +25717,7 @@ GL_PREFIX(VertexAttrib1fNV):
        movq    8(%rsp), %xmm0
        movq    (%rsp), %rdi
        addq    $24, %rsp
-       movq    5440(%rax), %r11
+       movq    5464(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib1fNV), .-GL_PREFIX(VertexAttrib1fNV)
@@ -25601,7 +25728,7 @@ GL_PREFIX(VertexAttrib1fNV):
 GL_PREFIX(VertexAttrib1fvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5448(%rax), %r11
+       movq    5472(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -25611,13 +25738,13 @@ GL_PREFIX(VertexAttrib1fvNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5448(%rax), %r11
+       movq    5472(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5448(%rax), %r11
+       movq    5472(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -25627,7 +25754,7 @@ GL_PREFIX(VertexAttrib1fvNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5448(%rax), %r11
+       movq    5472(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib1fvNV), .-GL_PREFIX(VertexAttrib1fvNV)
@@ -25638,7 +25765,7 @@ GL_PREFIX(VertexAttrib1fvNV):
 GL_PREFIX(VertexAttrib1sNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5456(%rax), %r11
+       movq    5480(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -25648,13 +25775,13 @@ GL_PREFIX(VertexAttrib1sNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5456(%rax), %r11
+       movq    5480(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5456(%rax), %r11
+       movq    5480(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -25664,7 +25791,7 @@ GL_PREFIX(VertexAttrib1sNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5456(%rax), %r11
+       movq    5480(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib1sNV), .-GL_PREFIX(VertexAttrib1sNV)
@@ -25675,7 +25802,7 @@ GL_PREFIX(VertexAttrib1sNV):
 GL_PREFIX(VertexAttrib1svNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5464(%rax), %r11
+       movq    5488(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -25685,13 +25812,13 @@ GL_PREFIX(VertexAttrib1svNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5464(%rax), %r11
+       movq    5488(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5464(%rax), %r11
+       movq    5488(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -25701,7 +25828,7 @@ GL_PREFIX(VertexAttrib1svNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5464(%rax), %r11
+       movq    5488(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib1svNV), .-GL_PREFIX(VertexAttrib1svNV)
@@ -25712,7 +25839,7 @@ GL_PREFIX(VertexAttrib1svNV):
 GL_PREFIX(VertexAttrib2dNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5472(%rax), %r11
+       movq    5496(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $24, %rsp
@@ -25724,13 +25851,13 @@ GL_PREFIX(VertexAttrib2dNV):
        movq    8(%rsp), %xmm0
        movq    (%rsp), %rdi
        addq    $24, %rsp
-       movq    5472(%rax), %r11
+       movq    5496(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5472(%rax), %r11
+       movq    5496(%rax), %r11
        jmp     *%r11
 1:
        subq    $24, %rsp
@@ -25742,7 +25869,7 @@ GL_PREFIX(VertexAttrib2dNV):
        movq    8(%rsp), %xmm0
        movq    (%rsp), %rdi
        addq    $24, %rsp
-       movq    5472(%rax), %r11
+       movq    5496(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib2dNV), .-GL_PREFIX(VertexAttrib2dNV)
@@ -25753,7 +25880,7 @@ GL_PREFIX(VertexAttrib2dNV):
 GL_PREFIX(VertexAttrib2dvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5480(%rax), %r11
+       movq    5504(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -25763,13 +25890,13 @@ GL_PREFIX(VertexAttrib2dvNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5480(%rax), %r11
+       movq    5504(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5480(%rax), %r11
+       movq    5504(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -25779,7 +25906,7 @@ GL_PREFIX(VertexAttrib2dvNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5480(%rax), %r11
+       movq    5504(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib2dvNV), .-GL_PREFIX(VertexAttrib2dvNV)
@@ -25790,7 +25917,7 @@ GL_PREFIX(VertexAttrib2dvNV):
 GL_PREFIX(VertexAttrib2fNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5488(%rax), %r11
+       movq    5512(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $24, %rsp
@@ -25802,13 +25929,13 @@ GL_PREFIX(VertexAttrib2fNV):
        movq    8(%rsp), %xmm0
        movq    (%rsp), %rdi
        addq    $24, %rsp
-       movq    5488(%rax), %r11
+       movq    5512(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5488(%rax), %r11
+       movq    5512(%rax), %r11
        jmp     *%r11
 1:
        subq    $24, %rsp
@@ -25820,7 +25947,7 @@ GL_PREFIX(VertexAttrib2fNV):
        movq    8(%rsp), %xmm0
        movq    (%rsp), %rdi
        addq    $24, %rsp
-       movq    5488(%rax), %r11
+       movq    5512(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib2fNV), .-GL_PREFIX(VertexAttrib2fNV)
@@ -25831,7 +25958,7 @@ GL_PREFIX(VertexAttrib2fNV):
 GL_PREFIX(VertexAttrib2fvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5496(%rax), %r11
+       movq    5520(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -25841,13 +25968,13 @@ GL_PREFIX(VertexAttrib2fvNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5496(%rax), %r11
+       movq    5520(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5496(%rax), %r11
+       movq    5520(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -25857,7 +25984,7 @@ GL_PREFIX(VertexAttrib2fvNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5496(%rax), %r11
+       movq    5520(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib2fvNV), .-GL_PREFIX(VertexAttrib2fvNV)
@@ -25868,7 +25995,7 @@ GL_PREFIX(VertexAttrib2fvNV):
 GL_PREFIX(VertexAttrib2sNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5504(%rax), %r11
+       movq    5528(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -25878,13 +26005,13 @@ GL_PREFIX(VertexAttrib2sNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5504(%rax), %r11
+       movq    5528(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5504(%rax), %r11
+       movq    5528(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -25894,7 +26021,7 @@ GL_PREFIX(VertexAttrib2sNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5504(%rax), %r11
+       movq    5528(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib2sNV), .-GL_PREFIX(VertexAttrib2sNV)
@@ -25905,7 +26032,7 @@ GL_PREFIX(VertexAttrib2sNV):
 GL_PREFIX(VertexAttrib2svNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5512(%rax), %r11
+       movq    5536(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -25915,13 +26042,13 @@ GL_PREFIX(VertexAttrib2svNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5512(%rax), %r11
+       movq    5536(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5512(%rax), %r11
+       movq    5536(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -25931,7 +26058,7 @@ GL_PREFIX(VertexAttrib2svNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5512(%rax), %r11
+       movq    5536(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib2svNV), .-GL_PREFIX(VertexAttrib2svNV)
@@ -25942,7 +26069,7 @@ GL_PREFIX(VertexAttrib2svNV):
 GL_PREFIX(VertexAttrib3dNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5520(%rax), %r11
+       movq    5544(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $40, %rsp
@@ -25956,13 +26083,13 @@ GL_PREFIX(VertexAttrib3dNV):
        movq    8(%rsp), %xmm0
        movq    (%rsp), %rdi
        addq    $40, %rsp
-       movq    5520(%rax), %r11
+       movq    5544(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5520(%rax), %r11
+       movq    5544(%rax), %r11
        jmp     *%r11
 1:
        subq    $40, %rsp
@@ -25976,7 +26103,7 @@ GL_PREFIX(VertexAttrib3dNV):
        movq    8(%rsp), %xmm0
        movq    (%rsp), %rdi
        addq    $40, %rsp
-       movq    5520(%rax), %r11
+       movq    5544(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib3dNV), .-GL_PREFIX(VertexAttrib3dNV)
@@ -25987,7 +26114,7 @@ GL_PREFIX(VertexAttrib3dNV):
 GL_PREFIX(VertexAttrib3dvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5528(%rax), %r11
+       movq    5552(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -25997,13 +26124,13 @@ GL_PREFIX(VertexAttrib3dvNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5528(%rax), %r11
+       movq    5552(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5528(%rax), %r11
+       movq    5552(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26013,7 +26140,7 @@ GL_PREFIX(VertexAttrib3dvNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5528(%rax), %r11
+       movq    5552(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib3dvNV), .-GL_PREFIX(VertexAttrib3dvNV)
@@ -26024,7 +26151,7 @@ GL_PREFIX(VertexAttrib3dvNV):
 GL_PREFIX(VertexAttrib3fNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5536(%rax), %r11
+       movq    5560(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $40, %rsp
@@ -26038,13 +26165,13 @@ GL_PREFIX(VertexAttrib3fNV):
        movq    8(%rsp), %xmm0
        movq    (%rsp), %rdi
        addq    $40, %rsp
-       movq    5536(%rax), %r11
+       movq    5560(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5536(%rax), %r11
+       movq    5560(%rax), %r11
        jmp     *%r11
 1:
        subq    $40, %rsp
@@ -26058,7 +26185,7 @@ GL_PREFIX(VertexAttrib3fNV):
        movq    8(%rsp), %xmm0
        movq    (%rsp), %rdi
        addq    $40, %rsp
-       movq    5536(%rax), %r11
+       movq    5560(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib3fNV), .-GL_PREFIX(VertexAttrib3fNV)
@@ -26069,7 +26196,7 @@ GL_PREFIX(VertexAttrib3fNV):
 GL_PREFIX(VertexAttrib3fvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5544(%rax), %r11
+       movq    5568(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26079,13 +26206,13 @@ GL_PREFIX(VertexAttrib3fvNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5544(%rax), %r11
+       movq    5568(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5544(%rax), %r11
+       movq    5568(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26095,7 +26222,7 @@ GL_PREFIX(VertexAttrib3fvNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5544(%rax), %r11
+       movq    5568(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib3fvNV), .-GL_PREFIX(VertexAttrib3fvNV)
@@ -26106,7 +26233,7 @@ GL_PREFIX(VertexAttrib3fvNV):
 GL_PREFIX(VertexAttrib3sNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5552(%rax), %r11
+       movq    5576(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26120,13 +26247,13 @@ GL_PREFIX(VertexAttrib3sNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5552(%rax), %r11
+       movq    5576(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5552(%rax), %r11
+       movq    5576(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26140,7 +26267,7 @@ GL_PREFIX(VertexAttrib3sNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5552(%rax), %r11
+       movq    5576(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib3sNV), .-GL_PREFIX(VertexAttrib3sNV)
@@ -26151,7 +26278,7 @@ GL_PREFIX(VertexAttrib3sNV):
 GL_PREFIX(VertexAttrib3svNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5560(%rax), %r11
+       movq    5584(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26161,13 +26288,13 @@ GL_PREFIX(VertexAttrib3svNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5560(%rax), %r11
+       movq    5584(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5560(%rax), %r11
+       movq    5584(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26177,7 +26304,7 @@ GL_PREFIX(VertexAttrib3svNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5560(%rax), %r11
+       movq    5584(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib3svNV), .-GL_PREFIX(VertexAttrib3svNV)
@@ -26188,7 +26315,7 @@ GL_PREFIX(VertexAttrib3svNV):
 GL_PREFIX(VertexAttrib4dNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5568(%rax), %r11
+       movq    5592(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $40, %rsp
@@ -26204,13 +26331,13 @@ GL_PREFIX(VertexAttrib4dNV):
        movq    8(%rsp), %xmm0
        movq    (%rsp), %rdi
        addq    $40, %rsp
-       movq    5568(%rax), %r11
+       movq    5592(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5568(%rax), %r11
+       movq    5592(%rax), %r11
        jmp     *%r11
 1:
        subq    $40, %rsp
@@ -26226,7 +26353,7 @@ GL_PREFIX(VertexAttrib4dNV):
        movq    8(%rsp), %xmm0
        movq    (%rsp), %rdi
        addq    $40, %rsp
-       movq    5568(%rax), %r11
+       movq    5592(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib4dNV), .-GL_PREFIX(VertexAttrib4dNV)
@@ -26237,7 +26364,7 @@ GL_PREFIX(VertexAttrib4dNV):
 GL_PREFIX(VertexAttrib4dvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5576(%rax), %r11
+       movq    5600(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26247,13 +26374,13 @@ GL_PREFIX(VertexAttrib4dvNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5576(%rax), %r11
+       movq    5600(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5576(%rax), %r11
+       movq    5600(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26263,7 +26390,7 @@ GL_PREFIX(VertexAttrib4dvNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5576(%rax), %r11
+       movq    5600(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib4dvNV), .-GL_PREFIX(VertexAttrib4dvNV)
@@ -26274,7 +26401,7 @@ GL_PREFIX(VertexAttrib4dvNV):
 GL_PREFIX(VertexAttrib4fNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5584(%rax), %r11
+       movq    5608(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $40, %rsp
@@ -26290,13 +26417,13 @@ GL_PREFIX(VertexAttrib4fNV):
        movq    8(%rsp), %xmm0
        movq    (%rsp), %rdi
        addq    $40, %rsp
-       movq    5584(%rax), %r11
+       movq    5608(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5584(%rax), %r11
+       movq    5608(%rax), %r11
        jmp     *%r11
 1:
        subq    $40, %rsp
@@ -26312,7 +26439,7 @@ GL_PREFIX(VertexAttrib4fNV):
        movq    8(%rsp), %xmm0
        movq    (%rsp), %rdi
        addq    $40, %rsp
-       movq    5584(%rax), %r11
+       movq    5608(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib4fNV), .-GL_PREFIX(VertexAttrib4fNV)
@@ -26323,7 +26450,7 @@ GL_PREFIX(VertexAttrib4fNV):
 GL_PREFIX(VertexAttrib4fvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5592(%rax), %r11
+       movq    5616(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26333,13 +26460,13 @@ GL_PREFIX(VertexAttrib4fvNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5592(%rax), %r11
+       movq    5616(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5592(%rax), %r11
+       movq    5616(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26349,7 +26476,7 @@ GL_PREFIX(VertexAttrib4fvNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5592(%rax), %r11
+       movq    5616(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib4fvNV), .-GL_PREFIX(VertexAttrib4fvNV)
@@ -26360,7 +26487,7 @@ GL_PREFIX(VertexAttrib4fvNV):
 GL_PREFIX(VertexAttrib4sNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5600(%rax), %r11
+       movq    5624(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26374,13 +26501,13 @@ GL_PREFIX(VertexAttrib4sNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5600(%rax), %r11
+       movq    5624(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5600(%rax), %r11
+       movq    5624(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26394,7 +26521,7 @@ GL_PREFIX(VertexAttrib4sNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5600(%rax), %r11
+       movq    5624(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib4sNV), .-GL_PREFIX(VertexAttrib4sNV)
@@ -26405,7 +26532,7 @@ GL_PREFIX(VertexAttrib4sNV):
 GL_PREFIX(VertexAttrib4svNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5608(%rax), %r11
+       movq    5632(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26415,13 +26542,13 @@ GL_PREFIX(VertexAttrib4svNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5608(%rax), %r11
+       movq    5632(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5608(%rax), %r11
+       movq    5632(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26431,7 +26558,7 @@ GL_PREFIX(VertexAttrib4svNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5608(%rax), %r11
+       movq    5632(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib4svNV), .-GL_PREFIX(VertexAttrib4svNV)
@@ -26442,7 +26569,7 @@ GL_PREFIX(VertexAttrib4svNV):
 GL_PREFIX(VertexAttrib4ubNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5616(%rax), %r11
+       movq    5640(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26456,13 +26583,13 @@ GL_PREFIX(VertexAttrib4ubNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5616(%rax), %r11
+       movq    5640(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5616(%rax), %r11
+       movq    5640(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26476,7 +26603,7 @@ GL_PREFIX(VertexAttrib4ubNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5616(%rax), %r11
+       movq    5640(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib4ubNV), .-GL_PREFIX(VertexAttrib4ubNV)
@@ -26487,7 +26614,7 @@ GL_PREFIX(VertexAttrib4ubNV):
 GL_PREFIX(VertexAttrib4ubvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5624(%rax), %r11
+       movq    5648(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26497,13 +26624,13 @@ GL_PREFIX(VertexAttrib4ubvNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5624(%rax), %r11
+       movq    5648(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5624(%rax), %r11
+       movq    5648(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26513,7 +26640,7 @@ GL_PREFIX(VertexAttrib4ubvNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5624(%rax), %r11
+       movq    5648(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttrib4ubvNV), .-GL_PREFIX(VertexAttrib4ubvNV)
@@ -26524,7 +26651,7 @@ GL_PREFIX(VertexAttrib4ubvNV):
 GL_PREFIX(VertexAttribPointerNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5632(%rax), %r11
+       movq    5656(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26538,13 +26665,13 @@ GL_PREFIX(VertexAttribPointerNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5632(%rax), %r11
+       movq    5656(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5632(%rax), %r11
+       movq    5656(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26558,7 +26685,7 @@ GL_PREFIX(VertexAttribPointerNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5632(%rax), %r11
+       movq    5656(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttribPointerNV), .-GL_PREFIX(VertexAttribPointerNV)
@@ -26569,7 +26696,7 @@ GL_PREFIX(VertexAttribPointerNV):
 GL_PREFIX(VertexAttribs1dvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5640(%rax), %r11
+       movq    5664(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26579,13 +26706,13 @@ GL_PREFIX(VertexAttribs1dvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5640(%rax), %r11
+       movq    5664(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5640(%rax), %r11
+       movq    5664(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26595,7 +26722,7 @@ GL_PREFIX(VertexAttribs1dvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5640(%rax), %r11
+       movq    5664(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttribs1dvNV), .-GL_PREFIX(VertexAttribs1dvNV)
@@ -26606,7 +26733,7 @@ GL_PREFIX(VertexAttribs1dvNV):
 GL_PREFIX(VertexAttribs1fvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5648(%rax), %r11
+       movq    5672(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26616,13 +26743,13 @@ GL_PREFIX(VertexAttribs1fvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5648(%rax), %r11
+       movq    5672(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5648(%rax), %r11
+       movq    5672(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26632,7 +26759,7 @@ GL_PREFIX(VertexAttribs1fvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5648(%rax), %r11
+       movq    5672(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttribs1fvNV), .-GL_PREFIX(VertexAttribs1fvNV)
@@ -26643,7 +26770,7 @@ GL_PREFIX(VertexAttribs1fvNV):
 GL_PREFIX(VertexAttribs1svNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5656(%rax), %r11
+       movq    5680(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26653,13 +26780,13 @@ GL_PREFIX(VertexAttribs1svNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5656(%rax), %r11
+       movq    5680(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5656(%rax), %r11
+       movq    5680(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26669,7 +26796,7 @@ GL_PREFIX(VertexAttribs1svNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5656(%rax), %r11
+       movq    5680(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttribs1svNV), .-GL_PREFIX(VertexAttribs1svNV)
@@ -26680,7 +26807,7 @@ GL_PREFIX(VertexAttribs1svNV):
 GL_PREFIX(VertexAttribs2dvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5664(%rax), %r11
+       movq    5688(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26690,13 +26817,13 @@ GL_PREFIX(VertexAttribs2dvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5664(%rax), %r11
+       movq    5688(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5664(%rax), %r11
+       movq    5688(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26706,7 +26833,7 @@ GL_PREFIX(VertexAttribs2dvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5664(%rax), %r11
+       movq    5688(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttribs2dvNV), .-GL_PREFIX(VertexAttribs2dvNV)
@@ -26717,7 +26844,7 @@ GL_PREFIX(VertexAttribs2dvNV):
 GL_PREFIX(VertexAttribs2fvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5672(%rax), %r11
+       movq    5696(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26727,13 +26854,13 @@ GL_PREFIX(VertexAttribs2fvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5672(%rax), %r11
+       movq    5696(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5672(%rax), %r11
+       movq    5696(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26743,7 +26870,7 @@ GL_PREFIX(VertexAttribs2fvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5672(%rax), %r11
+       movq    5696(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttribs2fvNV), .-GL_PREFIX(VertexAttribs2fvNV)
@@ -26754,7 +26881,7 @@ GL_PREFIX(VertexAttribs2fvNV):
 GL_PREFIX(VertexAttribs2svNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5680(%rax), %r11
+       movq    5704(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26764,13 +26891,13 @@ GL_PREFIX(VertexAttribs2svNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5680(%rax), %r11
+       movq    5704(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5680(%rax), %r11
+       movq    5704(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26780,7 +26907,7 @@ GL_PREFIX(VertexAttribs2svNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5680(%rax), %r11
+       movq    5704(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttribs2svNV), .-GL_PREFIX(VertexAttribs2svNV)
@@ -26791,7 +26918,7 @@ GL_PREFIX(VertexAttribs2svNV):
 GL_PREFIX(VertexAttribs3dvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5688(%rax), %r11
+       movq    5712(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26801,13 +26928,13 @@ GL_PREFIX(VertexAttribs3dvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5688(%rax), %r11
+       movq    5712(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5688(%rax), %r11
+       movq    5712(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26817,7 +26944,7 @@ GL_PREFIX(VertexAttribs3dvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5688(%rax), %r11
+       movq    5712(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttribs3dvNV), .-GL_PREFIX(VertexAttribs3dvNV)
@@ -26828,7 +26955,7 @@ GL_PREFIX(VertexAttribs3dvNV):
 GL_PREFIX(VertexAttribs3fvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5696(%rax), %r11
+       movq    5720(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26838,13 +26965,13 @@ GL_PREFIX(VertexAttribs3fvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5696(%rax), %r11
+       movq    5720(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5696(%rax), %r11
+       movq    5720(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26854,7 +26981,7 @@ GL_PREFIX(VertexAttribs3fvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5696(%rax), %r11
+       movq    5720(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttribs3fvNV), .-GL_PREFIX(VertexAttribs3fvNV)
@@ -26865,7 +26992,7 @@ GL_PREFIX(VertexAttribs3fvNV):
 GL_PREFIX(VertexAttribs3svNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5704(%rax), %r11
+       movq    5728(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26875,13 +27002,13 @@ GL_PREFIX(VertexAttribs3svNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5704(%rax), %r11
+       movq    5728(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5704(%rax), %r11
+       movq    5728(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26891,7 +27018,7 @@ GL_PREFIX(VertexAttribs3svNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5704(%rax), %r11
+       movq    5728(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttribs3svNV), .-GL_PREFIX(VertexAttribs3svNV)
@@ -26902,7 +27029,7 @@ GL_PREFIX(VertexAttribs3svNV):
 GL_PREFIX(VertexAttribs4dvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5712(%rax), %r11
+       movq    5736(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26912,13 +27039,13 @@ GL_PREFIX(VertexAttribs4dvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5712(%rax), %r11
+       movq    5736(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5712(%rax), %r11
+       movq    5736(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26928,7 +27055,7 @@ GL_PREFIX(VertexAttribs4dvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5712(%rax), %r11
+       movq    5736(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttribs4dvNV), .-GL_PREFIX(VertexAttribs4dvNV)
@@ -26939,7 +27066,7 @@ GL_PREFIX(VertexAttribs4dvNV):
 GL_PREFIX(VertexAttribs4fvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5720(%rax), %r11
+       movq    5744(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26949,13 +27076,13 @@ GL_PREFIX(VertexAttribs4fvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5720(%rax), %r11
+       movq    5744(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5720(%rax), %r11
+       movq    5744(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -26965,7 +27092,7 @@ GL_PREFIX(VertexAttribs4fvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5720(%rax), %r11
+       movq    5744(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttribs4fvNV), .-GL_PREFIX(VertexAttribs4fvNV)
@@ -26976,7 +27103,7 @@ GL_PREFIX(VertexAttribs4fvNV):
 GL_PREFIX(VertexAttribs4svNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5728(%rax), %r11
+       movq    5752(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -26986,13 +27113,13 @@ GL_PREFIX(VertexAttribs4svNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5728(%rax), %r11
+       movq    5752(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5728(%rax), %r11
+       movq    5752(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -27002,7 +27129,7 @@ GL_PREFIX(VertexAttribs4svNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5728(%rax), %r11
+       movq    5752(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttribs4svNV), .-GL_PREFIX(VertexAttribs4svNV)
@@ -27013,7 +27140,7 @@ GL_PREFIX(VertexAttribs4svNV):
 GL_PREFIX(VertexAttribs4ubvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5736(%rax), %r11
+       movq    5760(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -27023,13 +27150,13 @@ GL_PREFIX(VertexAttribs4ubvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5736(%rax), %r11
+       movq    5760(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5736(%rax), %r11
+       movq    5760(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -27039,7 +27166,7 @@ GL_PREFIX(VertexAttribs4ubvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5736(%rax), %r11
+       movq    5760(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(VertexAttribs4ubvNV), .-GL_PREFIX(VertexAttribs4ubvNV)
@@ -27050,7 +27177,7 @@ GL_PREFIX(VertexAttribs4ubvNV):
 GL_PREFIX(GetTexBumpParameterfvATI):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5744(%rax), %r11
+       movq    5768(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -27060,13 +27187,13 @@ GL_PREFIX(GetTexBumpParameterfvATI):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5744(%rax), %r11
+       movq    5768(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5744(%rax), %r11
+       movq    5768(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -27076,7 +27203,7 @@ GL_PREFIX(GetTexBumpParameterfvATI):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5744(%rax), %r11
+       movq    5768(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetTexBumpParameterfvATI), .-GL_PREFIX(GetTexBumpParameterfvATI)
@@ -27087,7 +27214,7 @@ GL_PREFIX(GetTexBumpParameterfvATI):
 GL_PREFIX(GetTexBumpParameterivATI):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5752(%rax), %r11
+       movq    5776(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -27097,13 +27224,13 @@ GL_PREFIX(GetTexBumpParameterivATI):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5752(%rax), %r11
+       movq    5776(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5752(%rax), %r11
+       movq    5776(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -27113,7 +27240,7 @@ GL_PREFIX(GetTexBumpParameterivATI):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5752(%rax), %r11
+       movq    5776(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetTexBumpParameterivATI), .-GL_PREFIX(GetTexBumpParameterivATI)
@@ -27124,7 +27251,7 @@ GL_PREFIX(GetTexBumpParameterivATI):
 GL_PREFIX(TexBumpParameterfvATI):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5760(%rax), %r11
+       movq    5784(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -27134,13 +27261,13 @@ GL_PREFIX(TexBumpParameterfvATI):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5760(%rax), %r11
+       movq    5784(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5760(%rax), %r11
+       movq    5784(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -27150,7 +27277,7 @@ GL_PREFIX(TexBumpParameterfvATI):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5760(%rax), %r11
+       movq    5784(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(TexBumpParameterfvATI), .-GL_PREFIX(TexBumpParameterfvATI)
@@ -27161,7 +27288,7 @@ GL_PREFIX(TexBumpParameterfvATI):
 GL_PREFIX(TexBumpParameterivATI):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5768(%rax), %r11
+       movq    5792(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -27171,13 +27298,13 @@ GL_PREFIX(TexBumpParameterivATI):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5768(%rax), %r11
+       movq    5792(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5768(%rax), %r11
+       movq    5792(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -27187,7 +27314,7 @@ GL_PREFIX(TexBumpParameterivATI):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5768(%rax), %r11
+       movq    5792(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(TexBumpParameterivATI), .-GL_PREFIX(TexBumpParameterivATI)
@@ -27198,7 +27325,7 @@ GL_PREFIX(TexBumpParameterivATI):
 GL_PREFIX(AlphaFragmentOp1ATI):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5776(%rax), %r11
+       movq    5800(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -27216,13 +27343,13 @@ GL_PREFIX(AlphaFragmentOp1ATI):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5776(%rax), %r11
+       movq    5800(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5776(%rax), %r11
+       movq    5800(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -27240,7 +27367,7 @@ GL_PREFIX(AlphaFragmentOp1ATI):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5776(%rax), %r11
+       movq    5800(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(AlphaFragmentOp1ATI), .-GL_PREFIX(AlphaFragmentOp1ATI)
@@ -27251,7 +27378,7 @@ GL_PREFIX(AlphaFragmentOp1ATI):
 GL_PREFIX(AlphaFragmentOp2ATI):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5784(%rax), %r11
+       movq    5808(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -27269,13 +27396,13 @@ GL_PREFIX(AlphaFragmentOp2ATI):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5784(%rax), %r11
+       movq    5808(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5784(%rax), %r11
+       movq    5808(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -27293,7 +27420,7 @@ GL_PREFIX(AlphaFragmentOp2ATI):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5784(%rax), %r11
+       movq    5808(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(AlphaFragmentOp2ATI), .-GL_PREFIX(AlphaFragmentOp2ATI)
@@ -27304,7 +27431,7 @@ GL_PREFIX(AlphaFragmentOp2ATI):
 GL_PREFIX(AlphaFragmentOp3ATI):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5792(%rax), %r11
+       movq    5816(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -27322,13 +27449,13 @@ GL_PREFIX(AlphaFragmentOp3ATI):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5792(%rax), %r11
+       movq    5816(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5792(%rax), %r11
+       movq    5816(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -27346,7 +27473,7 @@ GL_PREFIX(AlphaFragmentOp3ATI):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5792(%rax), %r11
+       movq    5816(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(AlphaFragmentOp3ATI), .-GL_PREFIX(AlphaFragmentOp3ATI)
@@ -27357,25 +27484,25 @@ GL_PREFIX(AlphaFragmentOp3ATI):
 GL_PREFIX(BeginFragmentShaderATI):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5800(%rax), %r11
+       movq    5824(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rbp
        call    _x86_64_get_dispatch@PLT
        popq    %rbp
-       movq    5800(%rax), %r11
+       movq    5824(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5800(%rax), %r11
+       movq    5824(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rbp
        call    _glapi_get_dispatch
        popq    %rbp
-       movq    5800(%rax), %r11
+       movq    5824(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(BeginFragmentShaderATI), .-GL_PREFIX(BeginFragmentShaderATI)
@@ -27386,25 +27513,25 @@ GL_PREFIX(BeginFragmentShaderATI):
 GL_PREFIX(BindFragmentShaderATI):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5808(%rax), %r11
+       movq    5832(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5808(%rax), %r11
+       movq    5832(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5808(%rax), %r11
+       movq    5832(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5808(%rax), %r11
+       movq    5832(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(BindFragmentShaderATI), .-GL_PREFIX(BindFragmentShaderATI)
@@ -27415,7 +27542,7 @@ GL_PREFIX(BindFragmentShaderATI):
 GL_PREFIX(ColorFragmentOp1ATI):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5816(%rax), %r11
+       movq    5840(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -27433,13 +27560,13 @@ GL_PREFIX(ColorFragmentOp1ATI):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5816(%rax), %r11
+       movq    5840(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5816(%rax), %r11
+       movq    5840(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -27457,7 +27584,7 @@ GL_PREFIX(ColorFragmentOp1ATI):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5816(%rax), %r11
+       movq    5840(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(ColorFragmentOp1ATI), .-GL_PREFIX(ColorFragmentOp1ATI)
@@ -27468,7 +27595,7 @@ GL_PREFIX(ColorFragmentOp1ATI):
 GL_PREFIX(ColorFragmentOp2ATI):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5824(%rax), %r11
+       movq    5848(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -27486,13 +27613,13 @@ GL_PREFIX(ColorFragmentOp2ATI):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5824(%rax), %r11
+       movq    5848(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5824(%rax), %r11
+       movq    5848(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -27510,7 +27637,7 @@ GL_PREFIX(ColorFragmentOp2ATI):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5824(%rax), %r11
+       movq    5848(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(ColorFragmentOp2ATI), .-GL_PREFIX(ColorFragmentOp2ATI)
@@ -27521,7 +27648,7 @@ GL_PREFIX(ColorFragmentOp2ATI):
 GL_PREFIX(ColorFragmentOp3ATI):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5832(%rax), %r11
+       movq    5856(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -27539,13 +27666,13 @@ GL_PREFIX(ColorFragmentOp3ATI):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5832(%rax), %r11
+       movq    5856(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5832(%rax), %r11
+       movq    5856(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -27563,7 +27690,7 @@ GL_PREFIX(ColorFragmentOp3ATI):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5832(%rax), %r11
+       movq    5856(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(ColorFragmentOp3ATI), .-GL_PREFIX(ColorFragmentOp3ATI)
@@ -27574,25 +27701,25 @@ GL_PREFIX(ColorFragmentOp3ATI):
 GL_PREFIX(DeleteFragmentShaderATI):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5840(%rax), %r11
+       movq    5864(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5840(%rax), %r11
+       movq    5864(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5840(%rax), %r11
+       movq    5864(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5840(%rax), %r11
+       movq    5864(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(DeleteFragmentShaderATI), .-GL_PREFIX(DeleteFragmentShaderATI)
@@ -27603,25 +27730,25 @@ GL_PREFIX(DeleteFragmentShaderATI):
 GL_PREFIX(EndFragmentShaderATI):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5848(%rax), %r11
+       movq    5872(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rbp
        call    _x86_64_get_dispatch@PLT
        popq    %rbp
-       movq    5848(%rax), %r11
+       movq    5872(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5848(%rax), %r11
+       movq    5872(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rbp
        call    _glapi_get_dispatch
        popq    %rbp
-       movq    5848(%rax), %r11
+       movq    5872(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(EndFragmentShaderATI), .-GL_PREFIX(EndFragmentShaderATI)
@@ -27632,25 +27759,25 @@ GL_PREFIX(EndFragmentShaderATI):
 GL_PREFIX(GenFragmentShadersATI):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5856(%rax), %r11
+       movq    5880(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5856(%rax), %r11
+       movq    5880(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5856(%rax), %r11
+       movq    5880(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5856(%rax), %r11
+       movq    5880(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GenFragmentShadersATI), .-GL_PREFIX(GenFragmentShadersATI)
@@ -27661,7 +27788,7 @@ GL_PREFIX(GenFragmentShadersATI):
 GL_PREFIX(PassTexCoordATI):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5864(%rax), %r11
+       movq    5888(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -27671,13 +27798,13 @@ GL_PREFIX(PassTexCoordATI):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5864(%rax), %r11
+       movq    5888(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5864(%rax), %r11
+       movq    5888(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -27687,7 +27814,7 @@ GL_PREFIX(PassTexCoordATI):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5864(%rax), %r11
+       movq    5888(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(PassTexCoordATI), .-GL_PREFIX(PassTexCoordATI)
@@ -27698,7 +27825,7 @@ GL_PREFIX(PassTexCoordATI):
 GL_PREFIX(SampleMapATI):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5872(%rax), %r11
+       movq    5896(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -27708,13 +27835,13 @@ GL_PREFIX(SampleMapATI):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5872(%rax), %r11
+       movq    5896(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5872(%rax), %r11
+       movq    5896(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -27724,7 +27851,7 @@ GL_PREFIX(SampleMapATI):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5872(%rax), %r11
+       movq    5896(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(SampleMapATI), .-GL_PREFIX(SampleMapATI)
@@ -27735,7 +27862,7 @@ GL_PREFIX(SampleMapATI):
 GL_PREFIX(SetFragmentShaderConstantATI):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5880(%rax), %r11
+       movq    5904(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -27745,13 +27872,13 @@ GL_PREFIX(SetFragmentShaderConstantATI):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5880(%rax), %r11
+       movq    5904(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5880(%rax), %r11
+       movq    5904(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -27761,7 +27888,7 @@ GL_PREFIX(SetFragmentShaderConstantATI):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5880(%rax), %r11
+       movq    5904(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(SetFragmentShaderConstantATI), .-GL_PREFIX(SetFragmentShaderConstantATI)
@@ -27772,7 +27899,7 @@ GL_PREFIX(SetFragmentShaderConstantATI):
 GL_PREFIX(PointParameteriNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5888(%rax), %r11
+       movq    5912(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -27782,13 +27909,13 @@ GL_PREFIX(PointParameteriNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5888(%rax), %r11
+       movq    5912(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5888(%rax), %r11
+       movq    5912(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -27798,7 +27925,7 @@ GL_PREFIX(PointParameteriNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5888(%rax), %r11
+       movq    5912(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(PointParameteriNV), .-GL_PREFIX(PointParameteriNV)
@@ -27809,7 +27936,7 @@ GL_PREFIX(PointParameteriNV):
 GL_PREFIX(PointParameterivNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5896(%rax), %r11
+       movq    5920(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -27819,13 +27946,13 @@ GL_PREFIX(PointParameterivNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5896(%rax), %r11
+       movq    5920(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5896(%rax), %r11
+       movq    5920(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -27835,79 +27962,79 @@ GL_PREFIX(PointParameterivNV):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5896(%rax), %r11
+       movq    5920(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(PointParameterivNV), .-GL_PREFIX(PointParameterivNV)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_738)
-       .type   GL_PREFIX(_dispatch_stub_738), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_738))
-GL_PREFIX(_dispatch_stub_738):
+       .globl  GL_PREFIX(_dispatch_stub_741)
+       .type   GL_PREFIX(_dispatch_stub_741), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_741))
+GL_PREFIX(_dispatch_stub_741):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5904(%rax), %r11
+       movq    5928(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5904(%rax), %r11
+       movq    5928(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5904(%rax), %r11
+       movq    5928(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5904(%rax), %r11
+       movq    5928(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_738), .-GL_PREFIX(_dispatch_stub_738)
+       .size   GL_PREFIX(_dispatch_stub_741), .-GL_PREFIX(_dispatch_stub_741)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_739)
-       .type   GL_PREFIX(_dispatch_stub_739), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_739))
-GL_PREFIX(_dispatch_stub_739):
+       .globl  GL_PREFIX(_dispatch_stub_742)
+       .type   GL_PREFIX(_dispatch_stub_742), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_742))
+GL_PREFIX(_dispatch_stub_742):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5912(%rax), %r11
+       movq    5936(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5912(%rax), %r11
+       movq    5936(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5912(%rax), %r11
+       movq    5936(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5912(%rax), %r11
+       movq    5936(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_739), .-GL_PREFIX(_dispatch_stub_739)
+       .size   GL_PREFIX(_dispatch_stub_742), .-GL_PREFIX(_dispatch_stub_742)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_740)
-       .type   GL_PREFIX(_dispatch_stub_740), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_740))
-GL_PREFIX(_dispatch_stub_740):
+       .globl  GL_PREFIX(_dispatch_stub_743)
+       .type   GL_PREFIX(_dispatch_stub_743), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_743))
+GL_PREFIX(_dispatch_stub_743):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5920(%rax), %r11
+       movq    5944(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -27917,13 +28044,13 @@ GL_PREFIX(_dispatch_stub_740):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5920(%rax), %r11
+       movq    5944(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5920(%rax), %r11
+       movq    5944(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -27933,19 +28060,19 @@ GL_PREFIX(_dispatch_stub_740):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5920(%rax), %r11
+       movq    5944(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_740), .-GL_PREFIX(_dispatch_stub_740)
+       .size   GL_PREFIX(_dispatch_stub_743), .-GL_PREFIX(_dispatch_stub_743)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_741)
-       .type   GL_PREFIX(_dispatch_stub_741), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_741))
-GL_PREFIX(_dispatch_stub_741):
+       .globl  GL_PREFIX(_dispatch_stub_744)
+       .type   GL_PREFIX(_dispatch_stub_744), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_744))
+GL_PREFIX(_dispatch_stub_744):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5928(%rax), %r11
+       movq    5952(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -27955,13 +28082,13 @@ GL_PREFIX(_dispatch_stub_741):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5928(%rax), %r11
+       movq    5952(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5928(%rax), %r11
+       movq    5952(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -27971,40 +28098,40 @@ GL_PREFIX(_dispatch_stub_741):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5928(%rax), %r11
+       movq    5952(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_741), .-GL_PREFIX(_dispatch_stub_741)
+       .size   GL_PREFIX(_dispatch_stub_744), .-GL_PREFIX(_dispatch_stub_744)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_742)
-       .type   GL_PREFIX(_dispatch_stub_742), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_742))
-GL_PREFIX(_dispatch_stub_742):
+       .globl  GL_PREFIX(_dispatch_stub_745)
+       .type   GL_PREFIX(_dispatch_stub_745), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_745))
+GL_PREFIX(_dispatch_stub_745):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5936(%rax), %r11
+       movq    5960(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    5936(%rax), %r11
+       movq    5960(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5936(%rax), %r11
+       movq    5960(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    5936(%rax), %r11
+       movq    5960(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_742), .-GL_PREFIX(_dispatch_stub_742)
+       .size   GL_PREFIX(_dispatch_stub_745), .-GL_PREFIX(_dispatch_stub_745)
 
        .p2align        4,,15
        .globl  GL_PREFIX(GetProgramNamedParameterdvNV)
@@ -28012,7 +28139,7 @@ GL_PREFIX(_dispatch_stub_742):
 GL_PREFIX(GetProgramNamedParameterdvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5944(%rax), %r11
+       movq    5968(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -28026,13 +28153,13 @@ GL_PREFIX(GetProgramNamedParameterdvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5944(%rax), %r11
+       movq    5968(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5944(%rax), %r11
+       movq    5968(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -28046,7 +28173,7 @@ GL_PREFIX(GetProgramNamedParameterdvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5944(%rax), %r11
+       movq    5968(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetProgramNamedParameterdvNV), .-GL_PREFIX(GetProgramNamedParameterdvNV)
@@ -28057,7 +28184,7 @@ GL_PREFIX(GetProgramNamedParameterdvNV):
 GL_PREFIX(GetProgramNamedParameterfvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5952(%rax), %r11
+       movq    5976(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -28071,13 +28198,13 @@ GL_PREFIX(GetProgramNamedParameterfvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5952(%rax), %r11
+       movq    5976(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5952(%rax), %r11
+       movq    5976(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -28091,7 +28218,7 @@ GL_PREFIX(GetProgramNamedParameterfvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5952(%rax), %r11
+       movq    5976(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetProgramNamedParameterfvNV), .-GL_PREFIX(GetProgramNamedParameterfvNV)
@@ -28102,7 +28229,7 @@ GL_PREFIX(GetProgramNamedParameterfvNV):
 GL_PREFIX(ProgramNamedParameter4dNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5960(%rax), %r11
+       movq    5984(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $56, %rsp
@@ -28122,13 +28249,13 @@ GL_PREFIX(ProgramNamedParameter4dNV):
        movq    8(%rsp), %rsi
        movq    (%rsp), %rdi
        addq    $56, %rsp
-       movq    5960(%rax), %r11
+       movq    5984(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5960(%rax), %r11
+       movq    5984(%rax), %r11
        jmp     *%r11
 1:
        subq    $56, %rsp
@@ -28148,7 +28275,7 @@ GL_PREFIX(ProgramNamedParameter4dNV):
        movq    8(%rsp), %rsi
        movq    (%rsp), %rdi
        addq    $56, %rsp
-       movq    5960(%rax), %r11
+       movq    5984(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(ProgramNamedParameter4dNV), .-GL_PREFIX(ProgramNamedParameter4dNV)
@@ -28159,7 +28286,7 @@ GL_PREFIX(ProgramNamedParameter4dNV):
 GL_PREFIX(ProgramNamedParameter4dvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5968(%rax), %r11
+       movq    5992(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -28173,13 +28300,13 @@ GL_PREFIX(ProgramNamedParameter4dvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5968(%rax), %r11
+       movq    5992(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5968(%rax), %r11
+       movq    5992(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -28193,7 +28320,7 @@ GL_PREFIX(ProgramNamedParameter4dvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5968(%rax), %r11
+       movq    5992(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(ProgramNamedParameter4dvNV), .-GL_PREFIX(ProgramNamedParameter4dvNV)
@@ -28204,7 +28331,7 @@ GL_PREFIX(ProgramNamedParameter4dvNV):
 GL_PREFIX(ProgramNamedParameter4fNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5976(%rax), %r11
+       movq    6000(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        subq    $56, %rsp
@@ -28224,13 +28351,13 @@ GL_PREFIX(ProgramNamedParameter4fNV):
        movq    8(%rsp), %rsi
        movq    (%rsp), %rdi
        addq    $56, %rsp
-       movq    5976(%rax), %r11
+       movq    6000(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5976(%rax), %r11
+       movq    6000(%rax), %r11
        jmp     *%r11
 1:
        subq    $56, %rsp
@@ -28250,7 +28377,7 @@ GL_PREFIX(ProgramNamedParameter4fNV):
        movq    8(%rsp), %rsi
        movq    (%rsp), %rdi
        addq    $56, %rsp
-       movq    5976(%rax), %r11
+       movq    6000(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(ProgramNamedParameter4fNV), .-GL_PREFIX(ProgramNamedParameter4fNV)
@@ -28261,7 +28388,7 @@ GL_PREFIX(ProgramNamedParameter4fNV):
 GL_PREFIX(ProgramNamedParameter4fvNV):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5984(%rax), %r11
+       movq    6008(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -28275,13 +28402,13 @@ GL_PREFIX(ProgramNamedParameter4fvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5984(%rax), %r11
+       movq    6008(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5984(%rax), %r11
+       movq    6008(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -28295,19 +28422,19 @@ GL_PREFIX(ProgramNamedParameter4fvNV):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    5984(%rax), %r11
+       movq    6008(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(ProgramNamedParameter4fvNV), .-GL_PREFIX(ProgramNamedParameter4fvNV)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_749)
-       .type   GL_PREFIX(_dispatch_stub_749), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_749))
-GL_PREFIX(_dispatch_stub_749):
+       .globl  GL_PREFIX(_dispatch_stub_752)
+       .type   GL_PREFIX(_dispatch_stub_752), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_752))
+GL_PREFIX(_dispatch_stub_752):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    5992(%rax), %r11
+       movq    6016(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -28317,13 +28444,13 @@ GL_PREFIX(_dispatch_stub_749):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5992(%rax), %r11
+       movq    6016(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    5992(%rax), %r11
+       movq    6016(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -28333,19 +28460,19 @@ GL_PREFIX(_dispatch_stub_749):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    5992(%rax), %r11
+       movq    6016(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_749), .-GL_PREFIX(_dispatch_stub_749)
+       .size   GL_PREFIX(_dispatch_stub_752), .-GL_PREFIX(_dispatch_stub_752)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_750)
-       .type   GL_PREFIX(_dispatch_stub_750), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_750))
-GL_PREFIX(_dispatch_stub_750):
+       .globl  GL_PREFIX(_dispatch_stub_753)
+       .type   GL_PREFIX(_dispatch_stub_753), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_753))
+GL_PREFIX(_dispatch_stub_753):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6000(%rax), %r11
+       movq    6024(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -28355,13 +28482,13 @@ GL_PREFIX(_dispatch_stub_750):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    6000(%rax), %r11
+       movq    6024(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6000(%rax), %r11
+       movq    6024(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -28371,10 +28498,10 @@ GL_PREFIX(_dispatch_stub_750):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    6000(%rax), %r11
+       movq    6024(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_750), .-GL_PREFIX(_dispatch_stub_750)
+       .size   GL_PREFIX(_dispatch_stub_753), .-GL_PREFIX(_dispatch_stub_753)
 
        .p2align        4,,15
        .globl  GL_PREFIX(BindFramebufferEXT)
@@ -28382,7 +28509,7 @@ GL_PREFIX(_dispatch_stub_750):
 GL_PREFIX(BindFramebufferEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6008(%rax), %r11
+       movq    6032(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -28392,13 +28519,13 @@ GL_PREFIX(BindFramebufferEXT):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    6008(%rax), %r11
+       movq    6032(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6008(%rax), %r11
+       movq    6032(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -28408,7 +28535,7 @@ GL_PREFIX(BindFramebufferEXT):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    6008(%rax), %r11
+       movq    6032(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(BindFramebufferEXT), .-GL_PREFIX(BindFramebufferEXT)
@@ -28419,7 +28546,7 @@ GL_PREFIX(BindFramebufferEXT):
 GL_PREFIX(BindRenderbufferEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6016(%rax), %r11
+       movq    6040(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -28429,13 +28556,13 @@ GL_PREFIX(BindRenderbufferEXT):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    6016(%rax), %r11
+       movq    6040(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6016(%rax), %r11
+       movq    6040(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -28445,7 +28572,7 @@ GL_PREFIX(BindRenderbufferEXT):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    6016(%rax), %r11
+       movq    6040(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(BindRenderbufferEXT), .-GL_PREFIX(BindRenderbufferEXT)
@@ -28456,25 +28583,25 @@ GL_PREFIX(BindRenderbufferEXT):
 GL_PREFIX(CheckFramebufferStatusEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6024(%rax), %r11
+       movq    6048(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    6024(%rax), %r11
+       movq    6048(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6024(%rax), %r11
+       movq    6048(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    6024(%rax), %r11
+       movq    6048(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(CheckFramebufferStatusEXT), .-GL_PREFIX(CheckFramebufferStatusEXT)
@@ -28485,7 +28612,7 @@ GL_PREFIX(CheckFramebufferStatusEXT):
 GL_PREFIX(DeleteFramebuffersEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6032(%rax), %r11
+       movq    6056(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -28495,13 +28622,13 @@ GL_PREFIX(DeleteFramebuffersEXT):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    6032(%rax), %r11
+       movq    6056(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6032(%rax), %r11
+       movq    6056(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -28511,7 +28638,7 @@ GL_PREFIX(DeleteFramebuffersEXT):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    6032(%rax), %r11
+       movq    6056(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(DeleteFramebuffersEXT), .-GL_PREFIX(DeleteFramebuffersEXT)
@@ -28522,7 +28649,7 @@ GL_PREFIX(DeleteFramebuffersEXT):
 GL_PREFIX(DeleteRenderbuffersEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6040(%rax), %r11
+       movq    6064(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -28532,13 +28659,13 @@ GL_PREFIX(DeleteRenderbuffersEXT):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    6040(%rax), %r11
+       movq    6064(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6040(%rax), %r11
+       movq    6064(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -28548,7 +28675,7 @@ GL_PREFIX(DeleteRenderbuffersEXT):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    6040(%rax), %r11
+       movq    6064(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(DeleteRenderbuffersEXT), .-GL_PREFIX(DeleteRenderbuffersEXT)
@@ -28559,7 +28686,7 @@ GL_PREFIX(DeleteRenderbuffersEXT):
 GL_PREFIX(FramebufferRenderbufferEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6048(%rax), %r11
+       movq    6072(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -28573,13 +28700,13 @@ GL_PREFIX(FramebufferRenderbufferEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6048(%rax), %r11
+       movq    6072(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6048(%rax), %r11
+       movq    6072(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -28593,7 +28720,7 @@ GL_PREFIX(FramebufferRenderbufferEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6048(%rax), %r11
+       movq    6072(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(FramebufferRenderbufferEXT), .-GL_PREFIX(FramebufferRenderbufferEXT)
@@ -28604,7 +28731,7 @@ GL_PREFIX(FramebufferRenderbufferEXT):
 GL_PREFIX(FramebufferTexture1DEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6056(%rax), %r11
+       movq    6080(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -28618,13 +28745,13 @@ GL_PREFIX(FramebufferTexture1DEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6056(%rax), %r11
+       movq    6080(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6056(%rax), %r11
+       movq    6080(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -28638,7 +28765,7 @@ GL_PREFIX(FramebufferTexture1DEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6056(%rax), %r11
+       movq    6080(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(FramebufferTexture1DEXT), .-GL_PREFIX(FramebufferTexture1DEXT)
@@ -28649,7 +28776,7 @@ GL_PREFIX(FramebufferTexture1DEXT):
 GL_PREFIX(FramebufferTexture2DEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6064(%rax), %r11
+       movq    6088(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -28663,13 +28790,13 @@ GL_PREFIX(FramebufferTexture2DEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6064(%rax), %r11
+       movq    6088(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6064(%rax), %r11
+       movq    6088(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -28683,7 +28810,7 @@ GL_PREFIX(FramebufferTexture2DEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6064(%rax), %r11
+       movq    6088(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(FramebufferTexture2DEXT), .-GL_PREFIX(FramebufferTexture2DEXT)
@@ -28694,7 +28821,7 @@ GL_PREFIX(FramebufferTexture2DEXT):
 GL_PREFIX(FramebufferTexture3DEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6072(%rax), %r11
+       movq    6096(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -28712,13 +28839,13 @@ GL_PREFIX(FramebufferTexture3DEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6072(%rax), %r11
+       movq    6096(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6072(%rax), %r11
+       movq    6096(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -28736,7 +28863,7 @@ GL_PREFIX(FramebufferTexture3DEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6072(%rax), %r11
+       movq    6096(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(FramebufferTexture3DEXT), .-GL_PREFIX(FramebufferTexture3DEXT)
@@ -28747,7 +28874,7 @@ GL_PREFIX(FramebufferTexture3DEXT):
 GL_PREFIX(GenFramebuffersEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6080(%rax), %r11
+       movq    6104(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -28757,13 +28884,13 @@ GL_PREFIX(GenFramebuffersEXT):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    6080(%rax), %r11
+       movq    6104(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6080(%rax), %r11
+       movq    6104(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -28773,7 +28900,7 @@ GL_PREFIX(GenFramebuffersEXT):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    6080(%rax), %r11
+       movq    6104(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GenFramebuffersEXT), .-GL_PREFIX(GenFramebuffersEXT)
@@ -28784,7 +28911,7 @@ GL_PREFIX(GenFramebuffersEXT):
 GL_PREFIX(GenRenderbuffersEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6088(%rax), %r11
+       movq    6112(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -28794,13 +28921,13 @@ GL_PREFIX(GenRenderbuffersEXT):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    6088(%rax), %r11
+       movq    6112(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6088(%rax), %r11
+       movq    6112(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -28810,7 +28937,7 @@ GL_PREFIX(GenRenderbuffersEXT):
        popq    %rbp
        popq    %rsi
        popq    %rdi
-       movq    6088(%rax), %r11
+       movq    6112(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GenRenderbuffersEXT), .-GL_PREFIX(GenRenderbuffersEXT)
@@ -28821,25 +28948,25 @@ GL_PREFIX(GenRenderbuffersEXT):
 GL_PREFIX(GenerateMipmapEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6096(%rax), %r11
+       movq    6120(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    6096(%rax), %r11
+       movq    6120(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6096(%rax), %r11
+       movq    6120(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    6096(%rax), %r11
+       movq    6120(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GenerateMipmapEXT), .-GL_PREFIX(GenerateMipmapEXT)
@@ -28850,7 +28977,7 @@ GL_PREFIX(GenerateMipmapEXT):
 GL_PREFIX(GetFramebufferAttachmentParameterivEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6104(%rax), %r11
+       movq    6128(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -28864,13 +28991,13 @@ GL_PREFIX(GetFramebufferAttachmentParameterivEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6104(%rax), %r11
+       movq    6128(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6104(%rax), %r11
+       movq    6128(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -28884,7 +29011,7 @@ GL_PREFIX(GetFramebufferAttachmentParameterivEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6104(%rax), %r11
+       movq    6128(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetFramebufferAttachmentParameterivEXT), .-GL_PREFIX(GetFramebufferAttachmentParameterivEXT)
@@ -28895,7 +29022,7 @@ GL_PREFIX(GetFramebufferAttachmentParameterivEXT):
 GL_PREFIX(GetRenderbufferParameterivEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6112(%rax), %r11
+       movq    6136(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -28905,13 +29032,13 @@ GL_PREFIX(GetRenderbufferParameterivEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6112(%rax), %r11
+       movq    6136(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6112(%rax), %r11
+       movq    6136(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -28921,7 +29048,7 @@ GL_PREFIX(GetRenderbufferParameterivEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6112(%rax), %r11
+       movq    6136(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(GetRenderbufferParameterivEXT), .-GL_PREFIX(GetRenderbufferParameterivEXT)
@@ -28932,25 +29059,25 @@ GL_PREFIX(GetRenderbufferParameterivEXT):
 GL_PREFIX(IsFramebufferEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6120(%rax), %r11
+       movq    6144(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    6120(%rax), %r11
+       movq    6144(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6120(%rax), %r11
+       movq    6144(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    6120(%rax), %r11
+       movq    6144(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(IsFramebufferEXT), .-GL_PREFIX(IsFramebufferEXT)
@@ -28961,25 +29088,25 @@ GL_PREFIX(IsFramebufferEXT):
 GL_PREFIX(IsRenderbufferEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6128(%rax), %r11
+       movq    6152(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
        call    _x86_64_get_dispatch@PLT
        popq    %rdi
-       movq    6128(%rax), %r11
+       movq    6152(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6128(%rax), %r11
+       movq    6152(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
        call    _glapi_get_dispatch
        popq    %rdi
-       movq    6128(%rax), %r11
+       movq    6152(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(IsRenderbufferEXT), .-GL_PREFIX(IsRenderbufferEXT)
@@ -28990,7 +29117,7 @@ GL_PREFIX(IsRenderbufferEXT):
 GL_PREFIX(RenderbufferStorageEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6136(%rax), %r11
+       movq    6160(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -29004,13 +29131,13 @@ GL_PREFIX(RenderbufferStorageEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6136(%rax), %r11
+       movq    6160(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6136(%rax), %r11
+       movq    6160(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -29024,19 +29151,19 @@ GL_PREFIX(RenderbufferStorageEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6136(%rax), %r11
+       movq    6160(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(RenderbufferStorageEXT), .-GL_PREFIX(RenderbufferStorageEXT)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_768)
-       .type   GL_PREFIX(_dispatch_stub_768), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_768))
-GL_PREFIX(_dispatch_stub_768):
+       .globl  GL_PREFIX(_dispatch_stub_771)
+       .type   GL_PREFIX(_dispatch_stub_771), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_771))
+GL_PREFIX(_dispatch_stub_771):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6144(%rax), %r11
+       movq    6168(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -29054,13 +29181,13 @@ GL_PREFIX(_dispatch_stub_768):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6144(%rax), %r11
+       movq    6168(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6144(%rax), %r11
+       movq    6168(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -29078,10 +29205,10 @@ GL_PREFIX(_dispatch_stub_768):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6144(%rax), %r11
+       movq    6168(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_768), .-GL_PREFIX(_dispatch_stub_768)
+       .size   GL_PREFIX(_dispatch_stub_771), .-GL_PREFIX(_dispatch_stub_771)
 
        .p2align        4,,15
        .globl  GL_PREFIX(FramebufferTextureLayerEXT)
@@ -29089,7 +29216,7 @@ GL_PREFIX(_dispatch_stub_768):
 GL_PREFIX(FramebufferTextureLayerEXT):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6152(%rax), %r11
+       movq    6176(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -29103,13 +29230,13 @@ GL_PREFIX(FramebufferTextureLayerEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6152(%rax), %r11
+       movq    6176(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6152(%rax), %r11
+       movq    6176(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -29123,19 +29250,19 @@ GL_PREFIX(FramebufferTextureLayerEXT):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6152(%rax), %r11
+       movq    6176(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
        .size   GL_PREFIX(FramebufferTextureLayerEXT), .-GL_PREFIX(FramebufferTextureLayerEXT)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_770)
-       .type   GL_PREFIX(_dispatch_stub_770), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_770))
-GL_PREFIX(_dispatch_stub_770):
+       .globl  GL_PREFIX(_dispatch_stub_773)
+       .type   GL_PREFIX(_dispatch_stub_773), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_773))
+GL_PREFIX(_dispatch_stub_773):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6160(%rax), %r11
+       movq    6184(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -29149,13 +29276,13 @@ GL_PREFIX(_dispatch_stub_770):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6160(%rax), %r11
+       movq    6184(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6160(%rax), %r11
+       movq    6184(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -29169,19 +29296,19 @@ GL_PREFIX(_dispatch_stub_770):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6160(%rax), %r11
+       movq    6184(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_770), .-GL_PREFIX(_dispatch_stub_770)
+       .size   GL_PREFIX(_dispatch_stub_773), .-GL_PREFIX(_dispatch_stub_773)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_771)
-       .type   GL_PREFIX(_dispatch_stub_771), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_771))
-GL_PREFIX(_dispatch_stub_771):
+       .globl  GL_PREFIX(_dispatch_stub_774)
+       .type   GL_PREFIX(_dispatch_stub_774), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_774))
+GL_PREFIX(_dispatch_stub_774):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6168(%rax), %r11
+       movq    6192(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -29195,13 +29322,13 @@ GL_PREFIX(_dispatch_stub_771):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6168(%rax), %r11
+       movq    6192(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6168(%rax), %r11
+       movq    6192(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -29215,19 +29342,19 @@ GL_PREFIX(_dispatch_stub_771):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6168(%rax), %r11
+       movq    6192(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_771), .-GL_PREFIX(_dispatch_stub_771)
+       .size   GL_PREFIX(_dispatch_stub_774), .-GL_PREFIX(_dispatch_stub_774)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_772)
-       .type   GL_PREFIX(_dispatch_stub_772), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_772))
-GL_PREFIX(_dispatch_stub_772):
+       .globl  GL_PREFIX(_dispatch_stub_775)
+       .type   GL_PREFIX(_dispatch_stub_775), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_775))
+GL_PREFIX(_dispatch_stub_775):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6176(%rax), %r11
+       movq    6200(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -29241,13 +29368,13 @@ GL_PREFIX(_dispatch_stub_772):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6176(%rax), %r11
+       movq    6200(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6176(%rax), %r11
+       movq    6200(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -29261,19 +29388,19 @@ GL_PREFIX(_dispatch_stub_772):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6176(%rax), %r11
+       movq    6200(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_772), .-GL_PREFIX(_dispatch_stub_772)
+       .size   GL_PREFIX(_dispatch_stub_775), .-GL_PREFIX(_dispatch_stub_775)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_773)
-       .type   GL_PREFIX(_dispatch_stub_773), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_773))
-GL_PREFIX(_dispatch_stub_773):
+       .globl  GL_PREFIX(_dispatch_stub_776)
+       .type   GL_PREFIX(_dispatch_stub_776), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_776))
+GL_PREFIX(_dispatch_stub_776):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6184(%rax), %r11
+       movq    6208(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -29283,13 +29410,13 @@ GL_PREFIX(_dispatch_stub_773):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6184(%rax), %r11
+       movq    6208(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6184(%rax), %r11
+       movq    6208(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -29299,19 +29426,19 @@ GL_PREFIX(_dispatch_stub_773):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6184(%rax), %r11
+       movq    6208(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_773), .-GL_PREFIX(_dispatch_stub_773)
+       .size   GL_PREFIX(_dispatch_stub_776), .-GL_PREFIX(_dispatch_stub_776)
 
        .p2align        4,,15
-       .globl  GL_PREFIX(_dispatch_stub_774)
-       .type   GL_PREFIX(_dispatch_stub_774), @function
-       HIDDEN(GL_PREFIX(_dispatch_stub_774))
-GL_PREFIX(_dispatch_stub_774):
+       .globl  GL_PREFIX(_dispatch_stub_777)
+       .type   GL_PREFIX(_dispatch_stub_777), @function
+       HIDDEN(GL_PREFIX(_dispatch_stub_777))
+GL_PREFIX(_dispatch_stub_777):
 #if defined(GLX_USE_TLS)
        call    _x86_64_get_dispatch@PLT
-       movq    6192(%rax), %r11
+       movq    6216(%rax), %r11
        jmp     *%r11
 #elif defined(PTHREADS)
        pushq   %rdi
@@ -29321,13 +29448,13 @@ GL_PREFIX(_dispatch_stub_774):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6192(%rax), %r11
+       movq    6216(%rax), %r11
        jmp     *%r11
 #else
        movq    _glapi_Dispatch(%rip), %rax
        testq   %rax, %rax
        je      1f
-       movq    6192(%rax), %r11
+       movq    6216(%rax), %r11
        jmp     *%r11
 1:
        pushq   %rdi
@@ -29337,10 +29464,10 @@ GL_PREFIX(_dispatch_stub_774):
        popq    %rdx
        popq    %rsi
        popq    %rdi
-       movq    6192(%rax), %r11
+       movq    6216(%rax), %r11
        jmp     *%r11
 #endif /* defined(GLX_USE_TLS) */
-       .size   GL_PREFIX(_dispatch_stub_774), .-GL_PREFIX(_dispatch_stub_774)
+       .size   GL_PREFIX(_dispatch_stub_777), .-GL_PREFIX(_dispatch_stub_777)
 
        .globl GL_PREFIX(ArrayElementEXT) ; .set GL_PREFIX(ArrayElementEXT), GL_PREFIX(ArrayElement)
        .globl GL_PREFIX(BindTextureEXT) ; .set GL_PREFIX(BindTextureEXT), GL_PREFIX(BindTexture)
@@ -29595,7 +29722,7 @@ GL_PREFIX(_dispatch_stub_774):
        .globl GL_PREFIX(IsProgramARB) ; .set GL_PREFIX(IsProgramARB), GL_PREFIX(IsProgramNV)
        .globl GL_PREFIX(PointParameteri) ; .set GL_PREFIX(PointParameteri), GL_PREFIX(PointParameteriNV)
        .globl GL_PREFIX(PointParameteriv) ; .set GL_PREFIX(PointParameteriv), GL_PREFIX(PointParameterivNV)
-       .globl GL_PREFIX(BlendEquationSeparate) ; .set GL_PREFIX(BlendEquationSeparate), GL_PREFIX(_dispatch_stub_750)
+       .globl GL_PREFIX(BlendEquationSeparate) ; .set GL_PREFIX(BlendEquationSeparate), GL_PREFIX(_dispatch_stub_753)
        .globl GL_PREFIX(BindFramebuffer) ; .set GL_PREFIX(BindFramebuffer), GL_PREFIX(BindFramebufferEXT)
        .globl GL_PREFIX(BindRenderbuffer) ; .set GL_PREFIX(BindRenderbuffer), GL_PREFIX(BindRenderbufferEXT)
        .globl GL_PREFIX(CheckFramebufferStatus) ; .set GL_PREFIX(CheckFramebufferStatus), GL_PREFIX(CheckFramebufferStatusEXT)
@@ -29613,7 +29740,7 @@ GL_PREFIX(_dispatch_stub_774):
        .globl GL_PREFIX(IsFramebuffer) ; .set GL_PREFIX(IsFramebuffer), GL_PREFIX(IsFramebufferEXT)
        .globl GL_PREFIX(IsRenderbuffer) ; .set GL_PREFIX(IsRenderbuffer), GL_PREFIX(IsRenderbufferEXT)
        .globl GL_PREFIX(RenderbufferStorage) ; .set GL_PREFIX(RenderbufferStorage), GL_PREFIX(RenderbufferStorageEXT)
-       .globl GL_PREFIX(BlitFramebuffer) ; .set GL_PREFIX(BlitFramebuffer), GL_PREFIX(_dispatch_stub_768)
+       .globl GL_PREFIX(BlitFramebuffer) ; .set GL_PREFIX(BlitFramebuffer), GL_PREFIX(_dispatch_stub_771)
        .globl GL_PREFIX(FramebufferTextureLayer) ; .set GL_PREFIX(FramebufferTextureLayer), GL_PREFIX(FramebufferTextureLayerEXT)
 
 #if defined(GLX_USE_TLS) && defined(__linux__)
index 7aa344f214e92140e023b741568a352d4b591cbc..8d5ef4f90c7e6bada929b9937f4fd7991b1e27e8 100644 (file)
@@ -713,23 +713,26 @@ GLNAME(gl_dispatch_functions_start):
        GL_STUB(GetAttribLocationARB, _gloffset_GetAttribLocationARB, GetAttribLocationARB@8)
        GL_STUB(DrawBuffersARB, _gloffset_DrawBuffersARB, DrawBuffersARB@8)
        GL_STUB(RenderbufferStorageMultisample, _gloffset_RenderbufferStorageMultisample, RenderbufferStorageMultisample@20)
+       GL_STUB(FlushMappedBufferRange, _gloffset_FlushMappedBufferRange, FlushMappedBufferRange@12)
+       GL_STUB(MapBufferRange, _gloffset_MapBufferRange, MapBufferRange@16)
+       GL_STUB(CopyBufferSubData, _gloffset_CopyBufferSubData, CopyBufferSubData@20)
        GL_STUB(PolygonOffsetEXT, _gloffset_PolygonOffsetEXT, PolygonOffsetEXT@8)
-       GL_STUB(_dispatch_stub_563, _gloffset_GetPixelTexGenParameterfvSGIS, _dispatch_stub_563@8)
-       HIDDEN(GL_PREFIX(_dispatch_stub_563, _dispatch_stub_563@8))
-       GL_STUB(_dispatch_stub_564, _gloffset_GetPixelTexGenParameterivSGIS, _dispatch_stub_564@8)
-       HIDDEN(GL_PREFIX(_dispatch_stub_564, _dispatch_stub_564@8))
-       GL_STUB(_dispatch_stub_565, _gloffset_PixelTexGenParameterfSGIS, _dispatch_stub_565@8)
-       HIDDEN(GL_PREFIX(_dispatch_stub_565, _dispatch_stub_565@8))
-       GL_STUB(_dispatch_stub_566, _gloffset_PixelTexGenParameterfvSGIS, _dispatch_stub_566@8)
+       GL_STUB(_dispatch_stub_566, _gloffset_GetPixelTexGenParameterfvSGIS, _dispatch_stub_566@8)
        HIDDEN(GL_PREFIX(_dispatch_stub_566, _dispatch_stub_566@8))
-       GL_STUB(_dispatch_stub_567, _gloffset_PixelTexGenParameteriSGIS, _dispatch_stub_567@8)
+       GL_STUB(_dispatch_stub_567, _gloffset_GetPixelTexGenParameterivSGIS, _dispatch_stub_567@8)
        HIDDEN(GL_PREFIX(_dispatch_stub_567, _dispatch_stub_567@8))
-       GL_STUB(_dispatch_stub_568, _gloffset_PixelTexGenParameterivSGIS, _dispatch_stub_568@8)
+       GL_STUB(_dispatch_stub_568, _gloffset_PixelTexGenParameterfSGIS, _dispatch_stub_568@8)
        HIDDEN(GL_PREFIX(_dispatch_stub_568, _dispatch_stub_568@8))
-       GL_STUB(_dispatch_stub_569, _gloffset_SampleMaskSGIS, _dispatch_stub_569@8)
+       GL_STUB(_dispatch_stub_569, _gloffset_PixelTexGenParameterfvSGIS, _dispatch_stub_569@8)
        HIDDEN(GL_PREFIX(_dispatch_stub_569, _dispatch_stub_569@8))
-       GL_STUB(_dispatch_stub_570, _gloffset_SamplePatternSGIS, _dispatch_stub_570@4)
-       HIDDEN(GL_PREFIX(_dispatch_stub_570, _dispatch_stub_570@4))
+       GL_STUB(_dispatch_stub_570, _gloffset_PixelTexGenParameteriSGIS, _dispatch_stub_570@8)
+       HIDDEN(GL_PREFIX(_dispatch_stub_570, _dispatch_stub_570@8))
+       GL_STUB(_dispatch_stub_571, _gloffset_PixelTexGenParameterivSGIS, _dispatch_stub_571@8)
+       HIDDEN(GL_PREFIX(_dispatch_stub_571, _dispatch_stub_571@8))
+       GL_STUB(_dispatch_stub_572, _gloffset_SampleMaskSGIS, _dispatch_stub_572@8)
+       HIDDEN(GL_PREFIX(_dispatch_stub_572, _dispatch_stub_572@8))
+       GL_STUB(_dispatch_stub_573, _gloffset_SamplePatternSGIS, _dispatch_stub_573@4)
+       HIDDEN(GL_PREFIX(_dispatch_stub_573, _dispatch_stub_573@4))
        GL_STUB(ColorPointerEXT, _gloffset_ColorPointerEXT, ColorPointerEXT@20)
        GL_STUB(EdgeFlagPointerEXT, _gloffset_EdgeFlagPointerEXT, EdgeFlagPointerEXT@12)
        GL_STUB(IndexPointerEXT, _gloffset_IndexPointerEXT, IndexPointerEXT@16)
@@ -740,10 +743,10 @@ GLNAME(gl_dispatch_functions_start):
        GL_STUB(PointParameterfvEXT, _gloffset_PointParameterfvEXT, PointParameterfvEXT@8)
        GL_STUB(LockArraysEXT, _gloffset_LockArraysEXT, LockArraysEXT@8)
        GL_STUB(UnlockArraysEXT, _gloffset_UnlockArraysEXT, UnlockArraysEXT@0)
-       GL_STUB(_dispatch_stub_581, _gloffset_CullParameterdvEXT, _dispatch_stub_581@8)
-       HIDDEN(GL_PREFIX(_dispatch_stub_581, _dispatch_stub_581@8))
-       GL_STUB(_dispatch_stub_582, _gloffset_CullParameterfvEXT, _dispatch_stub_582@8)
-       HIDDEN(GL_PREFIX(_dispatch_stub_582, _dispatch_stub_582@8))
+       GL_STUB(_dispatch_stub_584, _gloffset_CullParameterdvEXT, _dispatch_stub_584@8)
+       HIDDEN(GL_PREFIX(_dispatch_stub_584, _dispatch_stub_584@8))
+       GL_STUB(_dispatch_stub_585, _gloffset_CullParameterfvEXT, _dispatch_stub_585@8)
+       HIDDEN(GL_PREFIX(_dispatch_stub_585, _dispatch_stub_585@8))
        GL_STUB(SecondaryColor3bEXT, _gloffset_SecondaryColor3bEXT, SecondaryColor3bEXT@12)
        GL_STUB(SecondaryColor3bvEXT, _gloffset_SecondaryColor3bvEXT, SecondaryColor3bvEXT@4)
        GL_STUB(SecondaryColor3dEXT, _gloffset_SecondaryColor3dEXT, SecondaryColor3dEXT@24)
@@ -768,8 +771,8 @@ GLNAME(gl_dispatch_functions_start):
        GL_STUB(FogCoorddvEXT, _gloffset_FogCoorddvEXT, FogCoorddvEXT@4)
        GL_STUB(FogCoordfEXT, _gloffset_FogCoordfEXT, FogCoordfEXT@4)
        GL_STUB(FogCoordfvEXT, _gloffset_FogCoordfvEXT, FogCoordfvEXT@4)
-       GL_STUB(_dispatch_stub_607, _gloffset_PixelTexGenSGIX, _dispatch_stub_607@4)
-       HIDDEN(GL_PREFIX(_dispatch_stub_607, _dispatch_stub_607@4))
+       GL_STUB(_dispatch_stub_610, _gloffset_PixelTexGenSGIX, _dispatch_stub_610@4)
+       HIDDEN(GL_PREFIX(_dispatch_stub_610, _dispatch_stub_610@4))
        GL_STUB(BlendFuncSeparateEXT, _gloffset_BlendFuncSeparateEXT, BlendFuncSeparateEXT@16)
        GL_STUB(FlushVertexArrayRangeNV, _gloffset_FlushVertexArrayRangeNV, FlushVertexArrayRangeNV@0)
        GL_STUB(VertexArrayRangeNV, _gloffset_VertexArrayRangeNV, VertexArrayRangeNV@8)
@@ -811,24 +814,24 @@ GLNAME(gl_dispatch_functions_start):
        GL_STUB(WindowPos4ivMESA, _gloffset_WindowPos4ivMESA, WindowPos4ivMESA@4)
        GL_STUB(WindowPos4sMESA, _gloffset_WindowPos4sMESA, WindowPos4sMESA@16)
        GL_STUB(WindowPos4svMESA, _gloffset_WindowPos4svMESA, WindowPos4svMESA@4)
-       GL_STUB(_dispatch_stub_649, _gloffset_MultiModeDrawArraysIBM, _dispatch_stub_649@20)
-       HIDDEN(GL_PREFIX(_dispatch_stub_649, _dispatch_stub_649@20))
-       GL_STUB(_dispatch_stub_650, _gloffset_MultiModeDrawElementsIBM, _dispatch_stub_650@24)
-       HIDDEN(GL_PREFIX(_dispatch_stub_650, _dispatch_stub_650@24))
-       GL_STUB(_dispatch_stub_651, _gloffset_DeleteFencesNV, _dispatch_stub_651@8)
-       HIDDEN(GL_PREFIX(_dispatch_stub_651, _dispatch_stub_651@8))
-       GL_STUB(_dispatch_stub_652, _gloffset_FinishFenceNV, _dispatch_stub_652@4)
-       HIDDEN(GL_PREFIX(_dispatch_stub_652, _dispatch_stub_652@4))
-       GL_STUB(_dispatch_stub_653, _gloffset_GenFencesNV, _dispatch_stub_653@8)
-       HIDDEN(GL_PREFIX(_dispatch_stub_653, _dispatch_stub_653@8))
-       GL_STUB(_dispatch_stub_654, _gloffset_GetFenceivNV, _dispatch_stub_654@12)
-       HIDDEN(GL_PREFIX(_dispatch_stub_654, _dispatch_stub_654@12))
-       GL_STUB(_dispatch_stub_655, _gloffset_IsFenceNV, _dispatch_stub_655@4)
+       GL_STUB(_dispatch_stub_652, _gloffset_MultiModeDrawArraysIBM, _dispatch_stub_652@20)
+       HIDDEN(GL_PREFIX(_dispatch_stub_652, _dispatch_stub_652@20))
+       GL_STUB(_dispatch_stub_653, _gloffset_MultiModeDrawElementsIBM, _dispatch_stub_653@24)
+       HIDDEN(GL_PREFIX(_dispatch_stub_653, _dispatch_stub_653@24))
+       GL_STUB(_dispatch_stub_654, _gloffset_DeleteFencesNV, _dispatch_stub_654@8)
+       HIDDEN(GL_PREFIX(_dispatch_stub_654, _dispatch_stub_654@8))
+       GL_STUB(_dispatch_stub_655, _gloffset_FinishFenceNV, _dispatch_stub_655@4)
        HIDDEN(GL_PREFIX(_dispatch_stub_655, _dispatch_stub_655@4))
-       GL_STUB(_dispatch_stub_656, _gloffset_SetFenceNV, _dispatch_stub_656@8)
+       GL_STUB(_dispatch_stub_656, _gloffset_GenFencesNV, _dispatch_stub_656@8)
        HIDDEN(GL_PREFIX(_dispatch_stub_656, _dispatch_stub_656@8))
-       GL_STUB(_dispatch_stub_657, _gloffset_TestFenceNV, _dispatch_stub_657@4)
-       HIDDEN(GL_PREFIX(_dispatch_stub_657, _dispatch_stub_657@4))
+       GL_STUB(_dispatch_stub_657, _gloffset_GetFenceivNV, _dispatch_stub_657@12)
+       HIDDEN(GL_PREFIX(_dispatch_stub_657, _dispatch_stub_657@12))
+       GL_STUB(_dispatch_stub_658, _gloffset_IsFenceNV, _dispatch_stub_658@4)
+       HIDDEN(GL_PREFIX(_dispatch_stub_658, _dispatch_stub_658@4))
+       GL_STUB(_dispatch_stub_659, _gloffset_SetFenceNV, _dispatch_stub_659@8)
+       HIDDEN(GL_PREFIX(_dispatch_stub_659, _dispatch_stub_659@8))
+       GL_STUB(_dispatch_stub_660, _gloffset_TestFenceNV, _dispatch_stub_660@4)
+       HIDDEN(GL_PREFIX(_dispatch_stub_660, _dispatch_stub_660@4))
        GL_STUB(AreProgramsResidentNV, _gloffset_AreProgramsResidentNV, AreProgramsResidentNV@12)
        GL_STUB(BindProgramNV, _gloffset_BindProgramNV, BindProgramNV@8)
        GL_STUB(DeleteProgramsNV, _gloffset_DeleteProgramsNV, DeleteProgramsNV@8)
@@ -909,26 +912,26 @@ GLNAME(gl_dispatch_functions_start):
        GL_STUB(SetFragmentShaderConstantATI, _gloffset_SetFragmentShaderConstantATI, SetFragmentShaderConstantATI@8)
        GL_STUB(PointParameteriNV, _gloffset_PointParameteriNV, PointParameteriNV@8)
        GL_STUB(PointParameterivNV, _gloffset_PointParameterivNV, PointParameterivNV@8)
-       GL_STUB(_dispatch_stub_738, _gloffset_ActiveStencilFaceEXT, _dispatch_stub_738@4)
-       HIDDEN(GL_PREFIX(_dispatch_stub_738, _dispatch_stub_738@4))
-       GL_STUB(_dispatch_stub_739, _gloffset_BindVertexArrayAPPLE, _dispatch_stub_739@4)
-       HIDDEN(GL_PREFIX(_dispatch_stub_739, _dispatch_stub_739@4))
-       GL_STUB(_dispatch_stub_740, _gloffset_DeleteVertexArraysAPPLE, _dispatch_stub_740@8)
-       HIDDEN(GL_PREFIX(_dispatch_stub_740, _dispatch_stub_740@8))
-       GL_STUB(_dispatch_stub_741, _gloffset_GenVertexArraysAPPLE, _dispatch_stub_741@8)
-       HIDDEN(GL_PREFIX(_dispatch_stub_741, _dispatch_stub_741@8))
-       GL_STUB(_dispatch_stub_742, _gloffset_IsVertexArrayAPPLE, _dispatch_stub_742@4)
+       GL_STUB(_dispatch_stub_741, _gloffset_ActiveStencilFaceEXT, _dispatch_stub_741@4)
+       HIDDEN(GL_PREFIX(_dispatch_stub_741, _dispatch_stub_741@4))
+       GL_STUB(_dispatch_stub_742, _gloffset_BindVertexArrayAPPLE, _dispatch_stub_742@4)
        HIDDEN(GL_PREFIX(_dispatch_stub_742, _dispatch_stub_742@4))
+       GL_STUB(_dispatch_stub_743, _gloffset_DeleteVertexArraysAPPLE, _dispatch_stub_743@8)
+       HIDDEN(GL_PREFIX(_dispatch_stub_743, _dispatch_stub_743@8))
+       GL_STUB(_dispatch_stub_744, _gloffset_GenVertexArraysAPPLE, _dispatch_stub_744@8)
+       HIDDEN(GL_PREFIX(_dispatch_stub_744, _dispatch_stub_744@8))
+       GL_STUB(_dispatch_stub_745, _gloffset_IsVertexArrayAPPLE, _dispatch_stub_745@4)
+       HIDDEN(GL_PREFIX(_dispatch_stub_745, _dispatch_stub_745@4))
        GL_STUB(GetProgramNamedParameterdvNV, _gloffset_GetProgramNamedParameterdvNV, GetProgramNamedParameterdvNV@16)
        GL_STUB(GetProgramNamedParameterfvNV, _gloffset_GetProgramNamedParameterfvNV, GetProgramNamedParameterfvNV@16)
        GL_STUB(ProgramNamedParameter4dNV, _gloffset_ProgramNamedParameter4dNV, ProgramNamedParameter4dNV@44)
        GL_STUB(ProgramNamedParameter4dvNV, _gloffset_ProgramNamedParameter4dvNV, ProgramNamedParameter4dvNV@16)
        GL_STUB(ProgramNamedParameter4fNV, _gloffset_ProgramNamedParameter4fNV, ProgramNamedParameter4fNV@28)
        GL_STUB(ProgramNamedParameter4fvNV, _gloffset_ProgramNamedParameter4fvNV, ProgramNamedParameter4fvNV@16)
-       GL_STUB(_dispatch_stub_749, _gloffset_DepthBoundsEXT, _dispatch_stub_749@16)
-       HIDDEN(GL_PREFIX(_dispatch_stub_749, _dispatch_stub_749@16))
-       GL_STUB(_dispatch_stub_750, _gloffset_BlendEquationSeparateEXT, _dispatch_stub_750@8)
-       HIDDEN(GL_PREFIX(_dispatch_stub_750, _dispatch_stub_750@8))
+       GL_STUB(_dispatch_stub_752, _gloffset_DepthBoundsEXT, _dispatch_stub_752@16)
+       HIDDEN(GL_PREFIX(_dispatch_stub_752, _dispatch_stub_752@16))
+       GL_STUB(_dispatch_stub_753, _gloffset_BlendEquationSeparateEXT, _dispatch_stub_753@8)
+       HIDDEN(GL_PREFIX(_dispatch_stub_753, _dispatch_stub_753@8))
        GL_STUB(BindFramebufferEXT, _gloffset_BindFramebufferEXT, BindFramebufferEXT@8)
        GL_STUB(BindRenderbufferEXT, _gloffset_BindRenderbufferEXT, BindRenderbufferEXT@8)
        GL_STUB(CheckFramebufferStatusEXT, _gloffset_CheckFramebufferStatusEXT, CheckFramebufferStatusEXT@4)
@@ -946,19 +949,19 @@ GLNAME(gl_dispatch_functions_start):
        GL_STUB(IsFramebufferEXT, _gloffset_IsFramebufferEXT, IsFramebufferEXT@4)
        GL_STUB(IsRenderbufferEXT, _gloffset_IsRenderbufferEXT, IsRenderbufferEXT@4)
        GL_STUB(RenderbufferStorageEXT, _gloffset_RenderbufferStorageEXT, RenderbufferStorageEXT@16)
-       GL_STUB(_dispatch_stub_768, _gloffset_BlitFramebufferEXT, _dispatch_stub_768@40)
-       HIDDEN(GL_PREFIX(_dispatch_stub_768, _dispatch_stub_768@40))
+       GL_STUB(_dispatch_stub_771, _gloffset_BlitFramebufferEXT, _dispatch_stub_771@40)
+       HIDDEN(GL_PREFIX(_dispatch_stub_771, _dispatch_stub_771@40))
        GL_STUB(FramebufferTextureLayerEXT, _gloffset_FramebufferTextureLayerEXT, FramebufferTextureLayerEXT@20)
-       GL_STUB(_dispatch_stub_770, _gloffset_StencilFuncSeparateATI, _dispatch_stub_770@16)
-       HIDDEN(GL_PREFIX(_dispatch_stub_770, _dispatch_stub_770@16))
-       GL_STUB(_dispatch_stub_771, _gloffset_ProgramEnvParameters4fvEXT, _dispatch_stub_771@16)
-       HIDDEN(GL_PREFIX(_dispatch_stub_771, _dispatch_stub_771@16))
-       GL_STUB(_dispatch_stub_772, _gloffset_ProgramLocalParameters4fvEXT, _dispatch_stub_772@16)
-       HIDDEN(GL_PREFIX(_dispatch_stub_772, _dispatch_stub_772@16))
-       GL_STUB(_dispatch_stub_773, _gloffset_GetQueryObjecti64vEXT, _dispatch_stub_773@12)
-       HIDDEN(GL_PREFIX(_dispatch_stub_773, _dispatch_stub_773@12))
-       GL_STUB(_dispatch_stub_774, _gloffset_GetQueryObjectui64vEXT, _dispatch_stub_774@12)
-       HIDDEN(GL_PREFIX(_dispatch_stub_774, _dispatch_stub_774@12))
+       GL_STUB(_dispatch_stub_773, _gloffset_StencilFuncSeparateATI, _dispatch_stub_773@16)
+       HIDDEN(GL_PREFIX(_dispatch_stub_773, _dispatch_stub_773@16))
+       GL_STUB(_dispatch_stub_774, _gloffset_ProgramEnvParameters4fvEXT, _dispatch_stub_774@16)
+       HIDDEN(GL_PREFIX(_dispatch_stub_774, _dispatch_stub_774@16))
+       GL_STUB(_dispatch_stub_775, _gloffset_ProgramLocalParameters4fvEXT, _dispatch_stub_775@16)
+       HIDDEN(GL_PREFIX(_dispatch_stub_775, _dispatch_stub_775@16))
+       GL_STUB(_dispatch_stub_776, _gloffset_GetQueryObjecti64vEXT, _dispatch_stub_776@12)
+       HIDDEN(GL_PREFIX(_dispatch_stub_776, _dispatch_stub_776@12))
+       GL_STUB(_dispatch_stub_777, _gloffset_GetQueryObjectui64vEXT, _dispatch_stub_777@12)
+       HIDDEN(GL_PREFIX(_dispatch_stub_777, _dispatch_stub_777@12))
        GL_STUB_ALIAS(ArrayElementEXT, _gloffset_ArrayElement, ArrayElementEXT@4, ArrayElement, ArrayElement@4)
        GL_STUB_ALIAS(BindTextureEXT, _gloffset_BindTexture, BindTextureEXT@8, BindTexture, BindTexture@8)
        GL_STUB_ALIAS(DrawArraysEXT, _gloffset_DrawArrays, DrawArraysEXT@12, DrawArrays, DrawArrays@12)